public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 6.6.y]  net: sched: fix TCF_LAYER_TRANSPORT handling in tcf_get_base_ptr()
@ 2026-03-27 15:23 driz2t
  2026-03-27 15:53 ` [v6.6] WARNING in em_nbyte_match syzbot
  0 siblings, 1 reply; 2+ messages in thread
From: driz2t @ 2026-03-27 15:23 UTC (permalink / raw)
  To: syzbot+aa4eb7c67913dbd88f56; +Cc: stable


[-- Attachment #1.1: Type: text/plain, Size: 194 bytes --]

Hi,

Please test this patch on stable 6.6.y.


#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git c09fbcd31ae6d71e7c69545839bec92d8e15c13b


Thanks,
Changjian Liu

[-- Attachment #1.2: Type: text/html, Size: 269 bytes --]

[-- Attachment #2: aa4eb7c67913dbd88f56.patch --]
[-- Type: application/octet-stream, Size: 4215 bytes --]

commit 4fe5a00ec70717a7f1002d8913ec6143582b3c8e
Author: Eric Dumazet <edumazet@google.com>
Date:   Fri Nov 21 15:41:00 2025 +0000

    net: sched: fix TCF_LAYER_TRANSPORT handling in tcf_get_base_ptr()
    
    syzbot reported that tcf_get_base_ptr() can be called while transport
    header is not set [1].
    
    Instead of returning a dangling pointer, return NULL.
    
    Fix tcf_get_base_ptr() callers to handle this NULL value.
    
    [1]
     WARNING: CPU: 1 PID: 6019 at ./include/linux/skbuff.h:3071 skb_transport_header include/linux/skbuff.h:3071 [inline]
     WARNING: CPU: 1 PID: 6019 at ./include/linux/skbuff.h:3071 tcf_get_base_ptr include/net/pkt_cls.h:539 [inline]
     WARNING: CPU: 1 PID: 6019 at ./include/linux/skbuff.h:3071 em_nbyte_match+0x2d8/0x3f0 net/sched/em_nbyte.c:43
    Modules linked in:
    CPU: 1 UID: 0 PID: 6019 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT(full)
    Call Trace:
     <TASK>
      tcf_em_match net/sched/ematch.c:494 [inline]
      __tcf_em_tree_match+0x1ac/0x770 net/sched/ematch.c:520
      tcf_em_tree_match include/net/pkt_cls.h:512 [inline]
      basic_classify+0x115/0x2d0 net/sched/cls_basic.c:50
      tc_classify include/net/tc_wrapper.h:197 [inline]
      __tcf_classify net/sched/cls_api.c:1764 [inline]
      tcf_classify+0x4cf/0x1140 net/sched/cls_api.c:1860
      multiq_classify net/sched/sch_multiq.c:39 [inline]
      multiq_enqueue+0xfd/0x4c0 net/sched/sch_multiq.c:66
      dev_qdisc_enqueue+0x4e/0x260 net/core/dev.c:4118
      __dev_xmit_skb net/core/dev.c:4214 [inline]
      __dev_queue_xmit+0xe83/0x3b50 net/core/dev.c:4729
      packet_snd net/packet/af_packet.c:3076 [inline]
      packet_sendmsg+0x3e33/0x5080 net/packet/af_packet.c:3108
      sock_sendmsg_nosec net/socket.c:727 [inline]
      __sock_sendmsg+0x21c/0x270 net/socket.c:742
      ____sys_sendmsg+0x505/0x830 net/socket.c:2630
    
    Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
    Reported-by: syzbot+f3a497f02c389d86ef16@syzkaller.appspotmail.com
    Closes: https://lore.kernel.org/netdev/6920855a.a70a0220.2ea503.0058.GAE@google.com/T/#u
    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
    Link: https://patch.msgid.link/20251121154100.1616228-1-edumazet@google.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
--- a/include/net/pkt_cls.h
+++ b/include/net/pkt_cls.h
@@ -536,6 +536,8 @@ static inline unsigned char * tcf_get_base_ptr(struct sk_buff *skb, int layer)
 		case TCF_LAYER_NETWORK:
 			return skb_network_header(skb);
 		case TCF_LAYER_TRANSPORT:
+			if (!skb_transport_header_was_set(skb))
+				break;
 			return skb_transport_header(skb);
 	}
 
--- a/net/sched/em_cmp.c
+++ b/net/sched/em_cmp.c
@@ -22,9 +22,12 @@ static int em_cmp_match(struct sk_buff *skb, struct tcf_ematch *em,
 			struct tcf_pkt_info *info)
 {
 	struct tcf_em_cmp *cmp = (struct tcf_em_cmp *) em->data;
-	unsigned char *ptr = tcf_get_base_ptr(skb, cmp->layer) + cmp->off;
+	unsigned char *ptr = tcf_get_base_ptr(skb, cmp->layer);
 	u32 val = 0;
 
+	if (!ptr)
+		return 0;
+	ptr += cmp->off;
 	if (!tcf_valid_offset(skb, ptr, cmp->align))
 		return 0;
 
--- a/net/sched/em_nbyte.c
+++ b/net/sched/em_nbyte.c
@@ -42,6 +42,8 @@ static int em_nbyte_match(struct sk_buff *skb, struct tcf_ematch *em,
 	struct nbyte_data *nbyte = (struct nbyte_data *) em->data;
 	unsigned char *ptr = tcf_get_base_ptr(skb, nbyte->hdr.layer);
 
+	if (!ptr)
+		return 0;
 	ptr += nbyte->hdr.off;
 
 	if (!tcf_valid_offset(skb, ptr, nbyte->hdr.len))
--- a/net/sched/em_text.c
+++ b/net/sched/em_text.c
@@ -29,12 +29,19 @@ static int em_text_match(struct sk_buff *skb, struct tcf_ematch *m,
 			 struct tcf_pkt_info *info)
 {
 	struct text_match *tm = EM_TEXT_PRIV(m);
+	unsigned char *ptr;
 	int from, to;
 
-	from = tcf_get_base_ptr(skb, tm->from_layer) - skb->data;
+	ptr = tcf_get_base_ptr(skb, tm->from_layer);
+	if (!ptr)
+		return 0;
+	from = ptr - skb->data;
 	from += tm->from_offset;
 
-	to = tcf_get_base_ptr(skb, tm->to_layer) - skb->data;
+	ptr = tcf_get_base_ptr(skb, tm->to_layer);
+	if (!ptr)
+		return 0;
+	to = ptr - skb->data;
 	to += tm->to_offset;
 
 	return skb_find_text(skb, from, to, tm->config) != UINT_MAX;

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

* Re: [v6.6] WARNING in em_nbyte_match
  2026-03-27 15:23 [PATCH 6.6.y] net: sched: fix TCF_LAYER_TRANSPORT handling in tcf_get_base_ptr() driz2t
@ 2026-03-27 15:53 ` syzbot
  0 siblings, 0 replies; 2+ messages in thread
From: syzbot @ 2026-03-27 15:53 UTC (permalink / raw)
  To: driz2t, stable, syzkaller-lts-bugs

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+aa4eb7c67913dbd88f56@syzkaller.appspotmail.com
Tested-by: syzbot+aa4eb7c67913dbd88f56@syzkaller.appspotmail.com

Tested on:

commit:         c09fbcd3 Linux 6.6.130
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=1440e1d6580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=cf30d9e358c58220
dashboard link: https://syzkaller.appspot.com/bug?extid=aa4eb7c67913dbd88f56
compiler:       Debian clang version 21.1.8 (++20251221033036+2078da43e25a-1~exp1~20251221153213.50), Debian LLD 21.1.8
patch:          https://syzkaller.appspot.com/x/patch.diff?x=12692aca580000

Note: testing is done by a robot and is best-effort only.

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

end of thread, other threads:[~2026-03-27 15:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-27 15:23 [PATCH 6.6.y] net: sched: fix TCF_LAYER_TRANSPORT handling in tcf_get_base_ptr() driz2t
2026-03-27 15:53 ` [v6.6] WARNING in em_nbyte_match syzbot

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