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] [day] [month] [year] [list]
Message-ID: <E8CE1CDC-27F2-4F14-9AFF-3AE409B82F6C@kernel.org>
Date:   Sat, 11 Feb 2023 09:55:09 -0800
From:   Kees Cook <kees@...nel.org>
To:     Alexei Starovoitov <alexei.starovoitov@...il.com>,
        Kees Cook <keescook@...omium.org>
CC:     Andrii Nakryiko <andrii.nakryiko@...il.com>,
        Alexei Starovoitov <ast@...nel.org>,
        Stanislav Fomichev <sdf@...gle.com>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Martin KaFai Lau <martin.lau@...ux.dev>,
        Song Liu <song@...nel.org>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>, Hao Luo <haoluo@...gle.com>,
        Jiri Olsa <jolsa@...nel.org>, Mykola Lysenko <mykolal@...com>,
        Shuah Khan <shuah@...nel.org>,
        Haowen Bai <baihaowen@...zu.com>, bpf <bpf@...r.kernel.org>,
        "open list:KERNEL SELFTEST FRAMEWORK" 
        <linux-kselftest@...r.kernel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Jesper Dangaard Brouer <hawk@...nel.org>,
        Nathan Chancellor <nathan@...nel.org>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Tom Rix <trix@...hat.com>, LKML <linux-kernel@...r.kernel.org>,
        Network Development <netdev@...r.kernel.org>,
        clang-built-linux <llvm@...ts.linux.dev>,
        linux-hardening@...r.kernel.org
Subject: Re: [PATCH] bpf: Deprecate "data" member of bpf_lpm_trie_key

On February 9, 2023 2:01:15 PM PST, Alexei Starovoitov <alexei.starovoitov@...il.com> wrote:
>On Thu, Feb 9, 2023 at 1:12 PM Kees Cook <keescook@...omium.org> wrote:
>>
>> On Thu, Feb 09, 2023 at 12:50:28PM -0800, Alexei Starovoitov wrote:
>> > On Thu, Feb 9, 2023 at 12:05 PM Kees Cook <keescook@...omium.org> wrote:
>> > >
>> > > On Thu, Feb 09, 2023 at 11:52:10AM -0800, Andrii Nakryiko wrote:
>> > > > Do we need to add a new type to UAPI at all here? We can make this new
>> > > > struct internal to kernel code (e.g. struct bpf_lpm_trie_key_kern) and
>> > > > point out that it should match the layout of struct bpf_lpm_trie_key.
>> > > > User-space can decide whether to use bpf_lpm_trie_key as-is, or if
>> > > > just to ensure their custom struct has the same layout (I see some
>> > > > internal users at Meta do just this, just make sure that they have
>> > > > __u32 prefixlen as first member).
>> > >
>> > > The uses outside the kernel seemed numerous enough to justify a new UAPI
>> > > struct (samples, selftests, etc). It also paves a single way forward
>> > > when the userspace projects start using modern compiler options (e.g.
>> > > systemd is usually pretty quick to adopt new features).
>> >
>> > I don't understand how the new uapi struct bpf_lpm_trie_key_u8 helps.
>> > cilium progs and progs/map_ptr_kern.c
>> > cannot do s/bpf_lpm_trie_key/bpf_lpm_trie_key_u8/.
>> > They will fail to build, so they're stuck with bpf_lpm_trie_key.
>>
>> Right -- I'm proposing not changing bpf_lpm_trie_key. I'm proposing
>> _adding_ bpf_lpm_trie_key_u8 for new users who will be using modern
>> compiler options (i.e. where "data[0]" is nonsense).
>>
>> > Can we do just
>> > struct bpf_lpm_trie_key_kern {
>> >   __u32   prefixlen;
>> >   __u8    data[];
>> > };
>> > and use it in the kernel?
>>
>> Yeah, I can do that if that's preferred, but it leaves userspace hanging
>> when they eventually trip over this in their code when they enable
>> -fstrict-flex-arrays=3 too.
>>
>> > What is the disadvantage?
>>
>> It seemed better to give a working example of how to migrate this code.
>
>I understand and agree with intent, but I'm still missing
>how you're going to achieve this migration.
>bpf_lpm_trie_key_u8 doesn't provide a migration path to cilium progs
>and pretty much all bpf progs that use LPM map.
>Sure, one can change the user space part, like you did in test_lpm_map.c,
>but it doesn't address the full scope.
>imo half way is worse than not doing it.

Maybe I'm missing something, but if a program isn't building with -fstrict-flex-arrays=3, it can keep on using struct bpf_lpm_trie_key as before. If/when it starts using -fsfa, if can use struct bpf_lpm_trie_key in composite structs as a header just like before, but if it has places using the "data" member as an array of u8, it can switch to something using struct bpf_lpm_trie_key_u8, either directly or as a union with whatever ever struct they have. (And this replacement is what I did for all the samples/selftests.)



-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ