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:   Wed, 1 Feb 2017 10:25:21 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Fabian Frederick <fabf@...net.be>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Ingo Molnar <mingo@...nel.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 01/14] locking/atomic: import atomic_dec_not_zero()

On Tue, Jan 31, 2017 at 09:55:08PM +0100, Fabian Frederick wrote:
> Once again it's just about readability:

I feel APIs should be about common use-cases, not about sporadic weird cases.

> "add -1 unless value is zero" looks more complex in code than "dec not zero"
> but maybe it's just a matter of taste :) It it's not the case why would there be
> more sense about having
> atomic_inc_not_zero() globally ?

inc_not_zero() has a very strong use-case, its for lockless refcount
increment. Incrementing a 0 reference count is bad because the object
will be freed and you'll have a use-after-free.

Arguably, once we move reference counting over to its own type, it would
make sense to remove it from atomic, specifically to discourage that use
case.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ