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-next>] [day] [month] [year] [list]
Date:	Tue, 27 Mar 2012 09:25:16 +0800
From:	"Liu Yu" <liuyums@...tor.com.cn>
To:	<netdev@...r.kernel.org>
Subject: Wrong use of MAX_JIFFY_OFFSET?

Hi guys,

I saw a couple of places in current kernel have this kind of code:

> static inline unsigned int elapsed_jiffies_msecs(unsigned long start)
> {
>         unsigned long end = jiffies;
>
>         if (end >= start)
>                return jiffies_to_msecs(end - start);
>
>         return jiffies_to_msecs(end + (MAX_JIFFY_OFFSET - start) + 1);
> }

As you know, jiffies has a type of unsigned long, so if we know which is the
end and
which is the start, then (end - start) can simply figure out how much
jiffies flies,
without worry about the overflow.

Look at the code above, assume that there is just an overflow happening on
jiffies: end=0 and start=~0UL.
Since end < start, then the return value of the function is
jiffies_to_msecs(MAX_JIFFY_OFFSET+2).
But shouldn't the correct value be jiffies_to_msecs(1)?

could someone tell me that am I missing anything?

Thanks,
Yu

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ