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: <DG7X1LYSZ1IC.2Q4CYXM97A62A@kernel.org>
Date: Fri, 06 Feb 2026 14:33:47 +0100
From: "Danilo Krummrich" <dakr@...nel.org>
To: "Greg KH" <gregkh@...uxfoundation.org>, "Alice Ryhl"
 <aliceryhl@...gle.com>
Cc: <rafael@...nel.org>, <ojeda@...nel.org>, <boqun.feng@...il.com>,
 <gary@...yguo.net>, <bjorn3_gh@...tonmail.com>, <lossin@...nel.org>,
 <a.hindborg@...nel.org>, <tmgross@...ch.edu>,
 <driver-core@...ts.linux.dev>, <rust-for-linux@...r.kernel.org>,
 <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/5] devres: export devres_node_init() and
 devres_node_add()

On Fri Feb 6, 2026 at 2:25 PM CET, Greg KH wrote:
> On Fri, Feb 06, 2026 at 02:20:06PM +0100, Alice Ryhl wrote:
>> On Fri, Feb 6, 2026 at 2:16 PM Danilo Krummrich <dakr@...nel.org> wrote:
>> >
>> > On Fri Feb 6, 2026 at 1:34 PM CET, Greg KH wrote:
>> > > That's fine, because the rust driver core code should also be built into
>> > > the kernel, not as a module, right?
>> >
>> > Yes, but the Rust compiler may still choose to put some of the core code into
>> > the module.
>> >
>> > Especially with generic types and functions the Rust compiler may move some the
>> > generated code for a certain type instance into the module that instanciates the
>> > type.
>> >
>> > For instance, even though rust/kernel/devres.rs is *always* built-in, we get the
>> > following error when devres_node_init() is not exported when the users of this
>> > built-in code are built as module.
>> >
>> >         ERROR: modpost: "devres_node_init" [drivers/pwm/pwm_th1520.ko] undefined!
>> >         ERROR: modpost: "devres_node_init" [drivers/gpu/drm/tyr/tyr.ko] undefined!
>> >         ERROR: modpost: "devres_node_init" [drivers/gpu/nova-core/nova_core.ko] undefined!
>> >         ERROR: modpost: "devres_node_init" [samples/rust/rust_dma.ko] undefined!
>> >         ERROR: modpost: "devres_node_init" [samples/rust/rust_driver_pci.ko] undefined!
>> >         ERROR: modpost: "devres_node_init" [samples/rust/rust_driver_auxiliary.ko] undefined!
>> >         make[2]: *** [scripts/Makefile.modpost:147: Module.symvers] Error 1
>> >
>> > However, sprinkling "raw" EXPORT_SYMBOL_GPL() due to that is not great at all.
>> > Hence, we could do something like in [1] instead. I don't know if there are
>> > other options that may be better though.
>> >
>> > [1] https://lore.kernel.org/all/DG7UR3WWZB4V.2MYMJJH1VDHH@kernel.org/
>> 
>> You can use #[inline(never)] to prevent this.
>
> Ah, good!

I tried this before, but it doesn't work. It might prevent inlining, but it does
not prevent the compiler to move the function into the module binary.

For instance, even with #[inline(never)] on Devres::new() I see this:

	$ objdump -t drivers/pwm/pwm_th1520.o | grep " F " | grep Devres | grep new

	0000000000000000 g     F .text  00000000000001d0 _RINvMNtCsgzhNYVB7wSz_6kernel6devresINtB3_6DevresINtNtNtB5_2io3mem5IoMemKjb0_EE3newNtNtB5_5error5ErrorINtNtCs4gKlGRWyJ5S_4core6result6ResultBK_B1i_EECsjBm7MKWXKwW_10pwm_th1520

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ