netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Timur Tabi <timur@codeaurora.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: phy: smsc: fix buffer overflow in memcpy
Date: Tue, 20 Jun 2017 23:46:15 +0200	[thread overview]
Message-ID: <20170620214615.GF12383@lunn.ch> (raw)
In-Reply-To: <20170620204059.790066-1-arnd@arndb.de>

On Tue, Jun 20, 2017 at 10:40:46PM +0200, Arnd Bergmann wrote:
> The memcpy annotation triggers for a fixed-length buffer copy:
> 
> In file included from /git/arm-soc/arch/arm64/include/asm/processor.h:30:0,
>                  from /git/arm-soc/arch/arm64/include/asm/spinlock.h:21,
>                  from /git/arm-soc/include/linux/spinlock.h:87,
>                  from /git/arm-soc/include/linux/seqlock.h:35,
>                  from /git/arm-soc/include/linux/time.h:5,
>                  from /git/arm-soc/include/linux/stat.h:21,
>                  from /git/arm-soc/include/linux/module.h:10,
>                  from /git/arm-soc/drivers/net/phy/smsc.c:20:
> In function 'memcpy',
>     inlined from 'smsc_get_strings' at /git/arm-soc/drivers/net/phy/smsc.c:166:3:
> /git/arm-soc/include/linux/string.h:309:4: error: call to '__read_overflow2' declared with attribute error: detected read beyond size of object passed as 2nd parameter
> 
> Using strncpy instead of memcpy should do the right thing here.

Hi Arnd

You will find this pattern in number of phy drivers:

bcm-phy-lib.c:	   	   memcpy(data + i * ETH_GSTRING_LEN,
marvell.c:			       		   memcpy(data + i * ETH_GSTRING_LEN,
micrel.c:   		memcpy(data + i * ETH_GSTRING_LEN,
smsc.c:				    memcpy(data + i * ETH_GSTRING_LEN,

They probably all need the same fix.

     Andrew

  reply	other threads:[~2017-06-20 21:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-20 20:40 [PATCH] net: phy: smsc: fix buffer overflow in memcpy Arnd Bergmann
2017-06-20 21:46 ` Andrew Lunn [this message]
2017-06-22 15:12 ` David Miller

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=20170620214615.GF12383@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=timur@codeaurora.org \
    /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).