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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 5 May 2023 08:30:40 -0700
From:   Alexei Starovoitov <alexei.starovoitov@...il.com>
To:     Yonghong Song <yhs@...a.com>
Cc:     Will Deacon <will@...nel.org>, bpf <bpf@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Network Development <netdev@...r.kernel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        John Fastabend <john.fastabend@...il.com>,
        Krzesimir Nowak <krzesimir@...volk.io>,
        Yonghong Song <yhs@...com>, Andrey Ignatov <rdna@...com>
Subject: Re: [PATCH] bpf: Fix mask generation for 32-bit narrow loads of
 64-bit fields

On Thu, May 4, 2023 at 1:18 PM Yonghong Song <yhs@...a.com> wrote:
>
>
>
> On 5/2/23 9:57 AM, Will Deacon wrote:
> > A narrow load from a 64-bit context field results in a 64-bit load
> > followed potentially by a 64-bit right-shift and then a bitwise AND
> > operation to extract the relevant data.
> >
> > In the case of a 32-bit access, an immediate mask of 0xffffffff is used
> > to construct a 64-bit BPP_AND operation which then sign-extends the mask
> > value and effectively acts as a glorified no-op.
> >
> > Fix the mask generation so that narrow loads always perform a 32-bit AND
> > operation.
> >
> > Cc: Alexei Starovoitov <ast@...nel.org>
> > Cc: Daniel Borkmann <daniel@...earbox.net>
> > Cc: John Fastabend <john.fastabend@...il.com>
> > Cc: Krzesimir Nowak <krzesimir@...volk.io>
> > Cc: Yonghong Song <yhs@...com>
> > Cc: Andrey Ignatov <rdna@...com>
> > Fixes: 31fd85816dbe ("bpf: permits narrower load from bpf program context fields")
> > Signed-off-by: Will Deacon <will@...nel.org>
>
>
> Thanks for the fix! You didn't miss anything. It is a bug and we did not
> find it probably because user always use 'u64 val = ctx->u64_field' in
> their bpf code...
>
> But I think the commit message can be improved. An example to show the
> difference without and with this patch can explain the issue much better.
>
> Acked-by: Yonghong Song <yhs@...com>

If I'm reading it correctly it's indeed a bug.
alu64(and, 0xffffFFFF) is a nop
but it should have been
alu32(and, 0xffffFFFF) which will clear upper 32-bit, right?
Would be good to have a selftest for this.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ