Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1592612

Re: fs: use-after-free in path_lookupat

From Al Viro <viro@ZenIV.linux.org.uk>
Newsgroups linux.kernel
Subject Re: fs: use-after-free in path_lookupat
Date 2017-03-04 20:40 +0100
Message-ID <thnH3-5wv-3@gated-at.bofh.it> (permalink)
References <thjtM-2xJ-27@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat, Mar 04, 2017 at 03:59:36PM +0100, Dmitry Vyukov wrote:

> I am getting the following use-after-free reports while running
> syzkaller fuzzer on 86292b33d4b79ee03e2f43ea0381ef85f077c760 (but also
> happened on 6dc39c50e4aeb769c8ae06edf2b1a732f3490913 and
> c82be9d2244aacea9851c86f4fb74694c99cd874).

IOW, it's not fs/namei.c patches from this window...

>  unlazy_walk+0xf2/0x4b0 fs/namei.c:692

Could you post disassembly (e.g. from objdump -d) of your unlazy_walk()?
For the kernel the trace is from...

> r4 = memfd_create(&(0x7f0000013000)="2f6465762f6877726e6700", 0x0)
> name_to_handle_at(r4, &(0x7f0000003000-0x6)="2e2f62757300",
> &(0x7f0000003000-0xd)={0xc, 0x0, "cd21"}, &(0x7f0000002000)=0x0,
> 0x1000)
> 
> What's strange is that dirfd passed to name_to_handle_at is memfd
> handle (sic). And path lookup somehow does not fail early on this.
> Does it make any sense?

It doesn't, but is that the triggering call of name_to_handle_at(), or do you
have it called elsewhere?

FWIW, no LOOKUP_ROOT in filename_lookup() flags + NULL root + dfd not
equal to AT_FDCWD + non-empty name should've ended up in
                        if (!d_can_lookup(dentry)) {
                                fdput(f);
                                return ERR_PTR(-ENOTDIR);
			}
in path_init() and it shouldn't have progressed any further.  And in case
of name_to_handle_at() we have user_path_at(dfd, name, lookup_flags, &path),
i.e. user_path_at_empty(dfd, name, lookup_flags, &path, NULL), i.e.
filename_lookup(dfd, getname_flags(name, lookup_flags, NULL), lookup_flags,
&path, NULL).  IOW, filename_lookup() is called with root equal to NULL,
dfd and name coming straight from userland and lookup_flags containing
nothing beyond LOOKUP_EMPTY and LOOKUP_FOLLOW...

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

fs: use-after-free in path_lookupat Dmitry Vyukov <dvyukov@google.com> - 2017-03-04 16:10 +0100
  Re: fs: use-after-free in path_lookupat Al Viro <viro@ZenIV.linux.org.uk> - 2017-03-04 20:40 +0100
    Re: fs: use-after-free in path_lookupat Dmitry Vyukov <dvyukov@google.com> - 2017-03-05 12:20 +0100
      Re: fs: use-after-free in path_lookupat Dmitry Vyukov <dvyukov@google.com> - 2017-03-05 12:30 +0100
        Re: fs: use-after-free in path_lookupat Dmitry Vyukov <dvyukov@google.com> - 2017-03-05 12:50 +0100
          Re: fs: use-after-free in path_lookupat Dmitry Vyukov <dvyukov@google.com> - 2017-03-05 17:20 +0100
            Re: fs: use-after-free in path_lookupat Al Viro <viro@ZenIV.linux.org.uk> - 2017-03-05 17:40 +0100
              Re: fs: use-after-free in path_lookupat Dmitry Vyukov <dvyukov@google.com> - 2017-03-05 18:40 +0100
                Re: fs: use-after-free in path_lookupat Dmitry Vyukov <dvyukov@google.com> - 2017-03-05 18:50 +0100
                Re: fs: use-after-free in path_lookupat Al Viro <viro@ZenIV.linux.org.uk> - 2017-03-05 21:10 +0100
                Re: fs: use-after-free in path_lookupat Dmitry Vyukov <dvyukov@google.com> - 2017-03-06 10:50 +0100
          Re: fs: use-after-free in path_lookupat Al Viro <viro@ZenIV.linux.org.uk> - 2017-03-05 19:10 +0100
      Re: fs: use-after-free in path_lookupat Dmitry Vyukov <dvyukov@google.com> - 2017-03-05 12:30 +0100

csiph-web