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]
Message-ID: <CAMuHMdWbcSUyYo1sJ81qojmbB_g595dVnzQycZq0Yh5BdQYCEg@mail.gmail.com>
Date:   Tue, 4 Jun 2019 14:04:03 +0200
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     Baruch Siach <baruch@...s.co.il>
Cc:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        netdev <netdev@...r.kernel.org>, bpf@...r.kernel.org,
        "Dmitry V . Levin" <ldv@...linux.org>,
        Jiri Olsa <jolsa@...nel.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH] bpf: fix uapi bpf_prog_info fields alignment

Hi Baruch,

On Tue, Jun 4, 2019 at 1:40 PM Baruch Siach <baruch@...s.co.il> wrote:
> Merge commit 1c8c5a9d38f60 ("Merge
> git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next") undid the
> fix from commit 36f9814a494 ("bpf: fix uapi hole for 32 bit compat
> applications") by taking the gpl_compatible 1-bit field definition from
> commit b85fab0e67b162 ("bpf: Add gpl_compatible flag to struct
> bpf_prog_info") as is. That breaks architectures with 16-bit alignment
> like m68k. Widen gpl_compatible to 32-bit to restore alignment of the
> following fields.
>
> Thanks to Dmitry V. Levin his analysis of this bug history.
>
> Cc: Jiri Olsa <jolsa@...nel.org>
> Cc: Daniel Borkmann <daniel@...earbox.net>
> Cc: Geert Uytterhoeven <geert@...ux-m68k.org>
> Cc: Linus Torvalds <torvalds@...ux-foundation.org>
> Signed-off-by: Baruch Siach <baruch@...s.co.il>

Thanks for your patch!

> --- a/include/uapi/linux/bpf.h
> +++ b/include/uapi/linux/bpf.h
> @@ -3140,7 +3140,7 @@ struct bpf_prog_info {
>         __aligned_u64 map_ids;
>         char name[BPF_OBJ_NAME_LEN];
>         __u32 ifindex;
> -       __u32 gpl_compatible:1;
> +       __u32 gpl_compatible;
>         __u64 netns_dev;
>         __u64 netns_ino;

Wouldn't it be better to change the types of the fields that require
8-byte alignment from __u64 to __aligned_u64, like is already used
for the map_ids fields?

Without that, some day people will need to add a new flag, and will
convert the 32-bit flag to a bitfield again to make space, reintroducing
the issue.

>         __u32 nr_jited_ksyms;
> diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
> index 63e0cf66f01a..fe73829b5b1c 100644
> --- a/tools/include/uapi/linux/bpf.h
> +++ b/tools/include/uapi/linux/bpf.h
> @@ -3140,7 +3140,7 @@ struct bpf_prog_info {
>         __aligned_u64 map_ids;
>         char name[BPF_OBJ_NAME_LEN];
>         __u32 ifindex;
> -       __u32 gpl_compatible:1;
> +       __u32 gpl_compatible;
>         __u64 netns_dev;
>         __u64 netns_ino;

Same here.

>         __u32 nr_jited_ksyms;
> --
> 2.20.1
>


-- 
Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ