Hi Oliver,

Oliver Hartkopp wrote:
> Wolfgang Grandegger wrote:
> 
>>>> Please also check for useless "dlc > 8" checks in the
>>>> start_xmit function.
>>> I thought about that and i'm not really sure about it:
>>> What if anyone uses PF_PACKET with CAN netdevices, which is a possible 
>>> use-case?
>> OK.
> 
> Any ideas how to proceed in the start_xmit functions?
> 
> We could add something like this consistently to *all* start_xmit functions:
> 
> Index: drivers/net/can/sja1000/sja1000.c
> ===================================================================
> --- drivers/net/can/sja1000/sja1000.c (Revision 1095)
> +++ drivers/net/can/sja1000/sja1000.c (Arbeitskopie)
> @@ -257,6 +257,13 @@
>       uint8_t dreg;
>       int i;
> 
> +     if (WARN_ONCE(skb->len != sizeof(*cf) || cf->can_dlc > 8,
> +                   "Dropped non conform skbuf: len %d, can_dlc %d\n",
> +                   skb->len, cf->can_dlc)) {
> +             kfree_skb(skb);
> +             return 0;
> +     }
> +

The mcp512x uses:

        if (skb->len != sizeof(struct can_frame)) {
                dev_err(&spi->dev, "dropping packet - bad length\n");
                dev_kfree_skb(skb);
                net->stats.tx_dropped++;
                return NETDEV_TX_OK;
        }

Maybe a dev_err() is already enough to inform the user about using a bad
format.

Wolfgang.
_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core

Reply via email to