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]
Message-ID: <4583183.OhVBZdlllx@pc-42>
Date:   Mon, 21 Oct 2019 08:21:45 +0000
From:   Jerome Pouiller <Jerome.Pouiller@...abs.com>
To:     "driverdev-devel@...uxdriverproject.org" 
        <driverdev-devel@...uxdriverproject.org>
CC:     Dan Carpenter <dan.carpenter@...cle.com>,
        Jules Irenge <jbi.octave@...il.com>,
        "devel@...verdev.osuosl.org" <devel@...verdev.osuosl.org>,
        "outreachy-kernel@...glegroups.com" 
        <outreachy-kernel@...glegroups.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>
Subject: Re: [PATCH v1 1/5] staging: wfx: fix warnings of no space is
 necessary

On Saturday 19 October 2019 16:24:43 CEST Dan Carpenter wrote:
> On Sat, Oct 19, 2019 at 03:07:15PM +0100, Jules Irenge wrote:
> > diff --git a/drivers/staging/wfx/bh.c b/drivers/staging/wfx/bh.c
> > index 3355183fc86c..573216b08042 100644
> > --- a/drivers/staging/wfx/bh.c
> > +++ b/drivers/staging/wfx/bh.c
> > @@ -69,13 +69,13 @@ static int rx_helper(struct wfx_dev *wdev, size_t read_len, int *is_cnf)
> >       if (wfx_data_read(wdev, skb->data, alloc_len))
> >               goto err;
> >
> > -     piggyback = le16_to_cpup((u16 *) (skb->data + alloc_len - 2));
> > +     piggyback = le16_to_cpup((u16 *)(skb->data + alloc_len - 2));
> >       _trace_piggyback(piggyback, false);
> >
> > -     hif = (struct hif_msg *) skb->data;
> > +     hif = (struct hif_msg *)skb->data;
> >       WARN(hif->encrypted & 0x1, "unsupported encryption type");
> >       if (hif->encrypted == 0x2) {
> > -             if (wfx_sl_decode(wdev, (void *) hif)) {
> > +             if (wfx_sl_decode(wdev, (void *)hif)) {
> 
> In the future you may want to go through and remove the (void *) casts.
> It's not required here.
> 
> > diff --git a/drivers/staging/wfx/bus_spi.c b/drivers/staging/wfx/bus_spi.c
> > index f65f7d75e731..effd07957753 100644
> > --- a/drivers/staging/wfx/bus_spi.c
> > +++ b/drivers/staging/wfx/bus_spi.c
> > @@ -90,7 +90,7 @@ static int wfx_spi_copy_to_io(void *priv, unsigned int addr,
> >       struct wfx_spi_priv *bus = priv;
> >       u16 regaddr = (addr << 12) | (count / 2);
> >       // FIXME: use a bounce buffer
> > -     u16 *src16 = (void *) src;
> > +     u16 *src16 = (void *)src;
> 
> Here we are just getting rid of the constness.  Apparently we are doing
> that so we can modify it without GCC pointing out the bug!!  I don't
> know the code but this seems very wrong.

Hello Dan, Jules,

Indeed, this code should be improved.

Each u16 from src is byte-swapped before to be sent to SPI and restored
before to return from the function:

	for (i = 0; i < count / 2; i++)
		swab16s(&src16[i]);
	[...]
	spi_sync(bus->func, &m);
   [...]
	for (i = 0; i < count / 2; i++)
		swab16s(&src16[i]);

So, src is same than original, but it is not const.

This is exactly the purpose of the FIXME just before the cast: "use a
bounce buffer". However, I did not yet make this change because I worry
about a possible performance penalty.

-- 
Jérôme Pouiller

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ