[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190502154644.GV23075@ZenIV.linux.org.uk>
Date: Thu, 2 May 2019 16:46:44 +0100
From: Al Viro <viro@...iv.linux.org.uk>
To: Matthew Wilcox <willy@...radead.org>
Cc: Kees Cook <keescook@...omium.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>, linux-kernel@...r.kernel.org
Subject: Re: Alloc refcount increments to fail
On Thu, May 02, 2019 at 08:26:21AM -0700, Matthew Wilcox wrote:
> +/**
> + * refcount_try_inc - Increment a refcount if it's below INT_MAX
> + * @r: the refcount to increment
> + *
> + * Avoid the counter saturating by declining to increment the counter
> + * if it is more than halfway to saturation.
> + */
> +static inline __must_check bool refcount_try_inc(refcount_t *r)
> +{
> + if (refcount_read(r) < 0)
> + return false;
> + refcount_inc(r);
> + return true;
> +}
So two of those in parallel with have zero protection, won't they?
Powered by blists - more mailing lists