netlink: add one debug check in nla_nest_end()
Subsystems (2)
PATCH 1/1 netlink: add one debug check in nla_nest_end()
Add a DEBUG_NET_WARN_ON_ONCE(diff > U16_MAX) to warn if the kernel sends corrupted nested attribute to user space.
Offenders can be converted to nla_nest_end_safe().
Signed-off-by Eric Dumazet <[email protected]>
--- include/net/netlink.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
include/net/netlink.h +4 -1
@@ -2260,7 +2260,10 @@ static inline struct nlattr *nla_nest_start(struct sk_buff *skb, int attrtype)*/ static inline int nla_nest_end (struct sk_buff *skb,struct nlattr *start) { - start->nla_len =skb_tail_pointer (skb) - (unsigned char *)start; +unsigned long diff =skb_tail_pointer (skb) - (unsigned char *)start; + +DEBUG_NET_WARN_ON_ONCE (diff >U16_MAX ); + start->nla_len = diff;return skb->len; }
Signature · 1 line
2.54.0.563.g4f69b47b94-goog
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Tue, 12 May 2026 15:52:44 +0000 you wrote:
Add a
DEBUG_NET_WARN_ON_ONCE(diff > U16_MAX)to warn if the kernel sends corrupted nested attribute to user space.Offenders can be converted to
nla_nest_end_safe().Signed-off-by Eric Dumazet <[email protected]>[...]
Here is the summary with links:
- [net-next] netlink: add one debug check in nla_nest_end()
https://git.kernel.org/netdev/net-next/c/ff205bf8c554
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html