lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ffc74759-e3e3-499f-85fb-abe52bac2464@bytedance.com>
Date: Tue, 30 Jan 2024 10:41:29 +0800
From: Chengming Zhou <zhouchengming@...edance.com>
To: Johannes Weiner <hannes@...xchg.org>,
 Andrew Morton <akpm@...ux-foundation.org>
Cc: Nhat Pham <nphamcs@...il.com>, Yosry Ahmed <yosryahmed@...gle.com>,
 linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm: zswap: fix objcg use-after-free in entry destruction

On 2024/1/30 09:34, Johannes Weiner wrote:
> In the per-memcg LRU universe, LRU removal uses entry->objcg to
> determine which list count needs to be decreased. Drop the objcg
> reference after updating the LRU, to fix a possible use-after-free.
> 
> Fixes: a65b0e7607cc ("zswap: make shrinking memcg-aware")
> Signed-off-by: Johannes Weiner <hannes@...xchg.org>

LGTM, thanks!

Reviewed-by: Chengming Zhou <zhouchengming@...edance.com>

> ---
>  mm/zswap.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/zswap.c b/mm/zswap.c
> index de68a5928527..7f88b3a77e4a 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -522,10 +522,6 @@ static struct zpool *zswap_find_zpool(struct zswap_entry *entry)
>   */
>  static void zswap_free_entry(struct zswap_entry *entry)
>  {
> -	if (entry->objcg) {
> -		obj_cgroup_uncharge_zswap(entry->objcg, entry->length);
> -		obj_cgroup_put(entry->objcg);
> -	}
>  	if (!entry->length)
>  		atomic_dec(&zswap_same_filled_pages);
>  	else {
> @@ -534,6 +530,10 @@ static void zswap_free_entry(struct zswap_entry *entry)
>  		atomic_dec(&entry->pool->nr_stored);
>  		zswap_pool_put(entry->pool);
>  	}
> +	if (entry->objcg) {
> +		obj_cgroup_uncharge_zswap(entry->objcg, entry->length);
> +		obj_cgroup_put(entry->objcg);
> +	}
>  	zswap_entry_cache_free(entry);
>  	atomic_dec(&zswap_stored_pages);
>  	zswap_update_total_size();

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ