lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 23 Mar 2024 19:55:10 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Andrei Matei <andreimatei1@...il.com>
Cc: Edward Adam Davis <eadavis@...com>, Andrii Nakryiko <andrii@...nel.org>, 
	Alexei Starovoitov <ast@...nel.org>, bpf <bpf@...r.kernel.org>, 
	Daniel Borkmann <daniel@...earbox.net>, Eddy Z <eddyz87@...il.com>, Hao Luo <haoluo@...gle.com>, 
	John Fastabend <john.fastabend@...il.com>, Jiri Olsa <jolsa@...nel.org>, 
	KP Singh <kpsingh@...nel.org>, LKML <linux-kernel@...r.kernel.org>, 
	Martin KaFai Lau <martin.lau@...ux.dev>, Network Development <netdev@...r.kernel.org>, 
	Stanislav Fomichev <sdf@...gle.com>, Song Liu <song@...nel.org>, 
	syzkaller-bugs <syzkaller-bugs@...glegroups.com>, Yonghong Song <yonghong.song@...ux.dev>
Subject: Re: stack access issue. Re: [syzbot] [bpf?] UBSAN:
 array-index-out-of-bounds in check_stack_range_initialized

On Sat, Mar 23, 2024 at 7:12 PM Andrei Matei <andreimatei1@...il.com> wrote:
>
> On Sat, Mar 23, 2024 at 8:52 PM Alexei Starovoitov
> <alexei.starovoitov@...il.com> wrote:
> >
> > On Sat, Mar 23, 2024 at 5:50 PM Andrei Matei <andreimatei1@...il.com> wrote:
> > >
> > > + Edward
> > >
> > > On Thu, Mar 21, 2024 at 3:33 AM Alexei Starovoitov
> > > <alexei.starovoitov@...il.com> wrote:
> > > >
> > > > Hi Andrei,
> > > >
> > > > looks like the refactoring of stack access introduced a bug.
> > > > See the reproducer below.
> > > > positive offsets are not caught by check_stack_access_within_bounds().
> > >
> > > check_stack_access_within_bounds() tries to catch positive offsets;
> > > It does: [1]
> > >
> > > err = check_stack_slot_within_bounds(env, min_off, state, type);
> > > if (!err && max_off > 0)
> > >   err = -EINVAL; /* out of stack access into non-negative offsets */
> > >
> > > Notice the max_off > 0 in there.
> > > And we have various tests that seem to check that positive offsets are
> > > rejected. Do you know what the bug is?
> > > I'm thinking maybe there's some overflow going on, except that UBSAN
> > > reported an index of -1 as being the problem.
> > >
> > > Edward, I see that you've been tickling the robot trying to narrow the issue;
> > > perhaps you've figured it out?
> > >
> > > If the bug is not immediately apparent to anyone, I would really appreciate a
> > > bit of tutoring around how to reproduce and get verifier logs.
> >
> > The repro is right there in the email I forwarded:
> >
> > > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=15c38711180000
>
> I understand, but how does one go from this to either BPF assembly,
> or to running it in such a way that you also get verifier logs?

Adding logs to repro.c is too hard, but you can
hack the kernel with printk-s.

Like the following:

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index de7813947981..d158b83ed16c 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -7179,6 +7179,7 @@ static int check_stack_range_initialized(
                        return -EFAULT;
                }

+               printk("slot %d %d spi %d\n", slot, slot % BPF_REG_SIZE, spi);
                stype = &state->stack[spi].slot_type[slot % BPF_REG_SIZE];


shows that spi and slot get negative: -1, -2, ...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ