From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752477AbcGANFQ (ORCPT ); Fri, 1 Jul 2016 09:05:16 -0400 Received: from mail-qk0-f180.google.com ([209.85.220.180]:35386 "EHLO mail-qk0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751981AbcGANFO (ORCPT ); Fri, 1 Jul 2016 09:05:14 -0400 Message-ID: <1467378310.7477.3.camel@redhat.com> Subject: Re: [PATCH] locks: use file_inode() From: Jeff Layton To: Miklos Szeredi , Al Viro Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, stable@vger.kernel.org, "J. Bruce Fields" Date: Fri, 01 Jul 2016 09:05:10 -0400 In-Reply-To: <1467377767-12845-1-git-send-email-mszeredi@redhat.com> References: <1467377767-12845-1-git-send-email-mszeredi@redhat.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.3 (3.20.3-1.fc24) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2016-07-01 at 14:56 +0200, Miklos Szeredi wrote: > (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 > Signed-off-by: Miklos Szeredi > Fixes: 4bacc9c9234c ("overlayfs: Make f_path always point to the overlay and f_inode to the underlay") > Cc: > Cc: Jeff Layton > Cc: "J. Bruce Fields" > --- >  fs/locks.c | 2 +- >  1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/locks.c b/fs/locks.c > index 7c5f91be9b65..ee1b15f6fc13 100644 > --- a/fs/locks.c > +++ b/fs/locks.c > @@ -1628,7 +1628,7 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr >  { >   struct file_lock *fl, *my_fl = NULL, *lease; >   struct dentry *dentry = filp->f_path.dentry; > - struct inode *inode = dentry->d_inode; > + struct inode *inode = file_inode(filp); >   struct file_lock_context *ctx; >   bool is_deleg = (*flp)->fl_flags & FL_DELEG; >   int error; Looks good. Al or Bruce, if either of you have remaining patches this cycle then could one of you take this one? Otherwise, I can queue up a branch with it. Reviewed-by: Jeff Layton