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>
This commit is contained in:
Johannes Weiner 2024-01-29 20:36:40 -05:00 committed by Andrew Morton
parent 7dd1f7f0fc
commit e477559ca6
1 changed files with 1 additions and 0 deletions

View File

@ -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++;
}