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: <f994bff3-6e0a-4d57-9c86-257c304f513c@gmail.com>
Date: Thu, 19 Sep 2024 18:58:52 +0200
From: Christian Schrefl <chrisi.schrefl@...il.com>
To: Gary Guo <gary@...yguo.net>, lkp@...el.com,
 Miguel Ojeda <ojeda@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>,
 Wedson Almeida Filho <wedsonaf@...il.com>, Boqun Feng
 <boqun.feng@...il.com>, Björn Roy Baron
 <bjorn3_gh@...tonmail.com>, Benno Lossin <benno.lossin@...ton.me>,
 Andreas Hindborg <a.hindborg@...sung.com>, Alice Ryhl
 <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>
Cc: conor.dooley@...rochip.com, linux-kernel@...r.kernel.org,
 llvm@...ts.linux.dev, oe-kbuild-all@...ts.linux.dev, palmer@...osinc.com,
 rust-for-linux@...r.kernel.org
Subject: Re: [PATCH] rust: fix `ARCH_SLAB_MINALIGN` multiple definition error

On 16.09.24 2:33 AM, Gary Guo wrote:
> We use const helpers in form of
> 
>     const size_t RUST_CONST_HELPER_ARCH_SLAB_MINALIGN = ARCH_SLAB_MINALIGN;
> 
> to aid generation of constants by bindgen because it is otherwise a
> macro definition of an expression and bindgen doesn't expand the
> constant. The helpers are then have `RUST_CONST_HELPER` prefix stripped
> and exposed to Rust code as if `ARCH_SLAB_MISALIGN` is generated
> natively by bindgen.
> 
> This works well for most constants, but on RISC-V, `ARCH_SLAB_MINALIGN`
> is defined directly as literal constant if `!CONFIG_MMU`, and bindgen
> would generate `ARCH_SLAB_MINALIGN` directly, thus conflict with the
> one generated through the helper.
> 
> To fix this, we simply need to block bindgen from generating directly
> without going through helper.
> 
> Reported-by: kernel test robot <lkp@...el.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202409160804.eSg9zh1e-lkp@intel.com/
> Signed-off-by: Gary Guo <gary@...yguo.net>
> ---
>  rust/bindgen_parameters | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/rust/bindgen_parameters b/rust/bindgen_parameters
> index a721d466bee4b..b7c7483123b7a 100644
> --- a/rust/bindgen_parameters
> +++ b/rust/bindgen_parameters
> @@ -24,3 +24,8 @@
>  # These functions use the `__preserve_most` calling convention, which neither bindgen
>  # nor Rust currently understand, and which Clang currently declares to be unstable.
>  --blocklist-function __list_.*_report
> +
> +# These constants are sometimes not recognized by bindgen depending on config.
> +# We use const helpers to aid bindgen, to avoid conflicts when constants are
> +# recognized, block generation of the non-helper constants.
> +--blocklist-item ARCH_SLAB_MINALIGN
> 
> base-commit: d077242d68a31075ef5f5da041bf8f6fc19aa231

This is also needed for 32-bit ARM support.

Reviewed-by: Christian Schrefl <chrisi.schrefl@...il.com>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ