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: <DFZQMVAWC7IS.7MTK7QGQLDB8@garyguo.net>
Date: Tue, 27 Jan 2026 22:51:06 +0000
From: "Gary Guo" <gary@...yguo.net>
To: "Nathan Chancellor" <nathan@...nel.org>, "Gary Guo" <gary@...nel.org>
Cc: "Miguel Ojeda" <ojeda@...nel.org>, "Boqun Feng" <boqun.feng@...il.com>,
 "Gary Guo" <gary@...yguo.net>, Björn Roy Baron
 <bjorn3_gh@...tonmail.com>, "Benno Lossin" <lossin@...nel.org>, "Andreas
 Hindborg" <a.hindborg@...nel.org>, "Alice Ryhl" <aliceryhl@...gle.com>,
 "Trevor Gross" <tmgross@...ch.edu>, "Danilo Krummrich" <dakr@...nel.org>,
 "Nicolas Schier" <nsc@...nel.org>, Thomas Weißschuh
 <linux@...ssschuh.net>, "Masahiro Yamada" <masahiroy@...nel.org>, "Kees
 Cook" <kees@...nel.org>, <rust-for-linux@...r.kernel.org>,
 <linux-kbuild@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH 2/2] kbuild: rust: use klint to provide
 CONFIG_FRAME_WARN

On Tue Jan 27, 2026 at 10:15 PM GMT, Nathan Chancellor wrote:
> On Tue, Jan 27, 2026 at 05:11:04PM +0000, Gary Guo wrote:
>> From: Gary Guo <gary@...yguo.net>
>> 
>> klint is able to analyze frame size and warn on frames that are too big.
>> 
>> With `register_tool(klint)` support, we can simply instruct rust to turn on
>> `klint::stack_frame_too_large`. This is a no-op if normal rustc (or Clippy)
>> is invoked, but will perform the check if klint is used.
>> 
>> This is an example of a bug caught using this option:
>> 
>> warning: stack size of `gsp::cmdq::Cmdq::new` is 8216 bytes, exceeds the 2048-byte limit
>>    --> drivers/gpu/nova-core/gsp/cmdq.rs:453:5
>>     |
>> 453 |     pub(crate) fn new(dev: &device::Device<device::Bound>) -> Result<Cmdq> {
>>     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>     |
>>     = note: the stack size is inferred from instruction `sub $0x2018,%rsp` at .text+32778
>> 
>> Signed-off-by: Gary Guo <gary@...yguo.net>
>
> Acked-by: Nathan Chancellor <nathan@...nel.org>
>
> Is the limit customizable?

Lints in Rust do not take arguments, so there's no way to represent something
similar to `-Wframe-larger-than=foo`. However, I've made klint search [1] for
`CONFIG_FRAME_WARN` and use whatever value is there.

Link: https://github.com/Rust-for-Linux/klint/blob/168031d93c3aa538c8ef71d1e448ae77c2cef7a7/src/binary_analysis/stack_size.rs#L70-L82 [1]

Best,
Gary

>
>> ---
>>  scripts/Makefile.warn | 1 +
>>  1 file changed, 1 insertion(+)
>> 
>> diff --git a/scripts/Makefile.warn b/scripts/Makefile.warn
>> index 5567da6c7dfe..254a4d53f8f3 100644
>> --- a/scripts/Makefile.warn
>> +++ b/scripts/Makefile.warn
>> @@ -23,6 +23,7 @@ KBUILD_CFLAGS += -Wmissing-prototypes
>>  
>>  ifneq ($(CONFIG_FRAME_WARN),0)
>>  KBUILD_CFLAGS += -Wframe-larger-than=$(CONFIG_FRAME_WARN)
>> +KBUILD_RUSTFLAGS += -Wklint::stack-frame-too-large
>>  endif
>>  
>>  KBUILD_CFLAGS-$(CONFIG_CC_NO_ARRAY_BOUNDS) += -Wno-array-bounds
>> -- 
>> 2.51.2
>> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ