]> www.infradead.org Git - users/willy/linux.git/commit
userfaultfd: convert userfaultfd_ctx::refcount to refcount_t
authorEric Biggers <ebiggers@google.com>
Wed, 5 Dec 2018 00:13:39 +0000 (11:13 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Wed, 5 Dec 2018 00:13:39 +0000 (11:13 +1100)
commit4aeb5d9f403a48efeded3d2afe61ec5b79cf0deb
treed16173dd2d3f7fcca2c317d23a7c9732ceacb25f
parentc661927b24d6f04621daaa6b58f00ec5739a5451
userfaultfd: convert userfaultfd_ctx::refcount to refcount_t

Reference counters should use refcount_t rather than atomic_t, since the
refcount_t implementation can prevent overflows, reducing the
exploitability of reference leak bugs.  userfaultfd_ctx::refcount is a
reference counter with the usual semantics, so convert it to refcount_t.

Note: I replaced the BUG() on incrementing a 0 refcount with just
refcount_inc(), since part of the semantics of refcount_t is that that
incrementing a 0 refcount is not allowed; with CONFIG_REFCOUNT_FULL,
refcount_inc() already checks for it and warns.

Link: http://lkml.kernel.org/r/20181115003916.63381-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
fs/userfaultfd.c