]> git.baikalelectronics.ru Git - kernel.git/commit
locking/refcount: Ensure integer operands are treated as signed
authorWill Deacon <will@kernel.org>
Thu, 21 Nov 2019 11:58:54 +0000 (11:58 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 29 Jul 2022 15:14:16 +0000 (17:14 +0200)
commit4a6066cac433432c3db8179a412405c836fb0aa2
tree4dfa291e775a2ac1c730228dfc37c8a795b57986
parent5fb981eb6f6d6690d2438cf0db1a3ad9ff374461
locking/refcount: Ensure integer operands are treated as signed

[ Upstream commit 9b86e2d1827c035c5d3fae6756ead6fa174677e0 ]

In preparation for changing the saturation point of REFCOUNT_FULL to
INT_MIN/2, change the type of integer operands passed into the API
from 'unsigned int' to 'int' so that we can avoid casting during
comparisons when we don't want to fall foul of C integral conversion
rules for signed and unsigned types.

Since the kernel is compiled with '-fno-strict-overflow', we don't need
to worry about the UB introduced by signed overflow here. Furthermore,
we're already making heavy use of the atomic_t API, which operates
exclusively on signed types.

Signed-off-by: Will Deacon <will@kernel.org>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Tested-by: Hanjun 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-3-will@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/refcount.h
lib/refcount.c