* [PATCH v3] net/sched: em_canid: fix uninit-value in em_canid_match
@ 2025-11-26 8:57 ssrane_b23
2025-11-26 9:03 ` Eric Dumazet
2025-11-26 15:28 ` Marc Kleine-Budde
0 siblings, 2 replies; 3+ messages in thread
From: ssrane_b23 @ 2025-11-26 8:57 UTC (permalink / raw)
To: Oliver Hartkopp, Marc Kleine-Budde, Jamal Hadi Salim, Cong Wang,
Jiri Pirko, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: Simon Horman, Rostislav Lisovy, 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>
Use pskb_may_pull() to ensure a complete CAN frame is present in the
linear data buffer before reading the CAN ID. A simple skb->len check
is insufficient because it only verifies the total data length but does
not guarantee the data is present in skb->data (it could be in
fragments).
pskb_may_pull() both validates the length and pulls fragmented data
into the linear buffer if necessary, making it safe to directly
access skb->data.
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>
---
v3: Use CAN_MTU to validate a complete CAN frame is present
v2: Use pskb_may_pull() instead of skb->len check to properly
handle fragmented skbs
---
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..2d27f91d8441 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 (!pskb_may_pull(skb, CAN_MTU))
+ 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* Re: [PATCH v3] net/sched: em_canid: fix uninit-value in em_canid_match
2025-11-26 8:57 [PATCH v3] net/sched: em_canid: fix uninit-value in em_canid_match ssrane_b23
@ 2025-11-26 9:03 ` Eric Dumazet
2025-11-26 15:28 ` Marc Kleine-Budde
1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2025-11-26 9:03 UTC (permalink / raw)
To: ssrane_b23
Cc: Oliver Hartkopp, Marc Kleine-Budde, Jamal Hadi Salim, Cong Wang,
Jiri Pirko, David S . Miller, Jakub Kicinski, Paolo Abeni,
Simon Horman, Rostislav Lisovy, linux-can, netdev, linux-kernel,
skhan, linux-kernel-mentees, david.hunter.linux, khalid,
syzbot+5d8269a1e099279152bc
On Wed, Nov 26, 2025 at 12:57 AM <ssrane_b23@ee.vjti.ac.in> wrote:
>
> From: Shaurya Rane <ssrane_b23@ee.vjti.ac.in>
>
> Use pskb_may_pull() to ensure a complete CAN frame is present in the
> linear data buffer before reading the CAN ID. A simple skb->len check
> is insufficient because it only verifies the total data length but does
> not guarantee the data is present in skb->data (it could be in
> fragments).
>
> pskb_may_pull() both validates the length and pulls fragmented data
> into the linear buffer if necessary, making it safe to directly
> access skb->data.
>
> 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>
> ---
> v3: Use CAN_MTU to validate a complete CAN frame is present
> v2: Use pskb_may_pull() instead of skb->len check to properly
> handle fragmented skbs
> ---
> 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..2d27f91d8441 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 (!pskb_may_pull(skb, CAN_MTU))
> + return 0;
> +
> can_id = em_canid_get_id(skb);
>
> if (can_id & CAN_EFF_FLAG) {
For your next netdev patches, please read
Documentation/process/maintainer-netdev.rst
Resending after review
~~~~~~~~~~~~~~~~~~~~~~
Allow at least 24 hours to pass between postings. This will ensure reviewers
from all geographical locations have a chance to chime in. Do not wait
too long (weeks) between postings either as it will make it harder for reviewers
to recall all the context.
Thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v3] net/sched: em_canid: fix uninit-value in em_canid_match
2025-11-26 8:57 [PATCH v3] net/sched: em_canid: fix uninit-value in em_canid_match ssrane_b23
2025-11-26 9:03 ` Eric Dumazet
@ 2025-11-26 15:28 ` Marc Kleine-Budde
1 sibling, 0 replies; 3+ messages in thread
From: Marc Kleine-Budde @ 2025-11-26 15:28 UTC (permalink / raw)
To: ssrane_b23
Cc: Oliver Hartkopp, Jamal Hadi Salim, Cong Wang, Jiri Pirko,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Rostislav Lisovy, linux-can, netdev, linux-kernel,
skhan, linux-kernel-mentees, david.hunter.linux, khalid,
syzbot+5d8269a1e099279152bc
[-- Attachment #1: Type: text/plain, Size: 1190 bytes --]
On 26.11.2025 14:27:18, ssrane_b23@ee.vjti.ac.in wrote:
> From: Shaurya Rane <ssrane_b23@ee.vjti.ac.in>
>
> Use pskb_may_pull() to ensure a complete CAN frame is present in the
> linear data buffer before reading the CAN ID. A simple skb->len check
> is insufficient because it only verifies the total data length but does
> not guarantee the data is present in skb->data (it could be in
> fragments).
>
> pskb_may_pull() both validates the length and pulls fragmented data
> into the linear buffer if necessary, making it safe to directly
> access skb->data.
>
> 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>
Applied to linux-can
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-26 15:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-26 8:57 [PATCH v3] net/sched: em_canid: fix uninit-value in em_canid_match ssrane_b23
2025-11-26 9:03 ` Eric Dumazet
2025-11-26 15:28 ` Marc Kleine-Budde
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox