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: <20100408182654.GA31578@elte.hu>
Date:	Thu, 8 Apr 2010 20:26:54 +0200
From:	Ingo Molnar <mingo@...e.hu>
To:	Andreas Schwab <schwab@...hat.com>
Cc:	Linus Torvalds <torvalds@...ux-foundation.org>,
	linux-kernel@...r.kernel.org,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Mike Galbraith <efault@....de>,
	Thomas Gleixner <tglx@...utronix.de>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Anton Blanchard <anton@...ba.org>
Subject: Re: [GIT PULL] scheduler fix


* Andreas Schwab <schwab@...hat.com> wrote:

> Linus Torvalds <torvalds@...ux-foundation.org> writes:
> 
> > On Thu, 8 Apr 2010, Ingo Molnar wrote:
> >>  
> >> -	if (len < nr_cpu_ids)
> >> +	if ((len * BITS_PER_BYTE) < nr_cpu_ids)
> >>  		return -EINVAL;
> >
> > Not that it really matters, but this will now fail for no good reason if 
> > you pass it a half-gigabyte area due to overflow.
> 
> Which can easily be avoided.
> 
> 	if (len < DIV_ROUND_UP(nr_cpu_ids, BITS_PER_BYTE))

nr_cpu_ids is a signed integer which turns the DIV_ROUND_UP into a somewhat 
suboptimal instruction sequence. (havent checked it though)

So i'd suggest changing nr_cpu_ids to unsigned int [unless there's some strong 
reason to have it signed] plus doing something like:

	if (len < (nr_cpu_ids >> BITS_PER_BYTE_BITS))

ought to both result in better code and should be more readable. We'd have to 
add:

  #define BITS_PER_BYTE_BITS 3

to linux/bitops.h.

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