All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Wolfgang Grandegger <wg@grandegger.com>
Cc: Netdev@vger.kernel.org, Devicetree-discuss@lists.ozlabs.org,
	Socketcan-core@lists.berlios.de, Linuxppc-dev@lists.ozlabs.org,
	Wolfgang Grandegger <wg@denx.de>
Subject: Re: [PATCH net-next v3 1/3] can: mscan: fix improper return if dlc < 8 in start_xmit function
Date: Thu, 07 Jan 2010 19:10:38 +0100	[thread overview]
Message-ID: <4B46239E.2000403@hartkopp.net> (raw)
In-Reply-To: <1262873421-6863-2-git-send-email-wg@grandegger.com>

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

WARNING: multiple messages have this Message-ID (diff)
From: Oliver Hartkopp <socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
To: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
Cc: Netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	Socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org,
	Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
	Wolfgang Grandegger <wg-ynQEQJNshbs@public.gmane.org>
Subject: Re: [PATCH net-next v3 1/3] can: mscan: fix improper return if dlc < 8 in start_xmit function
Date: Thu, 07 Jan 2010 19:10:38 +0100	[thread overview]
Message-ID: <4B46239E.2000403@hartkopp.net> (raw)
In-Reply-To: <1262873421-6863-2-git-send-email-wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>

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

  parent reply	other threads:[~2010-01-07 18:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-07 14:10 [PATCH net-next v3 0/3] can: mscan-mpc5xxx: add support for the Freescale MPC512x Wolfgang Grandegger
2010-01-07 14:10 ` Wolfgang Grandegger
2010-01-07 14:10 ` [PATCH net-next v3 1/3] can: mscan: fix improper return if dlc < 8 in start_xmit function Wolfgang Grandegger
2010-01-07 14:10   ` Wolfgang Grandegger
2010-01-07 14:10   ` [PATCH net-next v3 2/3] can: mscan-mpc5xxx: add support for the MPC512x processor Wolfgang Grandegger
2010-01-07 14:10     ` Wolfgang Grandegger
2010-01-07 14:10     ` [PATCH net-next v3 3/3] powerpc/mpc5xxx: add OF platform binding doc for FSL MSCAN devices Wolfgang Grandegger
2010-01-07 14:10       ` Wolfgang Grandegger
2010-01-07 16:21     ` [PATCH net-next v3 2/3] can: mscan-mpc5xxx: add support for the MPC512x processor Wolfram Sang
2010-01-07 16:21       ` Wolfram Sang
2010-01-07 18:10   ` Oliver Hartkopp [this message]
2010-01-07 18:10     ` [PATCH net-next v3 1/3] can: mscan: fix improper return if dlc < 8 in start_xmit function Oliver Hartkopp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B46239E.2000403@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=Devicetree-discuss@lists.ozlabs.org \
    --cc=Linuxppc-dev@lists.ozlabs.org \
    --cc=Netdev@vger.kernel.org \
    --cc=Socketcan-core@lists.berlios.de \
    --cc=wg@denx.de \
    --cc=wg@grandegger.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.