Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a09a3a6 authored by Will Deacon's avatar Will Deacon Committed by Bernhard Thoben
Browse files

locking/refcount: Remove unused refcount_*_checked() variants



The full-fat refcount implementation is exposed via a set of functions
suffixed with "_checked()", the idea being that code can choose to use
the more expensive, yet more secure implementation on a case-by-case
basis.

In reality, this hasn't happened, so with a grand total of zero users,
let's remove the checked variants for now by simply dropping the suffix
and predicating the out-of-line functions on CONFIG_REFCOUNT_FULL=y.

Signed-off-by: default avatarWill Deacon <will@kernel.org>
Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
Reviewed-by: default avatarKees Cook <keescook@chromium.org>
Tested-by: default avatarHanjun Guo <guohanjun@huawei.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Elena Reshetova <elena.reshetova@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20191121115902.2551-4-will@kernel.org


Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
(cherry picked from commit 7221762c48c6bbbcc6cc51d8b803c06930215e34)
parent 68d4867a
Loading
Loading
Loading
Loading
+5 −12
Original line number Diff line number Diff line
@@ -43,18 +43,6 @@ static inline unsigned int refcount_read(const refcount_t *r)
	return atomic_read(&r->refs);
}


extern __must_check bool refcount_add_not_zero_checked(int i, refcount_t *r);
extern void refcount_add_checked(int i, refcount_t *r);

extern __must_check bool refcount_inc_not_zero_checked(refcount_t *r);
extern void refcount_inc_checked(refcount_t *r);

extern __must_check bool refcount_sub_and_test_checked(int i, refcount_t *r);

extern __must_check bool refcount_dec_and_test_checked(refcount_t *r);
extern void refcount_dec_checked(refcount_t *r);

#ifdef CONFIG_REFCOUNT_FULL

#define REFCOUNT_MAX		(UINT_MAX - 1)
@@ -70,6 +58,11 @@ extern __must_check bool refcount_sub_and_test(int i, refcount_t *r);

extern void refcount_sub(unsigned int i, refcount_t *r);

extern __must_check bool refcount_inc_not_zero(refcount_t *r);
extern void refcount_inc(refcount_t *r);

extern __must_check bool refcount_sub_and_test(int i, refcount_t *r);

extern __must_check bool refcount_dec_and_test(refcount_t *r);
extern void refcount_dec(refcount_t *r);

+3 −3
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@
 *
 * Return: false if the passed refcount is 0, true otherwise
 */
bool refcount_add_not_zero_checked(int i, refcount_t *r)
bool refcount_add_not_zero(int i, refcount_t *r)
{
	unsigned int new, val = atomic_read(&r->refs);

@@ -102,7 +102,7 @@ EXPORT_SYMBOL(refcount_add_not_zero);
 * cases, refcount_inc(), or one of its variants, should instead be used to
 * increment a reference count.
 */
void refcount_add_checked(int i, refcount_t *r)
void refcount_add(int i, refcount_t *r)
{
	WARN_ONCE(!refcount_add_not_zero(i, r), "refcount_t: addition on 0; use-after-free.\n");
}
@@ -181,7 +181,7 @@ EXPORT_SYMBOL(refcount_inc);
 *
 * Return: true if the resulting refcount is 0, false otherwise
 */
bool refcount_sub_and_test_checked(int i, refcount_t *r)
bool refcount_sub_and_test(int i, refcount_t *r)
{
	unsigned int new, val = atomic_read(&r->refs);