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: <4B7DD89F.4050003@linux.intel.com>
Date:	Thu, 18 Feb 2010 16:17:35 -0800
From:	"H. Peter Anvin" <hpa@...ux.intel.com>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
CC:	linux-kernel@...r.kernel.org, "H. Peter Anvin" <hpa@...or.com>,
	Arjan van de Ven <arjan@...ux.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
	Christoph Lameter <cl@...ux-foundation.org>,
	Hugh Dickins <hugh.dickins@...cali.co.uk>,
	Rik van Riel <riel@...hat.com>, Ingo Molnar <mingo@...e.hu>,
	Thomas Gleixner <tglx@...utronix.de>
Subject: Re: [PATCH] mm: Make copy_from_user() in migrate.c statically predictable

On 02/18/2010 03:02 PM, Linus Torvalds wrote:
> 
> Hmm. When making simplifications like this, I would really suggest you 
> also move the declaration of the variable itself into the block where it 
> is now used, rather than leaving it be function-wide.
> 
> Yes, it's used in the final condition of the for-loop, but that whole loop 
> is just screwy. The 'err' handling is insane. Sometimes 'err' is a return 
> value form copy_to/from_user, and sometimes it's a errno. The two are 
> _not_ the same thing, they don't even have the same type!
> 
> And 'i' is totally useless too.
> 
> So that whole loop should be rewritten.
> 

OK, I was trying to make the minimal set of changes given the late -rc
status.

> I don't even have page migration enabled, so I haven't even compile-tested 
> this, but wouldn't something like this work? It's smaller, gets rid of two 
> pointless variables, and looks simpler to me. Hmm?

The code definitely looks cleaner, and it's a much more standard
"chunked data loop" form.  Weirdly enough, though, gcc 4.4.2 can't
figure out the copy_from_user() that way... despite having the same
min() structure as my code.

However, if I change it to:

		chunk_nr = nr_pages;
		if (chunk_nr > DO_PAGES_STAT_CHUNK_NR)
			chunk_nr = DO_PAGES_STAT_CHUNK_NR;

... then it works!

Overall, it looks like gcc is rather fragile with regards to its ability
to constant-propagate.  It's probably no coincidence that chunked loops
is the place where we really have problems with this kind of stuff.

Updated patch, which compile-tests for me, attached.

	-hpa

View attachment "0001-mm-Make-copy_from_user-in-migrate.c-statically-predi.patch" of type "text/x-patch" (2815 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ