Skip to content

Commit e0052b8

Browse files
committed
net: add debug check in skb_reset_mac_header()
JIRA: https://issues.redhat.com/browse/RHEL-96625 Upstream Status: net-next.git commit 3b6167e commit 3b6167e Author: Eric Dumazet <edumazet@google.com> Date: Tue Nov 5 17:44:03 2024 +0000 net: add debug check in skb_reset_mac_header() Make sure (skb->data - skb->head) can fit in skb->mac_header This needs CONFIG_DEBUG_NET=y. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Joe Damato <jdamato@fastly.com> Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Link: https://patch.msgid.link/20241105174403.850330-8-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Davide Caratti <dcaratti@redhat.com>
1 parent b24bfee commit e0052b8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

include/linux/skbuff.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3055,7 +3055,10 @@ static inline void skb_unset_mac_header(struct sk_buff *skb)
30553055

30563056
static inline void skb_reset_mac_header(struct sk_buff *skb)
30573057
{
3058-
skb->mac_header = skb->data - skb->head;
3058+
long offset = skb->data - skb->head;
3059+
3060+
DEBUG_NET_WARN_ON_ONCE(offset != (typeof(skb->mac_header))offset);
3061+
skb->mac_header = offset;
30593062
}
30603063

30613064
static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)

0 commit comments

Comments
 (0)