From: Miklos Szeredi Date: Fri, 1 Jul 2016 12:56:07 +0000 (+0200) Subject: locks: use file_inode() X-Git-Tag: accepted/tizen/4.0/unified/20170925.150838~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F00%2F152100%2F4;p=profile%2Fwearable%2Fplatform%2Fkernel%2Flinux-3.18-exynos7270.git locks: use file_inode() [ Upstream commit 6343a2120862f7023006c8091ad95c1f16a32077 ] (Another one for the f_path debacle.) ltp fcntl33 testcase caused an Oops in selinux_file_send_sigiotask. The reason is that generic_add_lease() used filp->f_path.dentry->inode while all the others use file_inode(). This makes a difference for files opened on overlayfs since the former will point to the overlay inode the latter to the underlying inode. So generic_add_lease() added the lease to the overlay inode and generic_delete_lease() removed it from the underlying inode. When the file was released the lease remained on the overlay inode's lock list, resulting in use after free. Reported-by: Eryu Guan Fixes: 4bacc9c9234c ("overlayfs: Make f_path always point to the overlay and f_inode to the underlay") Cc: Signed-off-by: Miklos Szeredi Reviewed-by: Jeff Layton Signed-off-by: J. Bruce Fields Signed-off-by: Sasha Levin [jcsing.lee: cherry-pick from linux-3.18.y to fix ltp issue] Signed-off-by: Jaechul Lee Change-Id: I6091178a330b85ebb34022f9fbbd5226516399f5 --- diff --git a/fs/locks.c b/fs/locks.c index 59e2f90..7207434 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -1580,7 +1580,7 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr { struct file_lock *fl, **before, **my_before = NULL, *lease; struct dentry *dentry = filp->f_path.dentry; - struct inode *inode = dentry->d_inode; + struct inode *inode = file_inode(filp); bool is_deleg = (*flp)->fl_flags & FL_DELEG; int error; LIST_HEAD(dispose);