From: Al Viro <viro@zeniv.linux.org.uk>
To: Matthew Wilcox <willy@infradead.org>
Cc: Kees Cook <keescook@chromium.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: Alloc refcount increments to fail
Date: Thu, 2 May 2019 16:46:44 +0100 [thread overview]
Message-ID: <20190502154644.GV23075@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20190502152621.GB18948@bombadil.infradead.org>
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?
next prev parent reply other threads:[~2019-05-02 15:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-02 15:26 Matthew Wilcox
2019-05-02 15:46 ` Al Viro [this message]
2019-05-02 17:37 ` Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190502154644.GV23075@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®