Commit e477559c authored by Johannes Weiner's avatar Johannes Weiner Committed by Andrew Morton

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.orgSigned-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Reviewed-by: default avatarNhat Pham <nphamcs@gmail.com>
Acked-by: default avatarYosry Ahmed <yosryahmed@google.com>
Reviewed-by: default avatarChengming Zhou <zhouchengming@bytedance.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 7dd1f7f0
...@@ -541,6 +541,7 @@ static void zswap_entry_free(struct zswap_entry *entry) ...@@ -541,6 +541,7 @@ static void zswap_entry_free(struct zswap_entry *entry)
/* caller must hold the tree lock */ /* caller must hold the tree lock */
static void zswap_entry_get(struct zswap_entry *entry) static void zswap_entry_get(struct zswap_entry *entry)
{ {
WARN_ON_ONCE(!entry->refcount);
entry->refcount++; entry->refcount++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment