path: root/Kbuild
diff options
authorElena Reshetova <>2019-02-05 14:24:27 +0200
committerIngo Molnar <>2019-02-11 11:37:16 +0100
commit49262de2270e09882d7bd8866a691cdd69ab32f6 (patch)
tree5a8b57ff71ff9ea2986b92e21150a9e441bd270b /Kbuild
parent47b8f3ab9c49daa824af848f9e02889662d8638f (diff)
futex: Convert futex_pi_state.refcount to refcount_t
atomic_t variables are currently used to implement reference counters with the following properties: - counter is initialized to 1 using atomic_set() - a resource is freed upon counter reaching zero - once counter reaches zero, its further increments aren't allowed - counter schema uses basic atomic operations (set, inc, inc_not_zero, dec_and_test, etc.) Such atomic variables should be converted to a newly provided refcount_t type and API that prevents accidental counter overflows and underflows. This is important since overflows and underflows can lead to use-after-free situation and be exploitable. The variable futex_pi_state.refcount is used as pure reference counter. Convert it to refcount_t and fix up the operations. **Important note for maintainers: Some functions from refcount_t API defined in lib/refcount.c have different memory ordering guarantees than their atomic counterparts. Please check Documentation/core-api/refcount-vs-atomic.rst for more information. Normally the differences should not matter since refcount_t provides enough guarantees to satisfy the refcounting use cases, but in some rare cases it might matter. Please double check that you don't have some undocumented memory guarantees for this variable usage. For the futex_pi_state.refcount it might make a difference in following places: - get_pi_state() and exit_pi_state_list(): increment in refcount_inc_not_zero() only guarantees control dependency on success vs. fully ordered atomic counterpart - put_pi_state(): decrement in refcount_dec_and_test() provides RELEASE ordering and ACQUIRE ordering on success vs. fully ordered atomic counterpart Suggested-by: Kees Cook <> Signed-off-by: Elena Reshetova <> Reviewed-by: David Windsor <> Reviewed-by: Hans Liljestrand <> Cc: Andrew Morton <> Cc: Linus Torvalds <> Cc: Paul E. McKenney <> Cc: Peter Zijlstra <> Cc: Thomas Gleixner <> Cc: Will Deacon <> Cc: Link: Signed-off-by: Ingo Molnar <>
Diffstat (limited to 'Kbuild')
0 files changed, 0 insertions, 0 deletions