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
| ||
|
Date: Tue, 15 Dec 2015 08:15:18 -0800 From: Guenter Roeck <linux@...ck-us.net> To: Jisheng Zhang <jszhang@...vell.com>, wim@...ana.be Cc: linux-watchdog@...r.kernel.org, linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org, sebastian.hesselbarth@...il.com Subject: Re: [PATCH] watchdog: dw_wdt: fix signedness bug in dw_wdt_top_in_seconds() On 12/15/2015 06:25 AM, Jisheng Zhang wrote: > On 64bit platforms, "(1 << (16 + top)) / clk_get_rate(dw_wdt.clk)" is > sign-extended to 64bit then converted to unsigned 64bit, finally divide > the clk rate. If the top is the maximum TOP i.e 15, "(1 << (16 +15))" > will be sign-extended to 0xffffffff80000000, then converted to unsigned > 0xffffffff80000000, which is a huge number, thus the final result is > wrong. > > We fix this issue by giving usigned value(1U in this case) at first. > > Let's assume clk rate is 25MHZ, > Before the patch: > dw_wdt_top_in_seconds(15) = -864612050 > > After the patch: > dw_wdt_top_in_seconds(15) = 85 > > Signed-off-by: Jisheng Zhang <jszhang@...vell.com> Nice catch. Reviewed-by: Guenter Roeck <linux@...ck-us.net> > --- > drivers/watchdog/dw_wdt.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c > index 6ea0634..8fefa4ad 100644 > --- a/drivers/watchdog/dw_wdt.c > +++ b/drivers/watchdog/dw_wdt.c > @@ -81,7 +81,7 @@ static inline int dw_wdt_top_in_seconds(unsigned top) > * There are 16 possible timeout values in 0..15 where the number of > * cycles is 2 ^ (16 + i) and the watchdog counts down. > */ > - return (1 << (16 + top)) / clk_get_rate(dw_wdt.clk); > + return (1U << (16 + top)) / clk_get_rate(dw_wdt.clk); > } > > static int dw_wdt_get_top(void) > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@...r.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists