From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, Chengfeng Ye <nicoyip.dev@gmail.com>,
Qi Zhang <marsy12010123@gmail.com>,
David Howells <dhowells@redhat.com>,
Marc Dionne <marc.dionne@auristor.com>,
linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org,
"Christian Brauner (Amutable)" <brauner@kernel.org>
Subject: [PATCH 6.18 1055/1250] afs: Clear stale peer app data after address list changes
Date: Thu, 17 Sep 2026 16:14:10 +0100 [thread overview]
Message-ID: <20260917151620.719669225@linuxfoundation.org> (raw)
In-Reply-To: <20260917151551.901433442@linuxfoundation.org>
6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chengfeng Ye <nicoyip.dev@gmail.com>
commit ba0623fc19a424f4745394c499f9f28a8d88d397 upstream.
afs_fs_probe_fileserver() fetches the current endpoint state under
server->fs_lock, but leaves old_alist as NULL. Consequently,
afs_set_peer_appdata() treats every address list replacement as initial
setup and only binds the new peers; it never unbinds peers removed from
the old list.
An address refresh can therefore proceed as follows. CPU 0 replaces
server S's list and drops Pold without clearing Pold->app_data. The
server destroyer then clears only S's current peers and lets S reach its
RCU callback. After the callback frees S, CPU 1 handles a callback
through an RxRPC connection that still pins Pold, reads Pold->app_data,
and calls afs_use_server() on the freed object.
KASAN reported:
BUG: KASAN: slab-use-after-free in afs_find_server+0x3c/0xa0
Read of size 4 at addr ffff8881013e1af0 by task krxrpcio/7001/74
Call Trace:
afs_find_server+0x3c/0xa0
afs_rx_new_call+0x15c/0x390
rxrpc_new_incoming_call+0x97c/0x1730
rxrpc_input_packet.constprop.0+0xd03/0xec0
rxrpc_io_thread+0x967/0x1640
Allocated by task 93:
afs_lookup_server+0x1a7/0x14c0
afs_alloc_server_list+0x43f/0xb60
afs_create_volume+0x923/0x1490
afs_get_tree+0x1c6/0x10a0
Freed by task 0:
kfree+0x131/0x3c0
rcu_core+0x50a/0x1850
Last potentially related work creation:
__call_rcu_common.constprop.0+0x71/0xa10
afs_put_server+0x213/0x2b0
Preserve old->addresses for the peer app-data update so that removed
peers are cleared before the endpoint state is replaced. Also advance
both cursors when the old and new lists share a peer; activating the
old/new comparison without this would otherwise loop forever on the
shared entry.
Fixes: 40e8b52fe8c8 ("afs: Use the per-peer app data provided by rxrpc")
Signed-off-by: Chengfeng Ye <nicoyip.dev@gmail.com>
Signed-off-by: Qi Zhang <marsy12010123@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://patch.msgid.link/20260902121024.3328255-5-dhowells@redhat.com
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
cc: linux-fsdevel@vger.kernel.org
cc: stable@vger.kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/afs/addr_list.c | 5 ++++-
fs/afs/fs_probe.c | 1 +
2 files changed, 5 insertions(+), 1 deletion(-)
--- a/fs/afs/addr_list.c
+++ b/fs/afs/addr_list.c
@@ -394,8 +394,11 @@ void afs_set_peer_appdata(struct afs_ser
struct rxrpc_peer *pn = new_alist->addrs[n].peer;
struct rxrpc_peer *po = old_alist->addrs[o].peer;
- if (pn == po)
+ if (pn == po) {
+ n++;
+ o++;
continue;
+ }
if (pn < po) {
rxrpc_kernel_set_peer_data(pn, data);
n++;
--- a/fs/afs/fs_probe.c
+++ b/fs/afs/fs_probe.c
@@ -258,6 +258,7 @@ int afs_fs_probe_fileserver(struct afs_n
lockdep_is_held(&server->fs_lock));
if (old) {
estate->responsive_set = old->responsive_set;
+ old_alist = old->addresses;
if (!new_alist)
new_alist = old->addresses;
}
prev parent reply other threads:[~2026-09-17 17:34 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260917151551.901433442@linuxfoundation.org>
2026-09-17 14:57 ` [PATCH 6.18 0028/1250] hfsplus: fix issue of direct writes beyond end-of-file Greg Kroah-Hartman
2026-09-17 14:58 ` [PATCH 6.18 0103/1250] hfsplus: rework hfsplus_readdir() logic Greg Kroah-Hartman
2026-09-17 15:00 ` [PATCH 6.18 0249/1250] hfs: " Greg Kroah-Hartman
2026-09-17 15:04 ` [PATCH 6.18 0486/1250] cachefiles: Fix double fput Greg Kroah-Hartman
2026-09-17 15:04 ` [PATCH 6.18 0487/1250] netfs: Fix decision whether to disallow write-streaming due to fscache use Greg Kroah-Hartman
2026-09-17 15:06 ` [PATCH 6.18 0582/1250] netfs: Fix barriering when walking subrequest list Greg Kroah-Hartman
2026-09-17 15:07 ` [PATCH 6.18 0642/1250] netfs: Fix unbuffered/DIO write partial transfer error return Greg Kroah-Hartman
2026-09-17 15:07 ` [PATCH 6.18 0643/1250] netfs: Fix error vs transferred passed to ->ki_complete() Greg Kroah-Hartman
2026-09-17 15:07 ` [PATCH 6.18 0644/1250] netfs: Fix i_size update for partial transfer Greg Kroah-Hartman
2026-09-17 15:07 ` [PATCH 6.18 0645/1250] netfs: Fix subreq ref leak Greg Kroah-Hartman
2026-09-17 15:07 ` [PATCH 6.18 0647/1250] cachefiles: Fix potential UAF/KASAN warning Greg Kroah-Hartman
2026-09-17 15:14 ` [PATCH 6.18 1052/1250] afs: Fix missing kunmap in afs_dir_search_bucket() Greg Kroah-Hartman
2026-09-17 15:14 ` [PATCH 6.18 1053/1250] afs: Fix double-unmap of directory block Greg Kroah-Hartman
2026-09-17 15:14 ` [PATCH 6.18 1054/1250] afs: Fix incorrect free in candidate cleanup in afs_lookup_server() Greg Kroah-Hartman
2026-09-17 15:14 ` Greg Kroah-Hartman [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260917151620.719669225@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=brauner@kernel.org \
--cc=dhowells@redhat.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=marc.dionne@auristor.com \
--cc=marsy12010123@gmail.com \
--cc=nicoyip.dev@gmail.com \
--cc=patches@lists.linux.dev \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox