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: <AM9PR04MB8397C6E7F7DB30B4AD1F65D3963B9@AM9PR04MB8397.eurprd04.prod.outlook.com>
Date:   Fri, 4 Jun 2021 13:34:55 +0000
From:   Claudiu Manoil <claudiu.manoil@....com>
To:     Heiner Kallweit <hkallweit1@...il.com>,
        Michael Walle <michael@...le.cc>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC:     "David S . Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Vladimir Oltean <vladimir.oltean@....com>
Subject: RE: [PATCH net-next] net: enetc: use get/put_unaligned() for mac
 address handling


> -----Original Message-----
> From: Heiner Kallweit <hkallweit1@...il.com>
> Sent: Friday, June 4, 2021 3:44 PM
[...]
> 
> On 04.06.2021 14:30, Michael Walle wrote:
> > The supplied buffer for the MAC address might not be aligned. Thus
> > doing a 32bit (or 16bit) access could be on an unaligned address. For
> > now, enetc is only used on aarch64 which can do unaligned accesses, thus
> > there is no error. In any case, be correct and use the get/put_unaligned()
> > helpers.
> >
> > Signed-off-by: Michael Walle <michael@...le.cc>
> > ---
> >  drivers/net/ethernet/freescale/enetc/enetc_pf.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
> b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
> > index 31274325159a..a96d2acb5e11 100644
> > --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c
> > +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c
> > @@ -1,6 +1,7 @@
> >  // SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
> >  /* Copyright 2017-2019 NXP */
> >
> > +#include <asm/unaligned.h>
> >  #include <linux/mdio.h>
> >  #include <linux/module.h>
> >  #include <linux/fsl/enetc_mdio.h>
> > @@ -17,15 +18,15 @@ static void enetc_pf_get_primary_mac_addr(struct
> enetc_hw *hw, int si, u8 *addr)
> >  	u32 upper = __raw_readl(hw->port + ENETC_PSIPMAR0(si));
> >  	u16 lower = __raw_readw(hw->port + ENETC_PSIPMAR1(si));
> >
> > -	*(u32 *)addr = upper;
> > -	*(u16 *)(addr + 4) = lower;
> > +	put_unaligned(upper, (u32 *)addr);
> > +	put_unaligned(lower, (u16 *)(addr + 4));
> 
> I think you want to write little endian, therefore on a BE platform
> this code may be wrong. Better use put_unaligned_le32?
> By using these versions of the unaligned helpers you could also
> remove the pointer cast.
> 

+1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ