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] [day] [month] [year] [list]
Date:	Tue, 27 Oct 2015 11:34:33 +0200
From:	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:	Vitaly Kuznetsov <vkuznets@...hat.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Rasmus Villemoes <linux@...musvillemoes.dk>,
	Ulf Hansson <ulf.hansson@...aro.org>,
	James Bottomley <JBottomley@...n.com>,
	Kees Cook <keescook@...omium.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] lib/string_helpers.c: don't lose precision in
 string_get_size()

On Tue, 2015-10-27 at 09:36 +0100, Vitaly Kuznetsov wrote:
> Andy Shevchenko <andriy.shevchenko@...ux.intel.com> writes:
> 
> > On Mon, 2015-10-26 at 14:55 +0100, Vitaly Kuznetsov wrote:
> > > string_get_size() loses precision when there is a remainder for
> > > blk_size / divisor[units] and size is big enough. E.g
> > > string_get_size(8192, 4096, STRING_UNITS_10, ...) returns "32.7
> > > MB"
> > > while it is supposed to return "33.5 MB". For some artificial
> > > inputs
> > > the result can be ridiculously wrong, e.g.
> > > string_get_size(3000, 1900, STRING_UNITS_10, ...) returns "3.00
> > > MB"
> > > when "5.70 MB" is expected.

[]

> > > -	int i, j;
> > > -	u32 remainder = 0, sf_cap, exp;
> > > +	int order = 0, j;
> > > +	u64 remainder = 0;
> > > +	u32 sf_cap;
> > >  	char tmp[8];
> > >  	const char *unit;
> > >  
> > >  	tmp[0] = '\0';
> > > -	i = 0;
> > 
> > Maybe leave i naming as is. Your order is not strictly speaking an
> > order, rather 3x order. I will make patch neater.
> > 
> 
> While reading the original function I found meaningless 'i' and 'j'
> here
> a bit consufing but yes, strictly speaking 'i' is a power of
> divisor[units], not 'order' and I don't have a good name for it
> (div_power?). I'll revert back to 'i' in v2.

I agree that names suck, however it might be better to have separate
patch to fix naming.

Rasmus?

-- 
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Intel Finland Oy

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