Re: [PATCH net-next v4] rust: net: netlink: validate attribute length before casting to `c_int`
From: Carlos Llamas
Date: Wed Sep 23 2026 - 13:38:45 EST
On Wed, Sep 23, 2026 at 12:05:17PM +0000, Sagar Taunk wrote:
> `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: 5eaa5fbb6e6c ("rust: netlink: add raw netlink abstraction")
> Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
> Signed-off-by: Sagar Taunk <sagartaunk@xxxxxxxxx>
> ---
LGTM,
Reviewed-by: Carlos Llamas <cmllamas@xxxxxxxxxx>