[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251118091818.152ba4fc0c8a6f3092a36fbc@linux-foundation.org>
Date: Tue, 18 Nov 2025 09:18:18 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: "Yury Norov (NVIDIA)" <yury.norov@...il.com>, Miguel Ojeda
<ojeda@...nel.org>, Boqun Feng <boqun.feng@...il.com>, Danilo Krummrich
<dakr@...nel.org>, Arnd Bergmann <arnd@...db.de>, Alex Gaynor
<alex.gaynor@...il.com>, Gary Guo <gary@...yguo.net>, John Hubbard
<jhubbard@...dia.com>, "Björn Roy Baron"
<bjorn3_gh@...tonmail.com>, Benno Lossin <lossin@...nel.org>, Andreas
Hindborg <a.hindborg@...nel.org>, Trevor Gross <tmgross@...ch.edu>,
linux-kernel@...r.kernel.org, rust-for-linux@...r.kernel.org
Subject: Re: [PATCH v2] uaccess: decouple INLINE_COPY_FROM_USER and
CONFIG_RUST
On Tue, 18 Nov 2025 10:39:56 +0000 Alice Ryhl <aliceryhl@...gle.com> wrote:
> On Fri, Oct 24, 2025 at 11:47:53AM -0400, Yury Norov (NVIDIA) wrote:
> > Commit 1f9a8286bc0c ("uaccess: always export _copy_[from|to]_user with
> > CONFIG_RUST") exports _copy_{from,to}_user() unconditionally, if RUST
> > is enabled. This pollutes exported symbols namespace, and spreads RUST
> > ifdefery in core files.
> >
> > It's better to declare a corresponding helper under the rust/helpers,
> > similarly to how non-underscored copy_{from,to}_user() is handled.
> >
> > Reviewed-by: Alice Ryhl <aliceryhl@...gle.com>
> > Tested-by: Alice Ryhl <aliceryhl@...gle.com>
> > Signed-off-by: Yury Norov (NVIDIA) <yury.norov@...il.com>
>
> It looks like this is not quite correct. The header file still has this
> declaration unconditionally:
>
> extern __must_check unsigned long
> _copy_from_user(void *, const void __user *, unsigned long);
>
> extern __must_check unsigned long
> _copy_to_user(void __user *, const void *, unsigned long);
>
> this causes:
>
> ERROR: modpost: "_copy_from_user" [samples/rust/rust_misc_device.ko] undefined!
> ERROR: modpost: "_copy_to_user" [samples/rust/rust_misc_device.ko] undefined!
I wonder why this wasn't caught in linux-next testing.
Please check the rust Kconfig defaults, see if there's something we can
do to get more compilation test coverage?
> This is because when Rust sees both a helper and a non-helper of the
> same function, it prefers to call the non-helper version. In this case,
> it saw a declaration of the function in the header file, and so it tried
> to call that instead of the helper.
>
> To fix this, we need to wrap the above declarations in:
>
> #ifndef INLINE_COPY_FROM_USER
It's in mainline now - do you have time to send along a patch?
Powered by blists - more mailing lists