diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2018-08-22 00:55:31 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-22 13:52:46 -0400 |
commit | e58dd0de5eadf145895b13451a1fef8ef03946eb (patch) | |
tree | f5db856cd6e69abf35e136e8c2666469ac6b51d3 /include/linux/backing-dev-defs.h | |
parent | cedc5b6aab493f6b1b1d381dccc0cc082da7d3d8 (diff) |
bdi: use refcount_t for reference counting instead atomic_t
refcount_t type and corresponding API should be used instead of atomic_t
when the variable is used as a reference counter. This permits avoiding
accidental refcounter overflows that might lead to use-after-free
situations.
Link: http://lkml.kernel.org/r/20180703200141.28415-4-bigeasy@linutronix.de
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Suggested-by: Peter Zijlstra <peterz@infradead.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/backing-dev-defs.h')
-rw-r--r-- | include/linux/backing-dev-defs.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/include/linux/backing-dev-defs.h b/include/linux/backing-dev-defs.h index 24251762c20c..9a6bc0951cfa 100644 --- a/include/linux/backing-dev-defs.h +++ b/include/linux/backing-dev-defs.h | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/timer.h> | 12 | #include <linux/timer.h> |
13 | #include <linux/workqueue.h> | 13 | #include <linux/workqueue.h> |
14 | #include <linux/kref.h> | 14 | #include <linux/kref.h> |
15 | #include <linux/refcount.h> | ||
15 | 16 | ||
16 | struct page; | 17 | struct page; |
17 | struct device; | 18 | struct device; |
@@ -75,7 +76,7 @@ enum wb_reason { | |||
75 | */ | 76 | */ |
76 | struct bdi_writeback_congested { | 77 | struct bdi_writeback_congested { |
77 | unsigned long state; /* WB_[a]sync_congested flags */ | 78 | unsigned long state; /* WB_[a]sync_congested flags */ |
78 | atomic_t refcnt; /* nr of attached wb's and blkg */ | 79 | refcount_t refcnt; /* nr of attached wb's and blkg */ |
79 | 80 | ||
80 | #ifdef CONFIG_CGROUP_WRITEBACK | 81 | #ifdef CONFIG_CGROUP_WRITEBACK |
81 | struct backing_dev_info *__bdi; /* the associated bdi, set to NULL | 82 | struct backing_dev_info *__bdi; /* the associated bdi, set to NULL |