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: <20240725174449.102724-1-ojeda@kernel.org>
Date: Thu, 25 Jul 2024 19:44:49 +0200
From: Miguel Ojeda <ojeda@...nel.org>
To: gary@...yguo.net
Cc: a.hindborg@...sung.com,
	alex.gaynor@...il.com,
	aliceryhl@...gle.com,
	benno.lossin@...ton.me,
	bjorn3_gh@...tonmail.com,
	boqun.feng@...il.com,
	bp@...en8.de,
	dave.hansen@...ux.intel.com,
	hpa@...or.com,
	jpoimboe@...nel.org,
	linux-kernel@...r.kernel.org,
	masahiroy@...nel.org,
	mingo@...hat.com,
	nathan@...nel.org,
	nicolas@...sle.eu,
	ojeda@...nel.org,
	patches@...ts.linux.dev,
	peterz@...radead.org,
	rust-for-linux@...r.kernel.org,
	tglx@...utronix.de,
	wedsonaf@...il.com,
	x86@...nel.org
Subject: Re: Re: [PATCH v2 1/6] rust: module: add static pointer to `{init,cleanup}_module()`

On Wed, 24 Jul 2024 20:46:49 +0100 Gary Guo <gary@...yguo.net> wrote:
>
> On Wed, 24 Jul 2024 18:14:54 +0200
> Miguel Ojeda <ojeda@...nel.org> wrote:
>
> > Add the equivalent of the `___ADDRESSABLE()` annotation in the
> > `module_{init,exit}` macros to the Rust `module!` macro.
> >
> > Without this, `objtool` would complain if enabled for Rust, e.g.:
> >
> >     samples/rust/rust_print.o: warning: objtool: cleanup_module(): not an indirect call target
> >     samples/rust/rust_print.o: warning: objtool: init_module(): not an indirect call target
> >
> > Signed-off-by: Miguel Ojeda <ojeda@...nel.org>
> > ---
> >  rust/macros/module.rs | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> >
> > diff --git a/rust/macros/module.rs b/rust/macros/module.rs
> > index 411dc103d82e..571ffa2e189c 100644
> > --- a/rust/macros/module.rs
> > +++ b/rust/macros/module.rs
> > @@ -256,6 +256,12 @@ mod __module_init {{
> >                          unsafe {{ __init() }}
> >                      }}
> >
> > +                    #[cfg(MODULE)]
> > +                    #[doc(hidden)]
> > +                    #[used]
> > +                    #[link_section = \".init.data\"]
>
> Should this be in section `.discard.addressable` instead?
>
> > +                    static __UNIQUE_ID___addressable_init_module: unsafe extern \"C\" fn() -> i32 = init_module;
> > +
> >                      #[cfg(MODULE)]
> >                      #[doc(hidden)]
> >                      #[no_mangle]
> > @@ -269,6 +275,12 @@ mod __module_init {{
> >                          unsafe {{ __exit() }}
> >                      }}
> >
> > +                    #[cfg(MODULE)]
> > +                    #[doc(hidden)]
> > +                    #[used]
> > +                    #[link_section = \".exit.data\"]
> > +                    static __UNIQUE_ID___addressable_cleanup_module: extern \"C\" fn() = cleanup_module;
> > +
> >                      // Built-in modules are initialized through an initcall pointer
> >                      // and the identifiers need to be unique.
> >                      #[cfg(not(MODULE))]

Boot-tested under QEMU for Rust:

Tested-by: Miguel Ojeda <ojeda@...nel.org>

Thanks!

Cheers,
Miguel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ