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]
Date:	Tue, 15 Nov 2011 13:51:34 +0200
From:	Pekka Enberg <penberg@...nel.org>
To:	Pavel Emelyanov <xemul@...allels.com>
Cc:	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Cyrill Gorcunov <gorcunov@...nvz.org>,
	Glauber Costa <glommer@...allels.com>,
	Andi Kleen <andi@...stfloor.org>, Tejun Heo <tj@...nel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Matt Helsley <matthltc@...ibm.com>
Subject: Re: [PATCH 1/4] Routine for generating an safe ID for kernel pointer

On Tue, Nov 15, 2011 at 1:44 PM, Pavel Emelyanov <xemul@...allels.com> wrote:
>>> +unsigned long gen_object_id(void *ptr)
>>> +{
>>> +       if (!ptr)
>>> +               return 0;
>>> +
>>> +       if (unlikely(!ptr_poison)) {
>>> +               spin_lock(&ptr_poison_lock);
>>> +               if (!ptr_poison)
>>> +                       get_random_bytes(&ptr_poison, sizeof(ptr_poison));
>>> +               spin_unlock(&ptr_poison_lock);
>>> +       }
>>> +
>>> +       return ((unsigned long)ptr) ^ ptr_poison;
>>> +}
>>
>> You could put this in mm/util.c. Wouldn't it make sense to separate
>> the initialization and use late_initcall() to call it?
>
> OK, will put to util.c
>
> About the initialization - I will put the sanity check about poison being not 0 on
> get_object_id() anyway, so what's the point in separate initialization?

You no longer need the spinlock and you get rid of the potential
double initialization problem because you're not holding the spinlock
when you check for ptr_poisson being zero.

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