From: Tejun Heo <tj@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, dougmill@linux.vnet.ibm.com
Subject: [GIT PULL] percpu fix for v4.10-rc6
Date: Tue, 31 Jan 2017 11:55:37 -0500 [thread overview]
Message-ID: <20170131165537.GC23970@htj.duckdns.org> (raw)
Hello,
Douglas found and fixed a ref leak bug in percpu_ref_tryget[_live]().
The bug is caused by storing the return value of
atomic_long_inc_not_zero() into an int temp variable before returning
it as a bool. The interim cast to int loses the upper bits and can
lead to false negatives. As percpu_ref uses a high bit to mark a
draining counter, this can happen relatively easily. Fixed by using
bool for the temp variable.
Thanks.
The following changes since commit 1b1bc42c1692e9b62756323c675a44cb1a1f9dbd:
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (2017-01-27 12:54:16 -0800)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu.git for-4.10-fixes
for you to fetch changes up to 966d2b04e070bc040319aaebfec09e0144dc3341:
percpu-refcount: fix reference leak during percpu-atomic transition (2017-01-28 07:49:42 -0500)
----------------------------------------------------------------
Douglas Miller (1):
percpu-refcount: fix reference leak during percpu-atomic transition
include/linux/percpu-refcount.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h
index 1c7eec0..3a481a4 100644
--- a/include/linux/percpu-refcount.h
+++ b/include/linux/percpu-refcount.h
@@ -204,7 +204,7 @@ static inline void percpu_ref_get(struct percpu_ref *ref)
static inline bool percpu_ref_tryget(struct percpu_ref *ref)
{
unsigned long __percpu *percpu_count;
- int ret;
+ bool ret;
rcu_read_lock_sched();
@@ -238,7 +238,7 @@ static inline bool percpu_ref_tryget(struct percpu_ref *ref)
static inline bool percpu_ref_tryget_live(struct percpu_ref *ref)
{
unsigned long __percpu *percpu_count;
- int ret = false;
+ bool ret = false;
rcu_read_lock_sched();
--
tejun
next reply other threads:[~2017-01-31 16:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-31 16:55 Tejun Heo [this message]
2017-01-31 21:32 ` [GIT PULL] percpu fix for v4.10-rc6 Linus Torvalds
2017-01-31 21:41 ` Linus Torvalds
2017-01-31 22:11 ` Tejun Heo
2017-01-31 22:17 ` Linus Torvalds
2017-01-31 22:27 ` Tejun Heo
2017-02-01 0:32 ` Linus Torvalds
2017-02-01 7:56 ` David Howells
[not found] ` <CA+55aFyiy2jD80RTbsm3C=G5ifgtj8GQHqFwaYZM+ktgx1embA@mail.gmail.com>
[not found] ` <CA+55aFxRLP_qPBXoLomxj-VYG-R=rKJE8KZ_h4NQ4g74gpNEWQ@mail.gmail.com>
[not found] ` <CA+55aFz8TFRykr0qNBjNbK+kavUdbGOm4huf5XhPLQcy0tMyLw@mail.gmail.com>
2017-02-01 10:00 ` David Howells
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=20170131165537.GC23970@htj.duckdns.org \
--to=tj@kernel.org \
--cc=dougmill@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.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