Skip to contentSkip to conversation

afs: Fix missing/incorrect unlocking of RCU read lock

PATCH In review David Howells 3 participants 4 messages Jan 17, 2024

Subsystems (2)
lore
Share & tools
lore

David Howells

author maintainer
#0 lore raw

PATCH 1/1 afs: Fix missing/incorrect unlocking of RCU read lock

In afs_proc_addr_prefs_show(), we need to unlock the RCU read lock in both places before returning (and not lock it again).

Fixes f94f70d39cc2 ("afs: Provide a way to configure address priorities")
---
 fs/afs/proc.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
fs/afs/proc.c +3 -2
index 3bd02571f30d..15eab053af6d 100644
@@ -166,7 +166,7 @@ static int afs_proc_addr_prefs_show(struct seq_file *m, void *v)
 
 	if (!preflist) {
 		seq_puts(m, "NO PREFS\n");
-		return 0;
+		goto out;
 	}
 
 	seq_printf(m, "PROT SUBNET                                      PRIOR (v=%u n=%u/%u/%u)\n",
@@ -191,7 +191,8 @@ static int afs_proc_addr_prefs_show(struct seq_file *m, void *v)
 		}
 	}
 
-	rcu_read_lock();
+out:
+	rcu_read_unlock();
 	return 0;
 }
 
author maintainer
#1 lore raw
Quoted 5 lines · David Howells

In afs_proc_addr_prefs_show(), we need to unlock the RCU read lock in both places before returning (and not lock it again).

Fixes f94f70d39cc2 ("afs: Provide a way to configure address priorities")

Actually:

Quoted 3 lines

David

maintainer Reviewed-by
#2 lore raw
Quoted 11 lines · David Howells
Quoted 5 lines · David Howells

In afs_proc_addr_prefs_show(), we need to unlock the RCU read lock in both places before returning (and not lock it again).

Fixes f94f70d39cc2 ("afs: Provide a way to configure address priorities")

Actually:

Quoted 7 lines
Quoted 3 lines

David

The fix looks fine.

Marc

#3 lore raw
In reply to David Howells
Quoted 29 lines

2024年1月18日 00:14,David Howells <[email protected]> 写道:

In afs_proc_addr_prefs_show(), we need to unlock the RCU read lock in both places before returning (and not lock it again).

Fixes f94f70d39cc2 ("afs: Provide a way to configure address priorities")

---
fs/afs/proc.c | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)
fs/afs/proc.c +1 -1
index 3bd02571f30d..15eab053af6d 100644
@@ -166,7 +166,7 @@ static int afs_proc_addr_prefs_show(struct seq_file *m, void *v)
 
 if (!preflist) {
 seq_puts(m, "NO PREFS\n");
- return 0;
+ goto out;
 }
 
 seq_printf(m, "PROT SUBNET                                      PRIOR (v=%u n=%u/%u/%u)\n",

fs/afs/proc.c static int afs_proc_addr_prefs_show(struct seq_file *m, void *v) · line 195

Quoted 6 lines
fs/afs/proc.c +2 -1
@@ -191,7 +191,8 @@ static int afs_proc_addr_prefs_show(struct seq_file *m, void *v)
 }
 }
 
- rcu_read_lock();
+out:
+ rcu_read_unlock();

What about using:

	guard(rcu)();

Thanks,
Alan

Quoted 4 lines
fs/afs/proc.c +0 -0
 return 0;
 }