linux/rust/kernel/net
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
..
phy rust: make build_assert module the home of related macros 2026-06-10 09:07:13 +02:00
mod.rs rust: netlink: add raw netlink abstraction 2026-07-17 15:18:39 +02:00
netlink.rs rust: net: netlink: validate attribute length before casting to c_int 2026-09-29 12:28:03 +02:00
phy.rs rust: net: phy: fix off-by-one bit positions in device status accessors 2026-09-14 18:56:16 -07:00