lkml.org 
[lkml]   [2020]   [Jan]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 4.19 43/92] do_last(): fetch directory ->i_mode and ->i_uid before its too late
On Fri, Jan 31, 2020 at 10:08:37AM +0000, Rantala, Tommi T. (Nokia - FI/Espoo) wrote:
> On Tue, 2020-01-28 at 15:08 +0100, Greg Kroah-Hartman wrote:
> > From: Al Viro <viro@zeniv.linux.org.uk>
> >
> > commit d0cb50185ae942b03c4327be322055d622dc79f6 upstream.
> >
> > may_create_in_sticky() call is done when we already have dropped the
> > reference to dir.
> >
> > Fixes: 30aba6656f61e (namei: allow restricted O_CREAT of FIFOs and
> > regular files)
> > Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> >
> > ---
> > fs/namei.c | 17 ++++++++++-------
> > 1 file changed, 10 insertions(+), 7 deletions(-)
> >
> > --- a/fs/namei.c
> > +++ b/fs/namei.c
> > [...]
> > @@ -3258,6 +3259,8 @@ static int do_last(struct nameidata *nd,
> > struct file *file, const struct open_flags *op)
> > {
> > struct dentry *dir = nd->path.dentry;
> > + kuid_t dir_uid = dir->d_inode->i_uid;
>
> I hit the following oops in 4.19.100 while running kselftests.
>
> fs/namei.c:3262 matches the line above.
>
> Any ideas?

Yes. Make those two line
kuid_t dir_uid = nd->inode->i_uid;
umode_t dir_mode = nd->inode->i_mode;

I'm pretty sure that I know which way I'd fucked up there; we can
get here in RCU mode with stale nd->path.dentry (that would make
the thing fail with -ECHILD. with retry in non-RCU mode). In
non-stale case nd->inode is the same as nd->path.dentry->d_inode
and it's always pointing to a struct inode that hadn't been
freed yet.

\
 
 \ /
  Last update: 2020-01-31 13:21    [W:0.069 / U:1.532 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site