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: <alpine.LFD.2.11.1505061604390.7750@knanqh.ubzr>
Date:	Wed, 6 May 2015 16:11:43 -0400 (EDT)
From:	Nicolas Pitre <nicolas.pitre@...aro.org>
To:	John Stultz <john.stultz@...aro.org>
cc:	linux-kernel@...r.kernel.org, Thomas Gleixner <tglx@...utronix.de>,
	Josh Boyer <jwboyer@...hat.com>,
	One Thousand Gnomes <gnomes@...rguk.ukuu.org.uk>,
	Trevor Cordes <trevor@...nopolis.ca>
Subject: Re: [RFC][PATCH v2] ktime: Fix ktime_divns to do signed division

On Wed, 6 May 2015, John Stultz wrote:

> It was noted that the 32bit implementation of ktime_divns()
> was doing unsigned division and didn't properly handle
> negative values.
> 
> This patch fixes the problem by checking and preserving
> the sign bit, and then reapplying it if appropriate after
> the division, it also changes the return type to a s64
> to make it more obvious this is expected.
> 
[...]
> 
> -# define ktime_divns(kt, div)          (u64)((kt).tv64 / (div))
> +static inline s64 ktime_divns(const ktime_t kt, s64 div)
> +{
> +	/*
> +	 * 32-bit implementation cannot handle negative divisors,
> +	 * so catch them on 64bit as well.
> +	 */
> +	BUG_ON(div < 0);
> +	return (u64)((kt).tv64 / (div))

You forgot to remove the u64 cast?

Is there a reason why it was there originally?


Nicolas
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ