Re: [PATCH net-next v5] rust: net: netlink: validate attribute length before casting to `c_int`

From
Andrew Lunn <andrew@lunn.ch>
Date
2026-09-24 19:23:06
Also in
lkml, rust-for-linux
Reply to
Sagar Taunk, 2026-09-24
On Thu, Sep 24, 2026 at 06:58:25PM +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")
Seems i was too slow giving you the link to the Documentation.

If this is a fix, and needs back porting to stable, you should base
your patch on net, not net-next.

     Andrew
Thread (2 messages) 2 messages, 2 authors, last reply 2026-09-24
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help