Skip to content

Commit 6343a21

Browse files
Miklos SzerediJ. Bruce Fields
authored andcommitted
locks: use file_inode()
(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 <eguan@redhat.com> Fixes: 4bacc9c ("overlayfs: Make f_path always point to the overlay and f_inode to the underlay") Cc: <stable@vger.kernel.org> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent cb7d224 commit 6343a21

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/locks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1628,7 +1628,7 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
16281628
{
16291629
struct file_lock *fl, *my_fl = NULL, *lease;
16301630
struct dentry *dentry = filp->f_path.dentry;
1631-
struct inode *inode = dentry->d_inode;
1631+
struct inode *inode = file_inode(filp);
16321632
struct file_lock_context *ctx;
16331633
bool is_deleg = (*flp)->fl_flags & FL_DELEG;
16341634
int error;

0 commit comments

Comments
 (0)