summaryrefslogtreecommitdiff
path: root/include/linux/ref_tracker.h
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2022-02-04 14:42:35 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-04-13 19:27:12 +0200
commit3743c9de303fa36c2e2ca2522ab280c52bcafbd2 (patch)
tree3d00b3e25163f1d68d3245636d4b41918d92cba5 /include/linux/ref_tracker.h
parent73a4f94256afaac0c9e693548b378b694bad0ba8 (diff)
ref_tracker: implement use-after-free detection
[ Upstream commit e3ececfe668facd87d920b608349a32607060e66 ] Whenever ref_tracker_dir_init() is called, mark the struct ref_tracker_dir as dead. Test the dead status from ref_tracker_alloc() and ref_tracker_free() This should detect buggy dev_put()/dev_hold() happening too late in netdevice dismantle process. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include/linux/ref_tracker.h')
-rw-r--r--include/linux/ref_tracker.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/ref_tracker.h b/include/linux/ref_tracker.h
index 60f3453be23e..a443abda937d 100644
--- a/include/linux/ref_tracker.h
+++ b/include/linux/ref_tracker.h
@@ -13,6 +13,7 @@ struct ref_tracker_dir {
spinlock_t lock;
unsigned int quarantine_avail;
refcount_t untracked;
+ bool dead;
struct list_head list; /* List of active trackers */
struct list_head quarantine; /* List of dead trackers */
#endif
@@ -26,6 +27,7 @@ static inline void ref_tracker_dir_init(struct ref_tracker_dir *dir,
INIT_LIST_HEAD(&dir->quarantine);
spin_lock_init(&dir->lock);
dir->quarantine_avail = quarantine_count;
+ dir->dead = false;
refcount_set(&dir->untracked, 1);
stack_depot_init();
}