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]
Date:   Fri, 26 Mar 2021 09:06:02 +0100
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     anthony.l.nguyen@...el.com,
        Norbert Ciosek <norbertx.ciosek@...el.com>
Cc:     "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        netdev <netdev@...r.kernel.org>, sassmann@...hat.com,
        sridhar.samudrala@...el.com,
        Konrad Jankowski <konrad0.jankowski@...el.com>,
        Mateusz Palczewski <mateusz.palczewski@...el.com>
Subject: Re: [PATCH net 1/4] virtchnl: Fix layout of RSS structures

Hi Anthony, Norbert,

Thanks for your patch!

On Thu, Mar 25, 2021 at 11:29 PM Tony Nguyen <anthony.l.nguyen@...el.com> wrote:
> From: Norbert Ciosek <norbertx.ciosek@...el.com>
>
> Remove padding from RSS structures. Previous layout
> could lead to unwanted compiler optimizations
> in loops when iterating over key and lut arrays.

>From an earlier private conversation with Mateusz, I understand the real
explanation is that key[] and lut[] must be at the end of the
structures, because they are used as flexible array members?

> Fixes: 65ece6de0114 ("virtchnl: Add missing explicit padding to structures")
> Signed-off-by: Norbert Ciosek <norbertx.ciosek@...el.com>
> Tested-by: Konrad Jankowski <konrad0.jankowski@...el.com>
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@...el.com>

> --- a/include/linux/avf/virtchnl.h
> +++ b/include/linux/avf/virtchnl.h
> @@ -476,7 +476,6 @@ struct virtchnl_rss_key {
>         u16 vsi_id;
>         u16 key_len;
>         u8 key[1];         /* RSS hash key, packed bytes */
> -       u8 pad[1];
>  };
>
>  VIRTCHNL_CHECK_STRUCT_LEN(6, virtchnl_rss_key);
> @@ -485,7 +484,6 @@ struct virtchnl_rss_lut {
>         u16 vsi_id;
>         u16 lut_entries;
>         u8 lut[1];        /* RSS lookup table */
> -       u8 pad[1];
>  };

If you use a flexible array member, it should be declared without a size,
i.e.

    u8 key[];

Everything else is (trying to) fool the compiler, and leading to undefined
behavior, and people (re)adding explicit padding.



--
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