[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4F197F73.3010000@zytor.com>
Date: Fri, 20 Jan 2012 06:51:31 -0800
From: "H. Peter Anvin" <hpa@...or.com>
To: Cyrill Gorcunov <gorcunov@...il.com>
CC: "Eric W. Biederman" <ebiederm@...ssion.com>,
Pavel Emelyanov <xemul@...allels.com>,
KOSAKI Motohiro <kosaki.motohiro@...il.com>, david@...g.hm,
Alexey Dobriyan <adobriyan@...il.com>,
LKML <linux-kernel@...r.kernel.org>,
Andrey Vagin <avagin@...nvz.org>, Ingo Molnar <mingo@...e.hu>,
Thomas Gleixner <tglx@...utronix.de>,
Glauber Costa <glommer@...allels.com>,
Andi Kleen <andi@...stfloor.org>, Tejun Heo <tj@...nel.org>,
Matt Helsley <matthltc@...ibm.com>,
Pekka Enberg <penberg@...nel.org>,
Eric Dumazet <eric.dumazet@...il.com>,
Vasiliy Kulikov <segoon@...nwall.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Valdis.Kletnieks@...edu
Subject: Re: [RFC] syscalls, x86: Add __NR_kcmp syscall
On 01/20/2012 01:02 AM, Cyrill Gorcunov wrote:
> On Fri, Jan 20, 2012 at 12:40:08PM +0400, Cyrill Gorcunov wrote:
> ...
>> +
>> +static __init int kcmp_cookie_init(void)
>> +{
>> + int i, j;
>> +
>> + for (i = 0; i < KCMP_TYPES; i++) {
>> + for (j = 0; j < 2; j++) {
>> + get_random_bytes(&cookies[i][j], sizeof(cookies[i][j]));
>> +
>> + if (cookies[i][j])
>> + continue;
>> +
>> + /*
>> + * This is impossible case but just to be sure.
>> + */
>> + cookies_valid = false;
>> + WARN_ONCE(1, "Can't get random bytes for k-pointers\n");
>> + }
>> + }
>> +
>> + cookies_valid = true;
>
> darn, this string of course should be on top,
> i'll update don't complain on this nit.
>
This code is wrong. You will have a zero cookie, legitimately, once in
2^32 or 2^64 attempts, depending on the bitness.
The other thing is that for the multiplicative cookie you should OR in
the value (~(~0UL >> 1) | 1) in order to make sure that the value is (a)
large and (b) odd.
-hpa
--
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel. I don't speak on their behalf.
--
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