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: <20240821162846.5f9ead69@eugeo>
Date: Wed, 21 Aug 2024 16:28:46 +0100
From: Gary Guo <gary@...yguo.net>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Miguel Ojeda <ojeda@...nel.org>, Josh Poimboeuf <jpoimboe@...nel.org>,
 Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
 Borislav Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>,
 Masahiro Yamada <masahiroy@...nel.org>, x86@...nel.org, "H. Peter Anvin"
 <hpa@...or.com>, Nathan Chancellor <nathan@...nel.org>, Nicolas Schier
 <nicolas@...sle.eu>, Wedson Almeida Filho <wedsonaf@...il.com>, Alex Gaynor
 <alex.gaynor@...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>, rust-for-linux@...r.kernel.org,
 linux-kernel@...r.kernel.org, patches@...ts.linux.dev
Subject: Re: [PATCH v2 5/6] objtool: list `noreturn` Rust functions

On Thu, 25 Jul 2024 10:33:55 +0200
Peter Zijlstra <peterz@...radead.org> wrote:

> On Wed, Jul 24, 2024 at 08:35:49PM +0100, Gary Guo wrote:
> > > @@ -202,10 +216,30 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
> > >  	if (!func)
> > >  		return false;
> > > 
> > > -	if (func->bind == STB_GLOBAL || func->bind == STB_WEAK)
> > > +	if (func->bind == STB_GLOBAL || func->bind == STB_WEAK) {
> > > +		/*
> > > +		 * Rust standard library functions.
> > > +		 *
> > > +		 * These are just heuristics -- we do not control the precise symbol
> > > +		 * name, due to the crate disambiguators (which depend on the compiler)
> > > +		 * as well as changes to the source code itself between versions.
> > > +		 */
> > > +		if (!strncmp(func->name, "_R", 2) &&
> > > +		    (str_ends_with(func->name, "_4core6option13unwrap_failed")			||
> > > +		     str_ends_with(func->name, "_4core6result13unwrap_failed")			||
> > > +		     str_ends_with(func->name, "_4core9panicking5panic")			||
> > > +		     str_ends_with(func->name, "_4core9panicking9panic_fmt")			||
> > > +		     str_ends_with(func->name, "_4core9panicking14panic_explicit")		||
> > > +		     str_ends_with(func->name, "_4core9panicking18panic_bounds_check")		||
> > > +		     strstr(func->name, "_4core9panicking11panic_const24panic_const_")		||
> > > +		     (strstr(func->name, "_4core5slice5index24slice_") &&
> > > +		      str_ends_with(func->name, "_fail"))))
> > > +			return true;
> > > +  
> 
> Perhaps add a helper function: is_rust_noreturn() or somesuch.
> 
> > I wonder if we should use dwarf for this. There's DW_AT_noreturn which
> > tells us exactly what we want. This would also remove the need for the
> > hardcoded C symbol list. I do recognise that debug info is not required
> > for objtool though...  
> 
> I think the slightly longer term plan here was to have noreturn.h
> generated from a DWARF build but still included verbatim in the objtool
> source, such that it works even on regular builds.
> 
> (and can be augmented where the compilers are being 'funny')
> 
> It's just that nobody has had time to implement this... you fancy giving
> this a stab?

The information extraction from dwarf is quite easy: I produced a tiny
cargo script that would be able to extract the info from an object file
(Miguel mentioned it in one of the replies):

https://gist.github.com/nbdd0121/449692570622c2f46a29ad9f47c3379a

I think the issue is that the list of noreturn symbols changes
depending on the configuration, so it's kind of difficult to
pregenerate this information.

Do you think it makes sense to have Rust object files always have DWARF
enabled, and we check Rust noreturn symbols using DWARF, while keep the
hardcoded C symbol list?

Best,
Gary



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ