lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 11 Feb 2014 15:54:10 +0000
From:	David Laight <David.Laight@...LAB.COM>
To:	'Eric Dumazet' <eric.dumazet@...il.com>,
	Francois-Xavier Le Bail <fx.lebail@...oo.com>
CC:	NETDEV <netdev@...r.kernel.org>, David Miller <davem@...emloft.net>
Subject: RE: [PATCH] net: rtnetlink: fix correct size given to memset

From: Eric Dumazet
> On Tue, 2014-02-11 at 15:06 +0100, Francois-Xavier Le Bail wrote:
> > Find by cppcheck:
> > [net/core/rtnetlink.c:1842]: (warning) Using size of pointer linkinfo instead of size of its data.
> >
> > Signed-off-by: Francois-Xavier Le Bail <fx.lebail@...oo.com>
> > ---
> >
> > The diagnosis of cppcheck seems relevant.
> >
> >  net/core/rtnetlink.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> > index 048dc8d..9a5dbf1 100644
> > --- a/net/core/rtnetlink.c
> > +++ b/net/core/rtnetlink.c
> > @@ -1839,7 +1839,7 @@ replay:
> >  		if (err < 0)
> >  			return err;
> >  	} else
> > -		memset(linkinfo, 0, sizeof(linkinfo));
> > +		memset(linkinfo, 0, sizeof(*linkinfo));
> >
> >  	if (linkinfo[IFLA_INFO_KIND]) {
> >  		nla_strlcpy(kind, linkinfo[IFLA_INFO_KIND], sizeof(kind));
> 
> 
> This is absolutely wrong.
> 
> 	struct nlattr *linkinfo[IFLA_INFO_MAX+1];
> 
> sizeof(linkinfo) is totally appropriate
> 
> sizeof(*linkinfo) is equal to sizeof(void *), and this is not what we
> need here.

I guess that changing it to:
	memset(&linkinfo, 0, sizeof(linkinfo));

might make the tool happy, but it really ought to be taught about arrays.

	David

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ