mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] can: dev: fix missing skb header initialization in init_can_skb
@ 2026-09-18 15:16 Shaunak Datar
  2026-09-18 17:33 ` Oliver Hartkopp
  0 siblings, 1 reply; 2+ messages in thread
From: Shaunak Datar @ 2026-09-18 15:16 UTC (permalink / raw)
  To: mkl, mailhol
  Cc: pabeni, socketcan, linux-can, linux-kernel, Shaunak Datar,
	syzbot+1aae11dc8d42ec1a87ec

__alloc_skb() sets skb->mac_header to (typeof(skb->mac_header))~0U via
__finalize_skb_around(). skb_reset_mac_len() checks if the value has been
updated via the skb_mac_header_was_set() and fires
DEBUG_NET_WARN_ON_ONCE(1) if not.

init_can_skb() previously included three header reset calls:

- skb_reset_mac_header(skb)
- skb_reset_network_header(skb)
- skb_reset_transport_header(skb)

Commit 9f10374bb024 ("can: remove private CAN skb headroom
infrastructure") dropped these calls which leads to the skb->mac_header
retaining the original value.

Restore the three missing calls in the init_can_skb().

Fixes: 9f10374bb024 ("can: remove private CAN skb headroom infrastructure")
Reported-by: syzbot+1aae11dc8d42ec1a87ec@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1aae11dc8d42ec1a87ec
Signed-off-by: Shaunak Datar <shaunakkdatar@gmail.com>
---
 drivers/net/can/dev/skb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/can/dev/skb.c b/drivers/net/can/dev/skb.c
index 95fcdc1026f8..9cbddc1edd41 100644
--- a/drivers/net/can/dev/skb.c
+++ b/drivers/net/can/dev/skb.c
@@ -210,6 +210,9 @@ static void init_can_skb(struct sk_buff *skb)
 {
 	skb->pkt_type = PACKET_BROADCAST;
 	skb->ip_summed = CHECKSUM_UNNECESSARY;
+	skb_reset_mac_header(skb);
+	skb_reset_network_header(skb);
+	skb_reset_transport_header(skb);
 }
 
 struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf)
-- 
2.53.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] can: dev: fix missing skb header initialization in init_can_skb
  2026-09-18 15:16 [PATCH] can: dev: fix missing skb header initialization in init_can_skb Shaunak Datar
@ 2026-09-18 17:33 ` Oliver Hartkopp
  0 siblings, 0 replies; 2+ messages in thread
From: Oliver Hartkopp @ 2026-09-18 17:33 UTC (permalink / raw)
  To: Shaunak Datar, mkl, mailhol
  Cc: pabeni, linux-can, linux-kernel, syzbot+1aae11dc8d42ec1a87ec

Hallo Shaunak,

many thanks for your patch. But there's already a fix awaiting upstream:

https://lore.kernel.org/linux-can/20260917123716.63116-1-ndaugoing@gmail.com/

Best regards,
Oliver

On 18.09.26 17:16, Shaunak Datar wrote:
> __alloc_skb() sets skb->mac_header to (typeof(skb->mac_header))~0U via
> __finalize_skb_around(). skb_reset_mac_len() checks if the value has been
> updated via the skb_mac_header_was_set() and fires
> DEBUG_NET_WARN_ON_ONCE(1) if not.
> 
> init_can_skb() previously included three header reset calls:
> 
> - skb_reset_mac_header(skb)
> - skb_reset_network_header(skb)
> - skb_reset_transport_header(skb)
> 
> Commit 9f10374bb024 ("can: remove private CAN skb headroom
> infrastructure") dropped these calls which leads to the skb->mac_header
> retaining the original value.
> 
> Restore the three missing calls in the init_can_skb().
> 
> Fixes: 9f10374bb024 ("can: remove private CAN skb headroom infrastructure")
> Reported-by: syzbot+1aae11dc8d42ec1a87ec@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=1aae11dc8d42ec1a87ec
> Signed-off-by: Shaunak Datar <shaunakkdatar@gmail.com>
> ---
>   drivers/net/can/dev/skb.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/can/dev/skb.c b/drivers/net/can/dev/skb.c
> index 95fcdc1026f8..9cbddc1edd41 100644
> --- a/drivers/net/can/dev/skb.c
> +++ b/drivers/net/can/dev/skb.c
> @@ -210,6 +210,9 @@ static void init_can_skb(struct sk_buff *skb)
>   {
>   	skb->pkt_type = PACKET_BROADCAST;
>   	skb->ip_summed = CHECKSUM_UNNECESSARY;
> +	skb_reset_mac_header(skb);
> +	skb_reset_network_header(skb);
> +	skb_reset_transport_header(skb);
>   }
>   
>   struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf)


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-18 17:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-18 15:16 [PATCH] can: dev: fix missing skb header initialization in init_can_skb Shaunak Datar
2026-09-18 17:33 ` Oliver Hartkopp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®