linux-can-fixes-for-4.15-20180118

-----BEGIN PGP SIGNATURE-----
 
 iQFHBAABCgAxFiEE4bay/IylYqM/npjQHv7KIOw4HPYFAlpgXAoTHG1rbEBwZW5n
 dXRyb25peC5kZQAKCRAe/sog7Dgc9pfMB/92awOK3MnAv1k5HjWNK0y2Qn0ZF2uq
 5X63v54tNs/nTs/GRcq69YOehrgKKonTKGHfbU/IDw0LGcjQBd1VRXe38fSpURzu
 0ecaN6/5HY7bhmT4FrR1S0JUxM/mLF3WygJDbOQsoWByqyGdZBZVTMNhl12gGcNU
 mq3TPrAx2PO2C4/6U/QIIG0PVx+RytFobcGAssKhhILyJdbO/BjqQIgejg5uvZP2
 DqXVbj2+zFrcXjB6lhAiOCvdrYqQq2fdgJHeLtmYjfLf7hzLOt0aWqr4vgAkb/ew
 ejArkC8LaZZVxsB/I/dNKQebzBTxzs1QswwXpdjmR3xaxsazyTaQ4VnT
 =R2B8
 -----END PGP SIGNATURE-----

Merge tag 'linux-can-fixes-for-4.15-20180118' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can

Marc Kleine-Budde says:

====================
pull-request: can 2018-01-18

====================
this is a pull reqeust of two patches for net/master:

The syzkaller project triggered two WARN_ONCE() in the af_can code from
userspace and we decided to replace it by a pr_warn_once().
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
David S. Miller 2018-01-18 21:16:13 -05:00
commit 69c4a65e4b
1 changed files with 14 additions and 22 deletions

View File

@ -721,20 +721,16 @@ static int can_rcv(struct sk_buff *skb, struct net_device *dev,
{ {
struct canfd_frame *cfd = (struct canfd_frame *)skb->data; struct canfd_frame *cfd = (struct canfd_frame *)skb->data;
if (WARN_ONCE(dev->type != ARPHRD_CAN || if (unlikely(dev->type != ARPHRD_CAN || skb->len != CAN_MTU ||
skb->len != CAN_MTU || cfd->len > CAN_MAX_DLEN)) {
cfd->len > CAN_MAX_DLEN, pr_warn_once("PF_CAN: dropped non conform CAN skbuf: dev type %d, len %d, datalen %d\n",
"PF_CAN: dropped non conform CAN skbuf: " dev->type, skb->len, cfd->len);
"dev type %d, len %d, datalen %d\n", kfree_skb(skb);
dev->type, skb->len, cfd->len)) return NET_RX_DROP;
goto drop; }
can_receive(skb, dev); can_receive(skb, dev);
return NET_RX_SUCCESS; return NET_RX_SUCCESS;
drop:
kfree_skb(skb);
return NET_RX_DROP;
} }
static int canfd_rcv(struct sk_buff *skb, struct net_device *dev, static int canfd_rcv(struct sk_buff *skb, struct net_device *dev,
@ -742,20 +738,16 @@ static int canfd_rcv(struct sk_buff *skb, struct net_device *dev,
{ {
struct canfd_frame *cfd = (struct canfd_frame *)skb->data; struct canfd_frame *cfd = (struct canfd_frame *)skb->data;
if (WARN_ONCE(dev->type != ARPHRD_CAN || if (unlikely(dev->type != ARPHRD_CAN || skb->len != CANFD_MTU ||
skb->len != CANFD_MTU || cfd->len > CANFD_MAX_DLEN)) {
cfd->len > CANFD_MAX_DLEN, pr_warn_once("PF_CAN: dropped non conform CAN FD skbuf: dev type %d, len %d, datalen %d\n",
"PF_CAN: dropped non conform CAN FD skbuf: " dev->type, skb->len, cfd->len);
"dev type %d, len %d, datalen %d\n", kfree_skb(skb);
dev->type, skb->len, cfd->len)) return NET_RX_DROP;
goto drop; }
can_receive(skb, dev); can_receive(skb, dev);
return NET_RX_SUCCESS; return NET_RX_SUCCESS;
drop:
kfree_skb(skb);
return NET_RX_DROP;
} }
/* /*