[PATCH 6.12 1258/1276] afs: Fix afs_dynroot_readdir() to not use the RCU read lock

Greg Kroah-Hartman gregkh at linuxfoundation.org
Tue Jul 21 08:28:21 PDT 2026


6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: David Howells <dhowells at redhat.com>

commit a64e4d48a0b77e4ada19ac26ca3a08cd492f6362 upstream.

afs_dynroot_readdir() uses the RCU read lock to walk the cell list whilst
emitting cell automount entries - but dir_emit() may write to a userspace
buffer, thereby causing a fault to occur and waits to happen.

Fix afs_dynroot_readdir() to get a shared lock on net->cells_lock instead.

This can be triggered by enabling lockdep, preconfiguring a number of
cells, doing "mount -t afs none /afs -o dyn" (or using the kafs-client
package with afs.mount systemd unit enabled) and then doing "ls /afs".

Fixes: 1d0b929fc070 ("afs: Change dynroot to create contents on demand")
Reported-by: syzbot+3b6c5c6a1d0119b687a1 at syzkaller.appspotmail.com
Reported-by: syzbot+8245611446194a52150d at syzkaller.appspotmail.com
Reported-by: syzbot+1aa62e6852a6ad1c7944 at syzkaller.appspotmail.com
Reported-by: syzbot+54e6c2176ba76c56217e at syzkaller.appspotmail.com
Signed-off-by: David Howells <dhowells at redhat.com>
Link: https://lore.kernel.org/1638014.1744145189@warthog.procyon.org.uk
cc: Marc Dionne <marc.dionne at auristor.com>
cc: linux-afs at lists.infradead.org
cc: linux-fsdevel at vger.kernel.org
Signed-off-by: Christian Brauner <brauner at kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
---
 fs/afs/dynroot.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/fs/afs/dynroot.c
+++ b/fs/afs/dynroot.c
@@ -347,9 +347,9 @@ static int afs_dynroot_readdir(struct fi
 	}
 
 	if ((unsigned long long)ctx->pos <= AFS_MAX_DYNROOT_CELL_INO) {
-		rcu_read_lock();
+		down_read(&net->cells_lock);
 		ret = afs_dynroot_readdir_cells(net, ctx);
-		rcu_read_unlock();
+		up_read(&net->cells_lock);
 	}
 	return ret;
 }





More information about the linux-afs mailing list