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: <ed65d0a2e49159a85fc47092d0df6bb6@walle.cc>
Date:   Thu, 31 Mar 2022 10:28:04 +0200
From:   Michael Walle <michael@...le.cc>
To:     "Russell King (Oracle)" <linux@...linux.org.uk>
Cc:     Andrew Lunn <andrew@...n.ch>,
        Heiner Kallweit <hkallweit1@...il.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        "David S . Miller" <davem@...emloft.net>,
        Xu Liang <lxu@...linear.com>,
        Alexandre Belloni <alexandre.belloni@...tlin.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH RFC net-next 2/5] net: phy: support indirect c45 access in
 get_phy_c45_ids()

Am 2022-03-30 18:18, schrieb Russell King (Oracle):
> On Wed, Mar 23, 2022 at 11:14:11PM +0100, Michael Walle wrote:
>> I actually had that. But mmd_phy_indirect() doesn't check
>> the return code and neither does the __phy_write_mmd() it
>> actually deliberatly sets "ret = 0". So I wasn't sure. If you
>> are fine with a changed code flow in the error case, then sure.
>> I.e. mmd_phy_indirect() always (try to) do three accesses; with
>> error checks it might end after the first. If you are fine
>> with the error checks, should __phy_write_mmd() also check the
>> last mdiobus_write()?
> 
> The reason for that goes back to
> commit a59a4d1921664da63d801ba477950114c71c88c9
>     phy: add the EEE support and the way to access to the MMD 
> registers.
> 
> and to maintain compatibility with that; if we start checking for
> errors now, we might trigger a kernel regression sadly.

I see that this is the commit which introduced the mmd_phy_indirect()
function, but I don't see why there is no return code checking.
Unlike now, there is a check for the last read (the one who
reads MII_MMD_DATA). That read which might return garbage if any
write has failed before - or if the bus is completely dead,
return an error. Current code will just return 0.

In any case, I don't have a strong opinion here. I just don't
see how that function could be reused while adding error checks
and without making it ugly, so I've just duplicated it.

Maybe something like this:

static int __phy_mmd_indirect_common(struct mii_bus *bus, int prtad,
                                      int devad, int addr,
                                      bool check_rc)
{
         int ret;

         /* Write the desired MMD Devad */
         ret = __mdiobus_write(bus, phy_addr, MII_MMD_CTRL, devad);
         if (check_rc && ret)
                 return ret;

         /* Write the desired MMD register address */
         ret = __mdiobus_write(bus, phy_addr, MII_MMD_DATA, regnum);
         if (check_rc && ret)
                 return ret;

         /* Select the Function : DATA with no post increment */
         ret = __mdiobus_write(bus, phy_addr, MII_MMD_CTRL,
                               devad | MII_MMD_CTRL_NOINCR);
         if (check_rc && ret)
                 return ret;

         return 0;
}

int __phy_mmd_indirect(struct mii_bus *bus, int prtad,
                        int devad, int addr)
{
         return __phy_mmd_indirect_common(bus, prtad, devad,
                                          addr, true);
}

/* some function doc about deliberatly no error checking.. */
void __phy_mmd_indirect_legacy(struct mii_bus *bus, int prtad,
                                int devad, int addr)
{
         __phy_mmd_indirect_common(bus, prtad, devad,
                                   addr, false);
}

should the last two functions be static inline?

-michael

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ