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:	Thu, 02 Feb 2012 22:27:34 +0800
From:	Cong Wang <xiyou.wangcong@...il.com>
To:	Arnd Bergmann <arnd@...db.de>
CC:	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	Prarit Bhargava <prarit@...hat.com>,
	Greg Kroah-Hartman <greg@...ah.com>,
	Dave Young <dyoung@...hat.com>
Subject: Re: [PATCH 1/2] lkdtm: use atomic_t to replace count_lock

On 02/02/2012 09:44 PM, Arnd Bergmann wrote:
> On Thursday 02 February 2012, Cong Wang wrote:
>>> In order to have an atomic here, you have to use a loop around
>>> atomic_cmpxchg, like
>>>
>>>
>>>        int old, new;
>>>        old = atomic_read(&count);
>>>        do {
>>>                new = old ? old - 1 : cpoint_count;
>>>                old = cmpxchg(&count, old, new);
>>>        } while (old != new);
>>>
>>> I suppose you could also just keep the spinlock and move lkdtm_do_action()
>>> outside of it?
>>
>> If we still need spinlock, I think we don't need to bother atomic_t at all.
>
> Yes, it's one or the other: If you use the cmpxchg loop, you don't need a
> spinlock and vice versa.
>

The cmpxchg loop is for comparing and assigning to 'count', but still 
there is a printk() above that needs to read 'count'. Combining these 
two operations means we have to use a spinlock, correct? Because there 
is a chance that another process could change 'count' in between.

Thanks.
--
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