Skip to contentSkip to conversation

NFS: Fix a race in __nfs_list_for_each_server()

PATCH New [email protected] 1 participant 1 message Apr 30, 2020

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 NFS: Fix a race in __nfs_list_for_each_server()

From: Trond Myklebust <[email protected]>

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 3c9e502b59fb ("NFS: Add a helper nfs_client_for_each_server()")
---
 fs/nfs/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfs/super.c +1 -1
index 59ef3b13ccca..bdb6d0c2e755 100644
@@ -185,7 +185,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)
Signature · 1 line
2.26.2