* [PATCH] locks: use file_inode()
@ 2016-07-01 12:56 Miklos Szeredi
2016-07-01 13:05 ` Jeff Layton
0 siblings, 1 reply; 3+ messages in thread
From: Miklos Szeredi @ 2016-07-01 12:56 UTC (permalink / raw)
To: Al Viro
Cc: linux-kernel, linux-fsdevel, linux-unionfs, stable, Jeff Layton,
J. Bruce Fields
(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>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Fixes: 4bacc9c9234c ("overlayfs: Make f_path always point to the overlay and f_inode to the underlay")
Cc: <stable@vger.kernel.org>
Cc: Jeff Layton <jlayton@poochiereds.net>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
---
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;
--
2.5.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] locks: use file_inode()
2016-07-01 12:56 [PATCH] locks: use file_inode() Miklos Szeredi
@ 2016-07-01 13:05 ` Jeff Layton
2016-07-01 13:47 ` J. Bruce Fields
0 siblings, 1 reply; 3+ messages in thread
From: Jeff Layton @ 2016-07-01 13:05 UTC (permalink / raw)
To: Miklos Szeredi, Al Viro
Cc: linux-kernel, linux-fsdevel, linux-unionfs, stable,
J. Bruce Fields
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 <eguan@redhat.com>
> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
> Fixes: 4bacc9c9234c ("overlayfs: Make f_path always point to the overlay and f_inode to the underlay")
> Cc: <stable@vger.kernel.org>
> Cc: Jeff Layton <jlayton@poochiereds.net>
> Cc: "J. Bruce Fields" <bfields@fieldses.org>
> ---
> 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 <jlayton@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] locks: use file_inode()
2016-07-01 13:05 ` Jeff Layton
@ 2016-07-01 13:47 ` J. Bruce Fields
0 siblings, 0 replies; 3+ messages in thread
From: J. Bruce Fields @ 2016-07-01 13:47 UTC (permalink / raw)
To: Jeff Layton
Cc: Miklos Szeredi, Al Viro, linux-kernel, linux-fsdevel,
linux-unionfs, stable
On Fri, Jul 01, 2016 at 09:05:10AM -0400, Jeff Layton wrote:
> 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 <eguan@redhat.com>
> > Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
> > Fixes: 4bacc9c9234c ("overlayfs: Make f_path always point to the overlay and f_inode to the underlay")
> > Cc: <stable@vger.kernel.org>
> > Cc: Jeff Layton <jlayton@poochiereds.net>
> > Cc: "J. Bruce Fields" <bfields@fieldses.org>
> > ---
> > 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 <jlayton@redhat.com>
I'll take it and pass it along in a pull request later today, unless
somebody tells me otherwise.
--b.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-07-01 13:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-01 12:56 [PATCH] locks: use file_inode() Miklos Szeredi
2016-07-01 13:05 ` Jeff Layton
2016-07-01 13:47 ` J. Bruce Fields
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).