From: Sasha Levin Date: Wed, 28 Jan 2015 11:30:43 +0000 (+0900) Subject: vfs: read file_handle only once in handle_to_path X-Git-Tag: TizenStudio_2.0_p2.3.1~17 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=92ccb5b4e1c4da8a08d4976e6fa10998f1910286;p=sdk%2Femulator%2Femulator-kernel.git vfs: read file_handle only once in handle_to_path This patch was related with "[CVE-2015-1420] Race condition in fs/fhandle.c in the Linux kernel". We used to read file_handle twice. Once to get the amount of extra bytes, and once to fetch the entire structure. This may be problematic since we do size verifications only after the first read, so if the number of extra bytes changes in userspace between the first and second calls, we'll have an incoherent view of file_handle. Instead, read the constant size once, and copy that over to the final structure without having to re-read it again. Change-Id: I318d7428079e323f53bc7eb1f7dc0a5dfac7eb0b Signed-off-by: Sasha Levin Signed-off-by: Byungsoo Kim Signed-off-by: sungmin ha --- diff --git a/fs/fhandle.c b/fs/fhandle.c index 999ff5c3cab0..d59712dfa3e7 100644 --- a/fs/fhandle.c +++ b/fs/fhandle.c @@ -195,8 +195,9 @@ static int handle_to_path(int mountdirfd, struct file_handle __user *ufh, goto out_err; } /* copy the full handle */ - if (copy_from_user(handle, ufh, - sizeof(struct file_handle) + + *handle = f_handle; + if (copy_from_user(&handle->f_handle, + &ufh->f_handle, f_handle.handle_bytes)) { retval = -EFAULT; goto out_handle;