From dcafe7cb48f5e4582a4711652b38629c46675232 Mon Sep 17 00:00:00 2001 From: Arshad Hussain Date: Tue, 4 Dec 2018 23:50:59 +0530 Subject: [PATCH] LU-8260 osd-ldiskfs: osd_fiemap_get() fix address space mismatch There was an address space mismatch in function osd_fiemap_get() as this uses "__user" qualifier in fiemap_extent buffer. Since this buffer is created under kernel and again passed to another call, this may fail under some configuration. This patch address this issue by modifying the address space limit by using get_fs() and set_fs() call suggesting that the pointers are intact and secure. Change-Id: I25048faecd3475d5e91e25e6a47e065e49e36b26 Signed-off-by: Arshad Hussain Reviewed-on: https://review.whamcloud.com/33878 Reviewed-by: Andreas Dilger Reviewed-by: Ben Evans Reviewed-by: James Simmons Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/osd-ldiskfs/osd_io.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 59c87fc..7140abe 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -2234,7 +2234,7 @@ static int osd_fiemap_get(const struct lu_env *env, struct dt_object *dt, struct inode *inode = osd_dt_obj(dt)->oo_inode; u64 len; int rc; - + mm_segment_t cur_fs; LASSERT(inode); if (inode->i_op->fiemap == NULL) @@ -2254,10 +2254,18 @@ static int osd_fiemap_get(const struct lu_env *env, struct dt_object *dt, if (fieinfo.fi_flags & FIEMAP_FLAG_SYNC) filemap_write_and_wait(inode->i_mapping); + /* Save previous value address limit */ + cur_fs = get_fs(); + /* Set the address limit of the kernel */ + set_fs(get_ds()); + rc = inode->i_op->fiemap(inode, &fieinfo, fm->fm_start, len); fm->fm_flags = fieinfo.fi_flags; fm->fm_mapped_extents = fieinfo.fi_extents_mapped; + /* Restore the previous address limt */ + set_fs(cur_fs); + return rc; } -- 1.8.3.1