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: <d290de0964c8f0dd3e039a4b892b8171520bf503.camel@perches.com>
Date: Sun, 01 Feb 2026 11:37:26 -0800
From: Joe Perches <joe@...ches.com>
To: Jason Hall <jason.kei.hall@...il.com>, charmitro@...teo.net
Cc: apw@...onical.com, ojeda@...nel.org, rust-for-linux@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] scripts: checkpatch: warn on Rust panicking methods

On Sun, 2026-02-01 at 11:30 -0700, Jason Hall wrote:
> Added regex check in checkpatch.pl for common Rust panicking methods
> like unwrap() and expect().
> 
> Allowed an exception if the line contains a '// PANIC:' comment.

There's some desire to add rust comment checking.

https://lore.kernel.org/lkml/20260113211025.637889-1-foster.ryan.r@gmail.com/

Maybe this could be coordinated.

> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -3834,6 +3834,17 @@ sub process {
>  # check we are in a valid source file if not then ignore this hunk
>  		next if ($realfile !~ /\.(h|c|rs|s|S|sh|dtsi|dts)$/);
>  
> +# check for Rust unwrap/expect
> +		if ($realfile =~ /\.rs$/ && $line =~ /^\+/) {
> +			if ($line =~ /(\.|::)(unwrap|expect)\s*\(/ &&

Please use (?: to avoid capture groups

> +				$rawline !~ /\/\/\s*PANIC:/ &&
> +				$line !~ /^\+\s*\/\// &&
> +				$line !~ /^\+\s*assert/) {
> +				WARN("RUST_UNWRAP",
> +					"Avoid unwrap() or expect() in Rust code; use proper error handling (Result) or justify with a '// PANIC: ...' comment.\n" . $herecurr);
> +			}
> +		}


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ