public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH net] net/sched: em_canid: add length check before reading CAN ID
@ 2025-11-26  3:46 ssrane_b23
  2025-11-26  4:16 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: ssrane_b23 @ 2025-11-26  3:46 UTC (permalink / raw)
  To: socketcan
  Cc: mkl, jhs, xiyou.wangcong, jiri, davem, edumazet, kuba, pabeni,
	horms, linux-can, netdev, linux-kernel, skhan,
	linux-kernel-mentees, david.hunter.linux, khalid, Shaurya Rane,
	syzbot+5d8269a1e099279152bc

From: Shaurya Rane <ssrane_b23@ee.vjti.ac.in>

Add a check to verify that the skb has at least sizeof(canid_t) bytes
before reading the CAN ID from skb->data. This prevents reading
uninitialized memory when processing malformed packets that don't
contain a valid CAN frame.

Reported-by: syzbot+5d8269a1e099279152bc@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=5d8269a1e099279152bc
Fixes: f057bbb6f9ed ("net: em_canid: Ematch rule to match CAN frames according to their identifiers")
Signed-off-by: Shaurya Rane <ssrane_b23@ee.vjti.ac.in>
---
 net/sched/em_canid.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/sched/em_canid.c b/net/sched/em_canid.c
index 5337bc462755..a9b6cab70ff1 100644
--- a/net/sched/em_canid.c
+++ b/net/sched/em_canid.c
@@ -99,6 +99,9 @@ static int em_canid_match(struct sk_buff *skb, struct tcf_ematch *m,
 	int i;
 	const struct can_filter *lp;
 
+	if (skb->len < sizeof(canid_t))
+		return 0;
+
 	can_id = em_canid_get_id(skb);
 
 	if (can_id & CAN_EFF_FLAG) {
-- 
2.34.1


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

end of thread, other threads:[~2025-11-26  4:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-26  3:46 [PATCH net] net/sched: em_canid: add length check before reading CAN ID ssrane_b23
2025-11-26  4:16 ` Eric Dumazet
2025-11-26  4:59   ` SHAURYA RANE

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