netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Cc: davem@davemloft.net,
	"joshua.a.hay@intel.com" <joshua.a.hay@intel.com>,
	netdev@vger.kernel.org, gospo@redhat.com, sassmann@redhat.com
Subject: Re: [net-next 07/14] ixgbe: eliminate Smatch warnings in ixgbe_debugfs.c
Date: Fri, 26 Oct 2012 15:41:22 +0300	[thread overview]
Message-ID: <20121026124122.GJ20754@mwanda> (raw)
In-Reply-To: <1351252702-16532-8-git-send-email-jeffrey.t.kirsher@intel.com>

On Fri, Oct 26, 2012 at 04:58:15AM -0700, Jeff Kirsher wrote:
> From: "joshua.a.hay@intel.com" <joshua.a.hay@intel.com>
> 
> This patch replaces calls to copy_to_user, copy_from_user, and the associated
> logic, with calls to simple_read_from_buffer and simple_write_to_buffer
> respectively.  This was done to eliminate warnings generated by the Smatch
> static analysis tool.

There were some bugs, it wasn't just about silencing warnings.

> +	buf = kasprintf(GFP_KERNEL, "%s: %s\n",
> +			adapter->netdev->name,
> +			ixgbe_dbg_reg_ops_buf);
> +	if (!buf)
> +		return -ENOMEM;
> +
> +	if (count < strlen(buf))
>  		return -ENOSPC;

You need a kfree(buf) here.

> -	ixgbe_dbg_reg_ops_buf[count] = '\0';
> +	len = simple_write_to_buffer(ixgbe_dbg_reg_ops_buf,
> +				     sizeof(ixgbe_dbg_reg_ops_buf),

This should be "sizeof(ixgbe_dbg_reg_ops_buf) - 1" to leave space
for the NUL terminator.

> +				     ppos,
> +				     buffer,
> +				     count);
> +	ixgbe_dbg_reg_ops_buf[len] = '\0';

simple_write_to_buffer() returns negative error codes so this could
corrupt memory.


> +	buf = kasprintf(GFP_KERNEL, "%s: %s\n",
> +			adapter->netdev->name,
> +			ixgbe_dbg_netdev_ops_buf);
> +	if (!buf)
> +		return -ENOMEM;
>  
> -	*ppos = len;
> +	if (count < strlen(buf))
> +		return -ENOSPC;

Missing kfree().

> -	ixgbe_dbg_netdev_ops_buf[count] = '\0';
> +	len = simple_write_to_buffer(ixgbe_dbg_netdev_ops_buf,
> +				     sizeof(ixgbe_dbg_netdev_ops_buf),
> +				     ppos,
> +				     buffer,
> +				     count);
> +	ixgbe_dbg_netdev_ops_buf[len] = '\0';

Same issues as before.

regards,
dan carpenter

  reply	other threads:[~2012-10-26 12:41 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-26 11:58 [net-next 00/14][pull request] Intel Wired LAN Driver Updates Jeff Kirsher
2012-10-26 11:58 ` [net-next 01/14] ixgbe: Add support for pipeline reset Jeff Kirsher
2012-10-26 11:58 ` [net-next 02/14] ixgbe: Fix return value from macvlan filter function Jeff Kirsher
2012-10-26 11:58 ` [net-next 03/14] net, ixgbe: handle link local multicast addresses in SR-IOV mode Jeff Kirsher
2012-10-26 11:58 ` [net-next 04/14] ixgbe: clean up the condition for turning on/off the laser Jeff Kirsher
2012-10-26 11:58 ` [net-next 05/14] ixgbe: Return success or failure on VF MAC filter set Jeff Kirsher
2012-10-26 11:58 ` [net-next 06/14] ixgbe: Do not decrement budget in ixgbe_clean_rx_irq Jeff Kirsher
2012-10-26 11:58 ` [net-next 07/14] ixgbe: eliminate Smatch warnings in ixgbe_debugfs.c Jeff Kirsher
2012-10-26 12:41   ` Dan Carpenter [this message]
2012-10-26 11:58 ` [net-next 08/14] ixgbe: add/udpate descriptor maps in comments Jeff Kirsher
2012-10-26 11:58 ` [net-next 09/14] ixgbevf: Do not forward LLDP type frames Jeff Kirsher
2012-10-26 11:58 ` [net-next 10/14] ixgbevf: make sure probe fails on MSI-X enable error Jeff Kirsher
2012-10-26 12:43   ` Kicinski, Jakub
2012-10-26 16:32     ` Greg Rose
2012-10-26 11:58 ` [net-next 11/14] igbvf: Check for error on dma_map_single call Jeff Kirsher
2012-10-26 11:58 ` [net-next 12/14] igb: Enable auto-crossover during forced operation on 82580 and above Jeff Kirsher
2012-10-26 11:58 ` [net-next 13/14] igb: Update firmware version info for ethtool output Jeff Kirsher
2012-10-26 11:58 ` [net-next 14/14] igb: Fix sparse warning in igb_ptp_rx_pktstamp Jeff Kirsher

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=20121026124122.GJ20754@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=gospo@redhat.com \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=joshua.a.hay@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=sassmann@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).