mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-06-21 15:43:21 +02:00
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 <edumazet@google.com> Link: https://patch.msgid.link/20260512155244.4137851-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
878492af7d
commit
ff205bf8c5
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user