linux/rust
Sagar Taunk 0923198be4 rust: net: netlink: validate attribute length before casting to c_int
`put()` trusted an unchecked `as` cast from `usize` to `c_int`.
When the length exceeds `i32::MAX` that cast wraps around to a
negative value.

This ultimately resulted in a kernel panic when the reinterpreted
value via `__nla_reserve()` and `skb_put()` became enormous.

Validate payload and header both fit together in a `u16`, rejecting
any payload that wouldn't leave room for `NLA_HDRLEN`.

Fixes: 5eaa5fbb6e ("rust: netlink: add raw netlink abstraction")
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Carlos Llamas <cmllamas@google.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: Sagar Taunk <sagartaunk@proton.me>
Link: https://patch.msgid.link/20260925085449.22553-1-sagartaunk@proton.me
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-09-29 12:28:03 +02:00
..
bindings rust: allow unknown_lints in generated bindings for Rust < 1.88 2026-09-08 23:29:18 +02:00
helpers Char/Misc/IIO/etc driver update for 7.3-rc1 2026-08-25 09:38:50 -07:00
kernel rust: net: netlink: validate attribute length before casting to c_int 2026-09-29 12:28:03 +02:00
macros Modules changes for 7.3-rc1 2026-08-21 12:47:25 -07:00
pin-init rust: pin-init: use irrefutable pattern for stack_pin_init 2026-09-01 01:27:55 +02:00
proc-macro2 rust: proc-macro2: rebuild if the version text changes 2026-01-23 10:44:27 +01:00
quote
syn
uapi rust: allow unknown_lints in generated bindings for Rust < 1.88 2026-09-08 23:29:18 +02:00
zerocopy rust: zerocopy: update to v0.8.54 2026-07-11 13:46:02 +02:00
zerocopy-derive rust: zerocopy: update to v0.8.54 2026-07-11 13:46:02 +02:00
.gitignore
.kunitconfig
bindgen_parameters rust/bindgen_parameters: Mark s390 types as opaque to prevent repr conflicts 2026-06-10 16:25:13 +02:00
build_error.rs
compiler_builtins.rs rust: Make __udivdi3() and __umoddi3() panic 2026-07-31 16:57:48 +05:30
exports.c kbuild: rust: provide an option to inline C helpers into Rust 2026-03-30 02:03:52 +02:00
ffi.rs
Makefile Rust fixes for v7.3 2026-08-30 09:47:39 -07:00