From: Dmitry Vyukov <dvyukov@google.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: Ondrej Mosnacek <omosnace@redhat.com>,
syzbot <syzbot+f07cc9be8d1d226947ed@syzkaller.appspotmail.com>,
Andrii Nakryiko <andriin@fb.com>,
Alexei Starovoitov <ast@kernel.org>, bpf <bpf@vger.kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
James Morris <jmorris@namei.org>,
John Fastabend <john.fastabend@gmail.com>,
Martin KaFai Lau <kafai@fb.com>, KP Singh <kpsingh@chromium.org>,
Linux kernel mailing list <linux-kernel@vger.kernel.org>,
Linux Security Module list
<linux-security-module@vger.kernel.org>,
network dev <netdev@vger.kernel.org>,
"Serge E. Hallyn" <serge@hallyn.com>,
Song Liu <songliubraving@fb.com>,
syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
Yonghong Song <yhs@fb.com>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
overlayfs <linux-unionfs@vger.kernel.org>
Subject: Re: general protection fault in security_inode_getattr
Date: Fri, 30 Oct 2020 20:56:14 +0100 [thread overview]
Message-ID: <CACT4Y+a2aSoEZpytAGKnx77a012z0yzOSu6P2rKQpoBYFBzBDg@mail.gmail.com> (raw)
In-Reply-To: <CAJfpegsAabASuHYtoi_DoooV1vM7Evfrd8ESZDDTx2oXHiR6cw@mail.gmail.com>
On Fri, Oct 30, 2020 at 8:21 PM Miklos Szeredi <miklos@szeredi.hu> wrote:
> > > On Mon, Aug 24, 2020 at 11:00 PM Ondrej Mosnacek <omosnace@redhat.com> wrote:
> > > >
> > > > On Mon, Aug 24, 2020 at 9:37 PM syzbot
> > > > <syzbot+f07cc9be8d1d226947ed@syzkaller.appspotmail.com> wrote:
> > > > > syzbot has found a reproducer for the following issue on:
> > > >
> > > > Looping in fsdevel and OverlayFS maintainers, as this seems to be
> > > > FS/OverlayFS related...
> > >
> > > Hmm, the oopsing code is always something like:
> > >
> > > All code
> > > ========
> > > 0: 1b fe sbb %esi,%edi
> > > 2: 49 8d 5e 08 lea 0x8(%r14),%rbx
> > > 6: 48 89 d8 mov %rbx,%rax
> > > 9: 48 c1 e8 03 shr $0x3,%rax
> > > d: 42 80 3c 38 00 cmpb $0x0,(%rax,%r15,1)
> > > 12: 74 08 je 0x1c
> > > 14: 48 89 df mov %rbx,%rdi
> > > 17: e8 bc b4 5b fe callq 0xfffffffffe5bb4d8
> > > 1c: 48 8b 1b mov (%rbx),%rbx
> > > 1f: 48 83 c3 68 add $0x68,%rbx
> > > 23: 48 89 d8 mov %rbx,%rax
> > > 26: 48 c1 e8 03 shr $0x3,%rax
> > > 2a:* 42 80 3c 38 00 cmpb $0x0,(%rax,%r15,1) <-- trapping instruction
> > > 2f: 74 08 je 0x39
> > > 31: 48 89 df mov %rbx,%rdi
> > > 34: e8 9f b4 5b fe callq 0xfffffffffe5bb4d8
> > > 39: 48 8b 1b mov (%rbx),%rbx
> > > 3c: 48 83 c3 0c add $0xc,%rbx
> > >
> > >
> > > And that looks (to me) like the unrolled loop in call_int_hook(). I
> > > don't see how that could be related to overlayfs, though it's
> > > definitely interesting why it only triggers from
> > > overlay->vfs_getattr()->security_inode_getattr()...
> >
> >
> > > 26: 48 c1 e8 03 shr $0x3,%rax
> > > 2a:* 42 80 3c 38 00 cmpb $0x0,(%rax,%r15,1) <-- trapping instruction
> >
> >
> > This access is part of KASAN check. But the original address kernel
> > tries to access is NULL, so it's not an issue with KASAN.
> >
> > The line is this:
> >
> > int security_inode_getattr(const struct path *path)
> > {
> > if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
> > return 0;
> >
> > So it's either path is NULL, or something in d_backing_inode
> > dereferences NULL path->dentry.
> >
> > The reproducer does involve overlayfs:
> >
> > mkdir(&(0x7f0000000240)='./file1\x00', 0x0)
> > mkdir(&(0x7f0000000300)='./bus\x00', 0x0)
> > r0 = creat(&(0x7f00000000c0)='./bus/file1\x00', 0x0)
> > mkdir(&(0x7f0000000080)='./file0\x00', 0x0)
> > mount$overlay(0x400002, &(0x7f0000000000)='./bus\x00',
> > &(0x7f0000000100)='overlay\x00', 0x0,
> > &(0x7f00000003c0)=ANY=[@ANYBLOB='upperdir=./file1,lowerdir=./bus,workdir=./file0,metacopy=on'])
> > link(&(0x7f0000000200)='./bus/file1\x00', &(0x7f00000002c0)='./bus/file0\x00')
> > write$RDMA_USER_CM_CMD_RESOLVE_ADDR(r0, 0x0, 0x0)
> > acct(&(0x7f0000000040)='./bus/file0\x00')
> >
> > Though, it may be overlayfs-related, or it may be a generic bug that
> > requires a tricky reproducer and the only reproducer syzbot come up
> > with happened to involve overlayfs.
> > But there are 4 reproducers on syzbot dashboard and all of them
> > involve overlayfs and they are somewhat different. So my bet would be
> > on overlayfs.
>
> Seems there's no C reproducer, though. Can this be reproduced
> without KASAN obfuscating the oops?
I guess so.
If you are interest in what exact field is NULL, I think there is
enough info in the asm already:
> > > 2: 49 8d 5e 08 lea 0x8(%r14),%rbx
> > > 6: 48 89 d8 mov %rbx,%rax
> > > 9: 48 c1 e8 03 shr $0x3,%rax
> > > d: 42 80 3c 38 00 cmpb $0x0,(%rax,%r15,1)
> > > 12: 74 08 je 0x1c
> > > 14: 48 89 df mov %rbx,%rdi
> > > 17: e8 bc b4 5b fe callq 0xfffffffffe5bb4d8
> > > 1c: 48 8b 1b mov (%rbx),%rbx
> > > 1f: 48 83 c3 68 add $0x68,%rbx
> > > 23: 48 89 d8 mov %rbx,%rax
> > > 26: 48 c1 e8 03 shr $0x3,%rax
> > > 2a:* 42 80 3c 38 00 cmpb $0x0,(%rax,%r15,1) <-- trapping instruction
The access via the NULL pointer happens with offset 0x68:
> > > 1f: 48 83 c3 68 add $0x68,%rbx
So we just need to find what's here accesses with offset 0x68:
> > if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
And that pointer itself was loaded from something at offset 0x8 previously:
> > > 2: 49 8d 5e 08 lea 0x8(%r14),%rbx
next prev parent reply other threads:[~2020-10-30 19:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <0000000000008caae305ab9a5318@google.com>
[not found] ` <000000000000a726a405ada4b6cf@google.com>
2020-08-24 21:00 ` general protection fault in security_inode_getattr Ondrej Mosnacek
2020-10-30 13:02 ` Miklos Szeredi
2020-10-30 18:42 ` Dmitry Vyukov
2020-10-30 19:21 ` Miklos Szeredi
2020-10-30 19:56 ` Dmitry Vyukov [this message]
2020-08-25 0:32 ` syzbot
2020-08-25 0:48 ` Yonghong Song
2022-10-15 17:24 ` [syzbot] " syzbot
2022-10-16 14:52 ` Paul Moore
2022-10-17 14:29 ` Tetsuo Handa
2022-10-17 5:38 ` Yonghong Song
2024-04-01 17:36 ` Andrey Kalachev
2024-04-02 16:01 ` Amir Goldstein
2024-04-19 20:01 ` Andrey Kalachev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACT4Y+a2aSoEZpytAGKnx77a012z0yzOSu6P2rKQpoBYFBzBDg@mail.gmail.com \
--to=dvyukov@google.com \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jmorris@namei.org \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=netdev@vger.kernel.org \
--cc=omosnace@redhat.com \
--cc=serge@hallyn.com \
--cc=songliubraving@fb.com \
--cc=syzbot+f07cc9be8d1d226947ed@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).