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: <CAK8P3a0+dD99CfuZYHkZNHjmZhvZqGt-j=X1v=N7DH4Ac_OAMQ@mail.gmail.com>
Date:   Thu, 18 Feb 2021 19:32:37 +0100
From:   Arnd Bergmann <arnd@...nel.org>
To:     Muhammad Usama Anjum <musamaanjum@...il.com>
Cc:     Greg KH <gregkh@...uxfoundation.org>,
        Lee Jones <lee.jones@...aro.org>,
        Johannes Berg <johannes@...solutions.net>,
        Arnd Bergmann <arnd@...db.de>,
        Jakub Kicinski <kuba@...nel.org>,
        "Gustavo A. R. Silva" <gustavoars@...nel.org>,
        wanghai38@...wei.com, driverdevel <devel@...verdev.osuosl.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] staging: wimax/i2400m: don't change the endianness of one
 byte variable

On Thu, Feb 18, 2021 at 10:54 AM Muhammad Usama Anjum
<musamaanjum@...il.com> wrote:
>
> On Thu, 2021-02-18 at 10:40 +0100, Greg KH wrote:
> > On Thu, Feb 18, 2021 at 02:21:54PM +0500, Muhammad Usama Anjum wrote:
> > > It is wrong to change the endianness of a variable which has just one
> > > byte size.
> > >
> > > Sparse warnings fixed:
> > > drivers/staging//wimax/i2400m/control.c:452:17: warning: cast to restricted __le32
> > > drivers/staging//wimax/i2400m/control.c:452:17: warning: cast to restricted __le32
> > > drivers/staging//wimax/i2400m/op-rfkill.c:159:14: warning: cast to restricted __le32
> > > drivers/staging//wimax/i2400m/op-rfkill.c:160:14: warning: cast to restricted __le32
> > >
> > > Signed-off-by: Muhammad Usama Anjum <musamaanjum@...il.com>
> > > ---
> > >  drivers/staging/wimax/i2400m/control.c   | 4 ++--
> > >  drivers/staging/wimax/i2400m/op-rfkill.c | 4 ++--
> > >  2 files changed, 4 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/staging/wimax/i2400m/control.c b/drivers/staging/wimax/i2400m/control.c
> > > index 1e270b2101e8..b6b2788af162 100644
> > > --- a/drivers/staging/wimax/i2400m/control.c
> > > +++ b/drivers/staging/wimax/i2400m/control.c
> > > @@ -452,8 +452,8 @@ void i2400m_report_state_parse_tlv(struct i2400m *i2400m,
> > >             d_printf(2, dev, "%s: RF status TLV "
> > >                      "found (0x%04x), sw 0x%02x hw 0x%02x\n",
> > >                      tag, I2400M_TLV_RF_STATUS,
> > > -                    le32_to_cpu(rfss->sw_rf_switch),
> > > -                    le32_to_cpu(rfss->hw_rf_switch));
> > > +                    rfss->sw_rf_switch,
> > > +                    rfss->hw_rf_switch);
> >
> > What do you mean by "one byte"?  This is a le32 sized variable, right?
> > If not, why isn't the le32_to_cpu() call complaining?
>
> These two variables are of type _u8, one byte.
>         __u8 sw_rf_switch;
>         __u8 hw_rf_switch;
> They aren't of type __le32. le32_to_cpu() macro should have
> complained. But it isn't complaining. It seems like whatever we pass
> to this macro, it casts it to __le32 forcefully (it seems like wrong).
> So we'll never get any complain from this macro directly. But we are
> getting complain from the sparse.
>
> For big endian:
> #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
> For little endian:
> #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))

Right, it seems this driver has been broken on big-endian ever since
it was first merged in 2008.

        Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ