Message ID | 1262873421-6863-2-git-send-email-wg@grandegger.com |
---|---|
State | Superseded, archived |
Delegated to: | David Miller |
Headers | show |
Wolfgang Grandegger wrote: > The start_xmit function of the MSCAN Driver did return improperly if > the CAN dlc check failed (skb not freed and invalid return code). This > patch adds a proper check of the frame lenght and data size and returns > now correctly. > @@ -177,8 +177,13 @@ static netdev_tx_t mscan_start_xmit(struct sk_buff *skb, struct net_device *dev) > int i, rtr, buf_id; > u32 can_id; > > - if (frame->can_dlc > 8) > - return -EINVAL; > + if (skb->len != sizeof(*frame) || frame->can_dlc > 8) { > + dev_err(dev->dev.parent, > + "Dropping non-conform packet: len %u, can_dlc %u\n", > + skb->len, frame->can_dlc); > + kfree_skb(skb); > + return NETDEV_TX_OK; > + } > Hi Wolfgang, i would suggest to remove the dev_err() which may flood the kernel log and add dev->stats.tx_dropped++; instead. As discussed with DaveM on netdev-ML this 'silent' handling seems to be the most appropriate approach to deal with invalid skbs. We should update the other CAN drivers in a similar way, if this is ok for you. Best regards, Oliver -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/net/can/mscan/mscan.c b/drivers/net/can/mscan/mscan.c index 07346f8..955a164 100644 --- a/drivers/net/can/mscan/mscan.c +++ b/drivers/net/can/mscan/mscan.c @@ -4,7 +4,7 @@ * Copyright (C) 2005-2006 Andrey Volkov <avolkov@varma-el.com>, * Varma Electronics Oy * Copyright (C) 2008-2009 Wolfgang Grandegger <wg@grandegger.com> - * Copytight (C) 2008-2009 Pengutronix <kernel@pengutronix.de> + * Copyright (C) 2008-2009 Pengutronix <kernel@pengutronix.de> * * This program is free software; you can redistribute it and/or modify * it under the terms of the version 2 of the GNU General Public License @@ -177,8 +177,13 @@ static netdev_tx_t mscan_start_xmit(struct sk_buff *skb, struct net_device *dev) int i, rtr, buf_id; u32 can_id; - if (frame->can_dlc > 8) - return -EINVAL; + if (skb->len != sizeof(*frame) || frame->can_dlc > 8) { + dev_err(dev->dev.parent, + "Dropping non-conform packet: len %u, can_dlc %u\n", + skb->len, frame->can_dlc); + kfree_skb(skb); + return NETDEV_TX_OK; + } out_8(®s->cantier, 0);