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: <CAMZ6RqL2eKd-uqP-2vnt99_0RRE-8x7hxwYy6x1b0Oqes-HGgA@mail.gmail.com>
Date:   Thu, 19 May 2022 01:15:04 +0900
From:   Vincent MAILHOL <mailhol.vincent@...adoo.fr>
To:     Nathan Chancellor <nathan@...nel.org>
Cc:     Marc Kleine-Budde <mkl@...gutronix.de>,
        kernel test robot <lkp@...el.com>, llvm@...ts.linux.dev,
        kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
        linux-can@...r.kernel.org
Subject: Re: [PATCH] can: mcp251xfd: silence clang's -Wunaligned-access warning

On Tue. 19 May 2022 at 01:08, Nathan Chancellor <nathan@...nel.org> wrote:
> Hi Vincent,
>
> On Wed, May 18, 2022 at 08:43:57PM +0900, Vincent Mailhol wrote:
> > clang emits a -Wunaligned-access warning on union
> > mcp251xfd_tx_ojb_load_buf.
> >
> > The reason is that field hw_tx_obj (not declared as packed) is being
> > packed right after a 16 bits field inside a packed struct:
> >
> > | union mcp251xfd_tx_obj_load_buf {
> > |     struct __packed {
> > |             struct mcp251xfd_buf_cmd cmd;
> > |               /* ^ 16 bits fields */
> > |             struct mcp251xfd_hw_tx_obj_raw hw_tx_obj;
> > |               /* ^ not declared as packed */
> > |     } nocrc;
> > |     struct __packed {
> > |             struct mcp251xfd_buf_cmd_crc cmd;
> > |             struct mcp251xfd_hw_tx_obj_raw hw_tx_obj;
> > |             __be16 crc;
> > |     } crc;
> > | } ____cacheline_aligned;
> >
> > Starting from LLVM 14, having an unpacked struct nested in a packed
> > struct triggers a warning. c.f. [1].
> >
> > This is a false positive because the field is always being accessed
> > with the relevant put_unaligned_*() function. Adding __packed to the
> > structure declaration silences the warning.
> >
> > [1] https://github.com/llvm/llvm-project/issues/55520
> >
> > Signed-off-by: Vincent Mailhol <mailhol.vincent@...adoo.fr>
> > ---
> > Actually, I do not have llvm 14 installed so I am not able to test
> > (this check was introduced in v14). But as explained in [1], adding
> > __packed should fix the warning.
>
> Thanks for the patch! This does resolve the warning (verified with LLVM
> 15).

Great, thanks for the check! Does this mean we can add you Tested-by
(I assume yes, c.f. below, if not the case, please raise your voice).

> > Because this is a false positive, I did not add a Fixes tag, nor a
> > Reported-by: kernel test robot.
>
> I think that the Reported-by tag should always be included but I agree
> that a Fixes tag is not necessary for this warning, as we currently have
> it under W=1, so it should not be visible under normal circumstances.

ACK.
Marc, can you directly add below tags to the patch:

Reported-by: kernel test robot <lkp@...el.com>
Tested-by: Nathan Chancellor <nathan@...nel.org>

Or do you want me to send a v2?


Yours sincerely,
Vincent Mailhol

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ