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
| ||
|
Message-ID: <20230530121910.05b9f837@kernel.org> Date: Tue, 30 May 2023 12:19:10 -0700 From: Jakub Kicinski <kuba@...nel.org> To: Andrew Lunn <andrew@...n.ch> Cc: Russell King <linux@...linux.org.uk>, Dan Carpenter <dan.carpenter@...aro.org>, Oleksij Rempel <linux@...pel-privat.de>, Heiner Kallweit <hkallweit1@...il.com>, "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org, kernel-janitors@...r.kernel.org Subject: Re: [PATCH net] net: phy: fix a signedness bug in genphy_loopback() On Tue, 30 May 2023 14:39:53 +0200 Andrew Lunn wrote: > > Therefore we should try to fix phy_read_poll_timeout() instead to > > use a local variable like it does for __ret. > > The problem with that is val is supposed to be available to the > caller. I don't know if it is every actually used, but if it is, using > an internal signed variable and then throwing away the sign bit on > return is going to result in similar bugs. This is what I meant FWIW: diff --git a/include/linux/phy.h b/include/linux/phy.h index 7addde5d14c0..829bd57b8794 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1206,10 +1206,13 @@ static inline int phy_read(struct phy_device *phydev, u32 regnum) #define phy_read_poll_timeout(phydev, regnum, val, cond, sleep_us, \ timeout_us, sleep_before_read) \ ({ \ - int __ret = read_poll_timeout(phy_read, val, val < 0 || (cond), \ + int __ret, __val; \ + \ + __ret = read_poll_timeout(phy_read, __val, __val < 0 || (cond), \ sleep_us, timeout_us, sleep_before_read, phydev, regnum); \ - if (val < 0) \ - __ret = val; \ + val = __val; + if (__val < 0) \ + __ret = __val; \ if (__ret) \ phydev_err(phydev, "%s failed: %d\n", __func__, __ret); \ __ret; \ I tried enabling -Wtype-limits but it's _very_ noisy :(
Powered by blists - more mailing lists