* [PATCH stable] can: af_can: fix NULL pointer dereference in can_rcv_filter
@ 2022-12-09 18:07 Oliver Hartkopp
2022-12-09 18:35 ` Oliver Hartkopp
0 siblings, 1 reply; 2+ messages in thread
From: Oliver Hartkopp @ 2022-12-09 18:07 UTC (permalink / raw)
To: stable
Cc: netdev, linux-can, Oliver Hartkopp, syzbot+2d7f58292cb5b29eb5ad,
Wei Chen
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@syzkaller.appspotmail.com
Reported-by: Wei Chen <harperchen1110@gmail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: stable@vger.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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH stable] can: af_can: fix NULL pointer dereference in can_rcv_filter
2022-12-09 18:07 [PATCH stable] can: af_can: fix NULL pointer dereference in can_rcv_filter Oliver Hartkopp
@ 2022-12-09 18:35 ` Oliver Hartkopp
0 siblings, 0 replies; 2+ messages in thread
From: Oliver Hartkopp @ 2022-12-09 18:35 UTC (permalink / raw)
To: stable, Greg Kroah-Hartman
Cc: netdev, linux-can, syzbot+2d7f58292cb5b29eb5ad, Wei Chen
Just checked that the stable patch for 8aa59e355949 ("can: af_can: fix
NULL pointer dereference in can_rx_register()") has been applied down to
linux-5.4.y
Same works with this patch.
Just the current 6.1-rc has some changes in this section which makes
this backport stable patch necessary.
Best,
Oliver
On 09.12.22 19:07, Oliver Hartkopp wrote:
> 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@syzkaller.appspotmail.com
> Reported-by: Wei Chen <harperchen1110@gmail.com>
> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
> Cc: stable@vger.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;
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-09 18:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-09 18:07 [PATCH stable] can: af_can: fix NULL pointer dereference in can_rcv_filter Oliver Hartkopp
2022-12-09 18:35 ` Oliver Hartkopp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox