FAILED: patch "[PATCH] mm/zswap: publish the initial pool with list_add_rcu()" failed to apply to 6.12-stable tree
Subsystems (3)
Sasha Levin
maintainerThe patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x c1dd5e24a82d19bff8eef50ba8205d4776584aff
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '[email protected]' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Thanks,
Sasha
------------------ original commit in Linus's tree ------------------
From c1dd5e24a82d19bff8eef50ba8205d4776584aff Mon Sep 17 00:00:00 2001
From: Longlong Xia <[email protected]>
Date: Tue, 8 Sep 2026 09:28:01 +0800
Subject: [PATCH] mm/zswap: publish the initial pool with list_add_rcu()
zswap_setup() publishes the pool on the zswap_pools list with a plain list_add(), but the list is walked by concurrent RCU readers holding nothing but rcu_read_lock() through zswap_total_pages(), e.g. /proc/meminfo and the shrinker count path.
CPU 0 (writer) CPU 1 (reader)
-------------- --------------
zswap_pool_create():
pool->zs_pool = zs_create_pool(); (1)
list_add() -> __list_add():
WRITE_ONCE(zswap_pools.next,
&pool->list); (2) zswap_total_pages():
pool = READ_ONCE( (a)
zswap_pools.next);
zs_get_total_pages( (b)
pool->zs_pool);If (2) becomes visible to CPU 1 before (1), CPU 1 finds the pool at (a) but dereferences a wild pointer at (b). Publish the node with list_add_rcu().
--- mm/zswap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/zswap.c +1 -1
@@ -1815,7 +1815,7 @@ static int zswap_setup(void) pool =__zswap_pool_create_fallback ();if (pool) {pr_info ("loaded using pool %s\n" , pool->tfm_name); -list_add (&pool->list, &zswap_pools); +list_add_rcu (&pool->list, &zswap_pools); zswap_has_pool = true;static_branch_enable (&zswap_ever_enabled); }else {
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 mm/zswap: publish the initial pool with list_add_rcu()
From: Longlong Xia <[email protected]>
[ Upstream commit c1dd5e24a82d19bff8eef50ba8205d4776584aff ]
zswap_setup() publishes the pool on the zswap_pools list with a plain list_add(), but the list is walked by concurrent RCU readers holding nothing but rcu_read_lock() through zswap_total_pages(), e.g. /proc/meminfo and the shrinker count path.
CPU 0 (writer) CPU 1 (reader)
-------------- --------------
zswap_pool_create():
pool->zs_pool = zs_create_pool(); (1)
list_add() -> __list_add():
WRITE_ONCE(zswap_pools.next,
&pool->list); (2) zswap_total_pages():
pool = READ_ONCE( (a)
zswap_pools.next);
zs_get_total_pages( (b)
pool->zs_pool);If (2) becomes visible to CPU 1 before (1), CPU 1 finds the pool at (a) but dereferences a wild pointer at (b). Publish the node with list_add_rcu().
--- mm/zswap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/zswap.c +1 -1
@@ -1778,7 +1778,7 @@ static int zswap_setup(void)if (pool) {pr_info ("loaded using pool %s/%s\n" , pool->tfm_name,zpool_get_type (pool->zpool)); -list_add (&pool->list, &zswap_pools); +list_add_rcu (&pool->list, &zswap_pools); zswap_has_pool = true; }else {pr_err ("pool creation failed\n" );
Signature · 1 line
2.53.0