summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2024-01-29 20:36:40 -0500
committerAndrew Morton <akpm@linux-foundation.org>2024-02-22 10:24:42 -0800
commite477559ca602a033e3970ebdbbfb39773345d694 (patch)
tree87b0e3253878c9841ed1ac427822be21240875e9 /mm
parent7dd1f7f0fc1c98525cbadf954eb6b7672ad4acea (diff)
mm: zswap: warn when referencing a dead entry
Put a standard sanity check on zswap_entry_get() for UAF scenario. Link: https://lkml.kernel.org/r/20240130014208.565554-5-hannes@cmpxchg.org Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Reviewed-by: Nhat Pham <nphamcs@gmail.com> Acked-by: Yosry Ahmed <yosryahmed@google.com> Reviewed-by: Chengming Zhou <zhouchengming@bytedance.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/zswap.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/mm/zswap.c b/mm/zswap.c
index 0dfd410d1b3c..70e409add32b 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -541,6 +541,7 @@ static void zswap_entry_free(struct zswap_entry *entry)
/* caller must hold the tree lock */
static void zswap_entry_get(struct zswap_entry *entry)
{
+ WARN_ON_ONCE(!entry->refcount);
entry->refcount++;
}