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: <20080310193955.9f30bf20.akpm@linux-foundation.org>
Date:	Mon, 10 Mar 2008 19:39:55 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Andi Kleen <andi@...stfloor.org>
Cc:	Ingo Molnar <mingo@...e.hu>, tglx@...utronix.de,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH REPOST for 2.6.25] Use an own random generator for
 pageattr-test.c

On Tue, 11 Mar 2008 02:30:14 +0100 Andi Kleen <andi@...stfloor.org> wrote:

> Use an own random generator for pageattr-test.c
> 
> [Repost. Please ack/nack. This is a bug fix and imho a .25 late merge 
> candidate because it fixes a subtle bug]

An Ingo/Thomas thing.

> pageattr-test attempts to be repeatable and uses srandom32 to get a 
> repeatable random number sequence.
> 
> Using srandom32() wasn't a good idea for various reasons:
> - it is per cpu and if the cpu changes on a preemptible kernel it gets lost
> - networking and random32 puts in some own state
> - srandom32() does not actually reset the state, but just adds bits to 
> it
> 
> Instead use a very simple private standard rnd that gives repeatable
> results. I took the reference rand() from ISO-C.
> 
> Signed-off-by: Andi Kleen <ak@...e.de>
> 
> ---
>  arch/x86/mm/pageattr-test.c |   11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> Index: linux/arch/x86/mm/pageattr-test.c
> ===================================================================
> --- linux.orig/arch/x86/mm/pageattr-test.c
> +++ linux/arch/x86/mm/pageattr-test.c
> @@ -101,6 +101,14 @@ static int print_split(struct split_stat
>  static unsigned long addr[NTEST];
>  static unsigned int len[NTEST];
>  
> +static int next = 100;
> +
> +static unsigned my_rand(void)
> +{
> +	next = next * 1103515245 + 12345;
> +	return next;
> +}

`next' should be local to my_rand().

>  /* Change the global bit on random pages in the direct mapping */
>  static int pageattr_test(void)
>  {
> @@ -123,10 +131,9 @@ static int pageattr_test(void)
>  	memset(bm, 0, (max_pfn_mapped + 7) / 8);
>  
>  	failed += print_split(&sa);
> -	srandom32(100);
>  
>  	for (i = 0; i < NTEST; i++) {
> -		unsigned long pfn = random32() % max_pfn_mapped;
> +		unsigned long pfn = my_rand() % max_pfn_mapped;
>  
>  		addr[i] = (unsigned long)__va(pfn << PAGE_SHIFT);
>  		len[i] = random32() % 100;
--
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