Skip to content

Commit

Permalink
NFS: Fix a race in __nfs_list_for_each_server()
Browse files Browse the repository at this point in the history
commit 9c07b75 upstream.

The struct nfs_server gets put on the cl_superblocks list before
the server->super field has been initialised, in which case the
call to nfs_sb_active() will Oops. Add a check to ensure that
we skip such a list entry.

Fixes: 3c9e502 ("NFS: Add a helper nfs_client_for_each_server()")
Signed-off-by: Trond Myklebust <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Trond Myklebust authored and gregkh committed Oct 10, 2023
1 parent f0ea421 commit b5c3bc4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/nfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ static int __nfs_list_for_each_server(struct list_head *head,

rcu_read_lock();
list_for_each_entry_rcu(server, head, client_link) {
if (!nfs_sb_active(server->super))
if (!(server->super && nfs_sb_active(server->super)))
continue;
rcu_read_unlock();
if (last)
Expand Down

0 comments on commit b5c3bc4

Please sign in to comment.