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] [day] [month] [year] [list]
Message-ID: <CAADnVQKh7GYfbvZ1vyY93DcpyKzoUHozmYTV360_0LFrNYUiog@mail.gmail.com>
Date:   Fri, 19 May 2023 11:03:05 -0700
From:   Alexei Starovoitov <alexei.starovoitov@...il.com>
To:     Will Deacon <will@...nel.org>
Cc:     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>,
        Andrey Ignatov <rdna@...com>, Yonghong Song <yhs@...com>
Subject: Re: [PATCH v2] bpf: Fix mask generation for 32-bit narrow loads of
 64-bit fields

On Thu, May 18, 2023 at 3:25 AM Will Deacon <will@...nel.org> 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. For example:
>
> 0:      61 10 00 00 00 00 00 00 r0 = *(u32 *)(r1 + 0)
>
> results in the following code generation for a 64-bit field:
>
>         ldr     x7, [x7]        // 64-bit load
>         mov     x10, #0xffffffffffffffff
>         and     x7, x7, x10
>
> Fix the mask generation so that narrow loads always perform a 32-bit AND
> operation:
>
>         ldr     x7, [x7]        // 64-bit load
>         mov     w10, #0xffffffff
>         and     w7, w7, w10
>
> 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: Andrey Ignatov <rdna@...com>
> Acked-by: Yonghong Song <yhs@...com>
> Fixes: 31fd85816dbe ("bpf: permits narrower load from bpf program context fields")
> Signed-off-by: Will Deacon <will@...nel.org>

Thanks for the fix! Applied to bpf tree.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ