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] [day] [month] [year] [list]
Message-ID: <20200714195456.GB14742@blackclown>
Date:   Wed, 15 Jul 2020 01:24:56 +0530
From:   Suraj Upadhyay <usuraj35@...il.com>
To:     Joe Perches <joe@...ches.com>
Cc:     Dan Carpenter <dan.carpenter@...cle.com>,
        GR-Linux-NIC-Dev@...vell.com, gregkh@...uxfoundation.org,
        devel@...verdev.osuosl.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 6/6] staging: qlge: qlge_ethtool: Remove one byte memset.

On Tue, Jul 14, 2020 at 12:22:05PM -0700, Joe Perches wrote:
> On Wed, 2020-07-15 at 00:36 +0530, Suraj Upadhyay wrote:
> > On Tue, Jul 14, 2020 at 11:57:23AM -0700, Joe Perches wrote:
> > > On Mon, 2020-07-13 at 17:17 +0300, Dan Carpenter wrote:
> > > > On Mon, Jul 13, 2020 at 05:52:22PM +0530, Suraj Upadhyay wrote:
> > > > > Use direct assignment instead of using memset with just one byte as an
> > > > > argument.
> > > > > Issue found by checkpatch.pl.
> > > > > 
> > > > > Signed-off-by: Suraj Upadhyay <usuraj35@...il.com>
> > > > > ---
> > > > > Hii Maintainers,
> > > > > 	Please correct me if I am wrong here.
> > > > > ---
> > > > > 
> > > > >  drivers/staging/qlge/qlge_ethtool.c | 4 ++--
> > > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > > 
> > > > > diff --git a/drivers/staging/qlge/qlge_ethtool.c b/drivers/staging/qlge/qlge_ethtool.c
> > > > > index 16fcdefa9687..d44b2dae9213 100644
> > > > > --- a/drivers/staging/qlge/qlge_ethtool.c
> > > > > +++ b/drivers/staging/qlge/qlge_ethtool.c
> > > > > @@ -516,8 +516,8 @@ static void ql_create_lb_frame(struct sk_buff *skb,
> > > > >  	memset(skb->data, 0xFF, frame_size);
> > > > >  	frame_size &= ~1;
> > > > >  	memset(&skb->data[frame_size / 2], 0xAA, frame_size / 2 - 1);
> > > > > -	memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
> > > > > -	memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
> > > > > +	skb->data[frame_size / 2 + 10] = (unsigned char)0xBE;
> > > > > +	skb->data[frame_size / 2 + 12] = (unsigned char)0xAF;
> > > > 
> > > > Remove the casting.
> > > > 
> > > > I guess this is better than the original because now it looks like
> > > > ql_check_lb_frame().  It's still really weird looking though.
> > > 
> > > There are several of these in the intel drivers too:
> > > 
> > > drivers/net/ethernet/intel/e1000/e1000_ethtool.c:       memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
> > > drivers/net/ethernet/intel/e1000/e1000_ethtool.c:       memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
> > > drivers/net/ethernet/intel/e1000e/ethtool.c:    memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
> > > drivers/net/ethernet/intel/e1000e/ethtool.c:    memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
> > > drivers/net/ethernet/intel/igb/igb_ethtool.c:   memset(&skb->data[frame_size + 10], 0xBE, 1);
> > > drivers/net/ethernet/intel/igb/igb_ethtool.c:   memset(&skb->data[frame_size + 12], 0xAF, 1);
> > > drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c:       memset(&skb->data[frame_size + 10], 0xBE, 1);
> > > drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c:       memset(&skb->data[frame_size + 12], 0xAF, 1);
> > > drivers/staging/qlge/qlge_ethtool.c:    memset(&skb->data[frame_size / 2 + 10], 0xBE, 1);
> > > drivers/staging/qlge/qlge_ethtool.c:    memset(&skb->data[frame_size / 2 + 12], 0xAF, 1);
> > 
> > Thanks to point this out,
> > 	I will be sending a patchset for that soon.
> 
> 
> It _might_ be useful to create and use a standard
> mechanism for the loopback functions:
> 
> 	<foo>create_lbtest_frame
> and
> 	<foo>check_lbtest_frame
> 
> Maybe use something like:
> 
> 	ether_loopback_frame_create
> and
> 	ether_loopback_frame_check
> 
I thought about it  but then again the fram_size is sometimes divided by two

e.g. `frame_size /= 2;` or `frame_size >>= 1;`.

and sometimes it is subtracted by one. i.e. `frame_size &= ~1;`.

Anyway, I sent my layman patchset to the lkml and intel maintainers.

Forgive my brevity.

Thanks, 

Suraj Upadhyay. 

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ