[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221209180745.2977-1-socketcan@hartkopp.net>
Date: Fri, 9 Dec 2022 19:07:45 +0100
From: Oliver Hartkopp <socketcan@...tkopp.net>
To: stable@...r.kernel.org
Cc: netdev@...r.kernel.org, linux-can@...r.kernel.org,
Oliver Hartkopp <socketcan@...tkopp.net>,
syzbot+2d7f58292cb5b29eb5ad@...kaller.appspotmail.com,
Wei Chen <harperchen1110@...il.com>
Subject: [PATCH stable] can: af_can: fix NULL pointer dereference in can_rcv_filter
Analogue to commit 8aa59e355949 ("can: af_can: fix NULL pointer
dereference in can_rx_register()") we need to check for a missing
initialization of ml_priv in the receive path of CAN frames.
Since commit 4e096a18867a ("net: introduce CAN specific pointer in the
struct net_device") the check for dev->type to be ARPHRD_CAN is not
sufficient anymore since bonding or tun netdevices claim to be CAN
devices but do not initialize ml_priv accordingly.
Upstream commit 0acc442309a0 ("can: af_can: fix NULL pointer
dereference in can_rcv_filter")
Fixes: 4e096a18867a ("net: introduce CAN specific pointer in the struct net_device")
Reported-by: syzbot+2d7f58292cb5b29eb5ad@...kaller.appspotmail.com
Reported-by: Wei Chen <harperchen1110@...il.com>
Signed-off-by: Oliver Hartkopp <socketcan@...tkopp.net>
Cc: stable@...r.kernel.org # 5.12 .. 6.0
---
net/can/af_can.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/can/af_can.c b/net/can/af_can.c
index 1fb49d51b25d..4392f1d9c027 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -678,11 +678,11 @@ static void can_receive(struct sk_buff *skb, struct net_device *dev)
static int can_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev)
{
struct canfd_frame *cfd = (struct canfd_frame *)skb->data;
- if (unlikely(dev->type != ARPHRD_CAN || skb->len != CAN_MTU)) {
+ if (unlikely(dev->type != ARPHRD_CAN || !can_get_ml_priv(dev) || skb->len != CAN_MTU)) {
pr_warn_once("PF_CAN: dropped non conform CAN skbuff: dev type %d, len %d\n",
dev->type, skb->len);
goto free_skb;
}
@@ -704,11 +704,11 @@ static int can_rcv(struct sk_buff *skb, struct net_device *dev,
static int canfd_rcv(struct sk_buff *skb, struct net_device *dev,
struct packet_type *pt, struct net_device *orig_dev)
{
struct canfd_frame *cfd = (struct canfd_frame *)skb->data;
- if (unlikely(dev->type != ARPHRD_CAN || skb->len != CANFD_MTU)) {
+ if (unlikely(dev->type != ARPHRD_CAN || !can_get_ml_priv(dev) || skb->len != CANFD_MTU)) {
pr_warn_once("PF_CAN: dropped non conform CAN FD skbuff: dev type %d, len %d\n",
dev->type, skb->len);
goto free_skb;
}
--
2.30.2
Powered by blists - more mailing lists