Commit 638696ef authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'net-af_packet-be-careful-when-expanding-mac-header-size'

Eric Dumazet says:

====================
net: af_packet: be careful when expanding mac header size

A recent regression in af_packet needed a preliminary debug patch,
which will presumably be useful for next bugs hunting.

The af_packet fix is to make sure MAC headers are contained in
skb linear part, as GSO stack requests.

v2: CONFIG_DEBUG_NET depends on CONFIG_NET to avoid compile
   errors found by kernel bots.
====================

Link: https://lore.kernel.org/r/20220602161859.2546399-1-eric.dumazet@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 83450bba e9d3f809
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -2696,7 +2696,14 @@ void *skb_pull(struct sk_buff *skb, unsigned int len);
static inline void *__skb_pull(struct sk_buff *skb, unsigned int len)
{
	skb->len -= len;
	BUG_ON(skb->len < skb->data_len);
	if (unlikely(skb->len < skb->data_len)) {
#if defined(CONFIG_DEBUG_NET)
		skb->len += len;
		pr_err("__skb_pull(len=%u)\n", len);
		skb_dump(KERN_ERR, skb, false);
#endif
		BUG();
	}
	return skb->data += len;
}

+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ config NET_NS_REFCNT_TRACKER

config DEBUG_NET
	bool "Add generic networking debug"
	depends on DEBUG_KERNEL
	depends on DEBUG_KERNEL && NET
	help
	  Enable extra sanity checks in networking.
	  This is mostly used by fuzzers, but is safe to select.
+4 −2
Original line number Diff line number Diff line
@@ -1935,8 +1935,10 @@ static void packet_parse_headers(struct sk_buff *skb, struct socket *sock)
	/* Move network header to the right position for VLAN tagged packets */
	if (likely(skb->dev->type == ARPHRD_ETHER) &&
	    eth_type_vlan(skb->protocol) &&
	    __vlan_get_protocol(skb, skb->protocol, &depth) != 0)
	    __vlan_get_protocol(skb, skb->protocol, &depth) != 0) {
		if (pskb_may_pull(skb, depth))
			skb_set_network_header(skb, depth);
	}

	skb_probe_transport_header(skb);
}