aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2018-01-16 13:30:14 -0500
committerMarc Kleine-Budde <mkl@pengutronix.de>2018-01-18 03:32:54 -0500
commit8cb68751c115d176ec851ca56ecfbb411568c9e8 (patch)
tree08b081492436174f37a8fe3d3c9fa8c2f9e47a76
parentad9294dbc227cbc8e173b3b963e7dd9af5314f77 (diff)
can: af_can: can_rcv(): replace WARN_ONCE by pr_warn_once
If an invalid CAN frame is received, from a driver or from a tun interface, a Kernel warning is generated. This patch replaces the WARN_ONCE by a simple pr_warn_once, so that a kernel, bootet with panic_on_warn, does not panic. A printk seems to be more appropriate here. Reported-by: syzbot+4386709c0c1284dca827@syzkaller.appspotmail.com Suggested-by: Dmitry Vyukov <dvyukov@google.com> Acked-by: Oliver Hartkopp <socketcan@hartkopp.net> Cc: linux-stable <stable@vger.kernel.org> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r--net/can/af_can.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/net/can/af_can.c b/net/can/af_can.c
index 003b2d6d655f..ae835382e678 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -721,20 +721,16 @@ static int can_rcv(struct sk_buff *skb, struct net_device *dev,
721{ 721{
722 struct canfd_frame *cfd = (struct canfd_frame *)skb->data; 722 struct canfd_frame *cfd = (struct canfd_frame *)skb->data;
723 723
724 if (WARN_ONCE(dev->type != ARPHRD_CAN || 724 if (unlikely(dev->type != ARPHRD_CAN || skb->len != CAN_MTU ||
725 skb->len != CAN_MTU || 725 cfd->len > CAN_MAX_DLEN)) {
726 cfd->len > CAN_MAX_DLEN, 726 pr_warn_once("PF_CAN: dropped non conform CAN skbuf: dev type %d, len %d, datalen %d\n",
727 "PF_CAN: dropped non conform CAN skbuf: " 727 dev->type, skb->len, cfd->len);
728 "dev type %d, len %d, datalen %d\n", 728 kfree_skb(skb);
729 dev->type, skb->len, cfd->len)) 729 return NET_RX_DROP;
730 goto drop; 730 }
731 731
732 can_receive(skb, dev); 732 can_receive(skb, dev);
733 return NET_RX_SUCCESS; 733 return NET_RX_SUCCESS;
734
735drop:
736 kfree_skb(skb);
737 return NET_RX_DROP;
738} 734}
739 735
740static int canfd_rcv(struct sk_buff *skb, struct net_device *dev, 736static int canfd_rcv(struct sk_buff *skb, struct net_device *dev,