[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <158634845677.28353.8519164850978803726.tip-bot2@tip-bot2>
Date: Wed, 08 Apr 2020 12:20:56 -0000
From: "tip-bot2 for Jann Horn" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Kees Cook <keescook@...omium.org>, Will Deacon <will@...nel.org>,
Jann Horn <jannh@...gle.com>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>, x86 <x86@...nel.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: [tip: locking/urgent] locking/refcount: Document interaction with
PID_MAX_LIMIT
The following commit has been merged into the locking/urgent branch of tip:
Commit-ID: a13f58a0cafa7b0416a2898bc3b0defbb305d108
Gitweb: https://git.kernel.org/tip/a13f58a0cafa7b0416a2898bc3b0defbb305d108
Author: Jann Horn <jannh@...gle.com>
AuthorDate: Tue, 03 Mar 2020 11:54:27 +01:00
Committer: Ingo Molnar <mingo@...nel.org>
CommitterDate: Wed, 08 Apr 2020 12:05:07 +02:00
locking/refcount: Document interaction with PID_MAX_LIMIT
Document the circumstances under which refcount_t's saturation mechanism
works deterministically.
Acked-by: Kees Cook <keescook@...omium.org>
Acked-by: Will Deacon <will@...nel.org>
Signed-off-by: Jann Horn <jannh@...gle.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
Signed-off-by: Ingo Molnar <mingo@...nel.org>
Link: https://lkml.kernel.org/r/20200303105427.260620-1-jannh@google.com
---
include/linux/refcount.h | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/include/linux/refcount.h b/include/linux/refcount.h
index 0ac50cf..0e3ee25 100644
--- a/include/linux/refcount.h
+++ b/include/linux/refcount.h
@@ -38,11 +38,24 @@
* atomic operations, then the count will continue to edge closer to 0. If it
* reaches a value of 1 before /any/ of the threads reset it to the saturated
* value, then a concurrent refcount_dec_and_test() may erroneously free the
- * underlying object. Given the precise timing details involved with the
- * round-robin scheduling of each thread manipulating the refcount and the need
- * to hit the race multiple times in succession, there doesn't appear to be a
- * practical avenue of attack even if using refcount_add() operations with
- * larger increments.
+ * underlying object.
+ * Linux limits the maximum number of tasks to PID_MAX_LIMIT, which is currently
+ * 0x400000 (and can't easily be raised in the future beyond FUTEX_TID_MASK).
+ * With the current PID limit, if no batched refcounting operations are used and
+ * the attacker can't repeatedly trigger kernel oopses in the middle of refcount
+ * operations, this makes it impossible for a saturated refcount to leave the
+ * saturation range, even if it is possible for multiple uses of the same
+ * refcount to nest in the context of a single task:
+ *
+ * (UINT_MAX+1-REFCOUNT_SATURATED) / PID_MAX_LIMIT =
+ * 0x40000000 / 0x400000 = 0x100 = 256
+ *
+ * If hundreds of references are added/removed with a single refcounting
+ * operation, it may potentially be possible to leave the saturation range; but
+ * given the precise timing details involved with the round-robin scheduling of
+ * each thread manipulating the refcount and the need to hit the race multiple
+ * times in succession, there doesn't appear to be a practical avenue of attack
+ * even if using refcount_add() operations with larger increments.
*
* Memory ordering
* ===============
Powered by blists - more mailing lists