Skip to contentSkip to conversation

tipc: fix RCU dereference race in tipc_aead_users_dec()

PATCH In review Daniel Hodges 3 participants 4 messages Feb 1 – Feb 3

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tipc: fix RCU dereference race in tipc_aead_users_dec()

tipc_aead_users_dec() calls rcu_dereference(aead) twice: once to store in 'tmp' for the NULL check, and again inside the atomic_add_unless() call.

Use the already-dereferenced 'tmp' pointer consistently, matching the correct pattern used in tipc_aead_users_inc() and tipc_aead_users_set().

Fixes fc1b6d6de220 ("tipc: introduce TIPC encryption & authentication")
---
 net/tipc/crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/tipc/crypto.c +1 -1
index 970db62bd029..a3f9ca28c3d5 100644
@@ -453,21 +453,21 @@ static void tipc_aead_users_inc(struct tipc_aead __rcu *aead, int lim)
 	rcu_read_unlock();
 }
 
 static void tipc_aead_users_dec(struct tipc_aead __rcu *aead, int lim)
 {
 	struct tipc_aead *tmp;
 
 	rcu_read_lock();
 	tmp = rcu_dereference(aead);
 	if (tmp)
-		atomic_add_unless(&rcu_dereference(aead)->users, -1, lim);
+		atomic_add_unless(&tmp->users, -1, lim);
 	rcu_read_unlock();
 }
 
 static void tipc_aead_users_set(struct tipc_aead __rcu *aead, int val)
 {
 	struct tipc_aead *tmp;
 	int cur;
 
 	rcu_read_lock();
 	tmp = rcu_dereference(aead);
Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Daniel Hodges

tipc_aead_users_dec() calls rcu_dereference(aead) twice: once to store in 'tmp' for the NULL check, and again inside the atomic_add_unless() call.

Quoted 7 lines

Use the already-dereferenced 'tmp' pointer consistently, matching the correct pattern used in tipc_aead_users_inc() and tipc_aead_users_set().

Fixes fc1b6d6de220 ("tipc: introduce TIPC encryption & authentication")
maintainer
#2 lore raw
In reply to Daniel Hodges
Quoted 11 lines · On Sat, 31 Jan 2026 18:21:28 -0800 Daniel Hodges wrote:

tipc_aead_users_dec() calls rcu_dereference(aead) twice: once to store in 'tmp' for the NULL check, and again inside the atomic_add_unless() call.

Use the already-dereferenced 'tmp' pointer consistently, matching the correct pattern used in tipc_aead_users_inc() and tipc_aead_users_set().

Fixes fc1b6d6de220 ("tipc: introduce TIPC encryption & authentication")

Somehow this didn't reach patchwork, please resend, and while you do that please remove the empty line between cc stable and you sob.

#3 lore raw
Quoted 8 lines · Jakub Kicinski
Quoted 7 lines · On Sat, 31 Jan 2026 18:21:28 -0800 Daniel Hodges wrote:

tipc_aead_users_dec() calls rcu_dereference(aead) twice: once to store in 'tmp' for the NULL check, and again inside the atomic_add_unless() call.

Use the already-dereferenced 'tmp' pointer consistently, matching the correct pattern used in tipc_aead_users_inc() and tipc_aead_users_set().

Quoted 7 lines
Quoted 4 lines
Fixes fc1b6d6de220 ("tipc: introduce TIPC encryption & authentication")

Somehow this didn't reach patchwork, please resend, and while you do that please remove the empty line between cc stable and you sob.

Sounds good, the corp email keeps getting filtered so I'll resend from my personal email.