linux-sg2042/drivers/md/bcache
Elena Reshetova 3b304d24a7 bcache: convert cached_dev.count from atomic_t 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 cached_dev.count is used as pure reference counter.
Convert it to refcount_t and fix up the operations.

Suggested-by: Kees Cook <keescook@chromium.org>
Reviewed-by: David Windsor <dwindsor@gmail.com>
Reviewed-by: Hans Liljestrand <ishkamiel@gmail.com>
Reviewed-by: Michael Lyle <mlyle@lyle.org>
Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2017-10-30 15:57:54 -06:00
..
Kconfig
Makefile
alloc.c bcache: fix a comments typo in bch_alloc_sectors() 2017-10-16 09:07:26 -06:00
bcache.h bcache: convert cached_dev.count from atomic_t to refcount_t 2017-10-30 15:57:54 -06:00
bset.c
bset.h
btree.c
btree.h
closure.c bcache: Don't reinvent the wheel but use existing llist API 2017-09-06 08:17:33 -06:00
closure.h bcache: safeguard a dangerous addressing in closure_queue 2017-10-16 09:07:26 -06:00
debug.c
debug.h
extents.c
extents.h
io.c
journal.c
journal.h
movinggc.c
request.c bcache: only permit to recovery read error when cache device is clean 2017-10-30 15:57:54 -06:00
request.h
stats.c
stats.h
super.c bcache: convert cached_dev.count from atomic_t to refcount_t 2017-10-30 15:57:54 -06:00
sysfs.c bcache: implement PI controller for writeback rate 2017-10-16 09:07:26 -06:00
sysfs.h
trace.c
util.c bcache: writeback rate clamping: make 32 bit safe 2017-10-16 13:00:10 -06:00
util.h bcache: writeback rate shouldn't artifically clamp 2017-10-16 09:07:26 -06:00
writeback.c bcache: rearrange writeback main thread ratelimit 2017-10-16 09:07:26 -06:00
writeback.h bcache: convert cached_dev.count from atomic_t to refcount_t 2017-10-30 15:57:54 -06:00