Skip to content

Commit a64e4d4

Browse files
dhowellsbrauner
authored andcommitted
afs: Fix afs_dynroot_readdir() to not use the RCU read lock
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: 1d0b929 ("afs: Change dynroot to create contents on demand") Reported-by: [email protected] Reported-by: [email protected] Reported-by: [email protected] Reported-by: [email protected] Signed-off-by: David Howells <[email protected]> Link: https://lore.kernel.org/[email protected] cc: Marc Dionne <[email protected]> cc: [email protected] cc: [email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent bb5e07c commit a64e4d4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/afs/dynroot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@ static int afs_dynroot_readdir(struct file *file, struct dir_context *ctx)
348348
}
349349

350350
if ((unsigned long long)ctx->pos <= AFS_MAX_DYNROOT_CELL_INO) {
351-
rcu_read_lock();
351+
down_read(&net->cells_lock);
352352
ret = afs_dynroot_readdir_cells(net, ctx);
353-
rcu_read_unlock();
353+
up_read(&net->cells_lock);
354354
}
355355
return ret;
356356
}

0 commit comments

Comments
 (0)