From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+8ed98cbd0161632bce95@syzkaller.appspotmail.com
Cc: linux-can@vger.kernel.org, linux-kernel@vger.kernel.org,
mkl@pengutronix.de, socketcan@hartkopp.net,
syzkaller-bugs@googlegroups.com
Subject: [PATCH] can: af_can: reject can rx unregister if dev is not can
Date: Mon, 25 May 2026 21:56:24 +0800 [thread overview]
Message-ID: <tencent_C56D5496D4E8FEEFDECCB07AEE6FC42C450A@qq.com> (raw)
In-Reply-To: <6a124882.050a0220.30ba69.0009.GAE@google.com>
When a user binds a non-CAN device to a socket, the vulnerability reported
in [1] is triggered during the socket's closure and release phase, due to
the inability to find the expected receive list.
Added checks for Mid-layer private and type during the rx unregistration
process.
[1]
KASAN: null-ptr-deref in range [0x0000000000000028-0x000000000000002f]
pc : can_rx_unregister+0x124/0x560 net/can/af_can.c:537
Call trace:
can_rx_unregister+0x124/0x560 net/can/af_can.c:531 (P)
isotp_release+0x500/0x9d8 net/can/isotp.c:1232
__sock_release+0xa0/0x1d4 net/socket.c:722
sock_close+0x24/0x38 net/socket.c:1514
Fixes: bdfb5765e45b ("can: af_can: remove NULL-ptr checks from users of can_dev_rcv_lists_find()")
Reported-by: syzbot+8ed98cbd0161632bce95@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=8ed98cbd0161632bce95
Tested-by: syzbot+8ed98cbd0161632bce95@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
net/can/af_can.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/can/af_can.c b/net/can/af_can.c
index 7bc86b176b4d..72831b4e0776 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -519,7 +519,7 @@ void can_rx_unregister(struct net *net, struct net_device *dev, canid_t can_id,
struct can_rcv_lists_stats *rcv_lists_stats = net->can.rcv_lists_stats;
struct can_dev_rcv_lists *dev_rcv_lists;
- if (dev && dev->type != ARPHRD_CAN)
+ if (dev && (dev->type != ARPHRD_CAN || !can_get_ml_priv(dev)))
return;
if (dev && !net_eq(net, dev_net(dev)))
--
2.43.0
next prev parent reply other threads:[~2026-05-25 13:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-24 0:38 [syzbot] [can?] general protection fault in can_rx_unregister (2) syzbot
2026-05-25 3:35 ` Edward Adam Davis
2026-05-25 4:32 ` syzbot
2026-05-25 11:48 ` Edward Adam Davis
2026-05-25 13:30 ` syzbot
2026-05-25 13:56 ` Edward Adam Davis [this message]
2026-05-25 18:15 ` [PATCH] can: af_can: reject can rx unregister if dev is not can Oliver Hartkopp
2026-05-25 23:46 ` Edward Adam Davis
2026-05-26 14:16 ` Oliver Hartkopp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_C56D5496D4E8FEEFDECCB07AEE6FC42C450A@qq.com \
--to=eadavis@qq.com \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=socketcan@hartkopp.net \
--cc=syzbot+8ed98cbd0161632bce95@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®