Skip to contentSkip to conversation

psp: do not use sk_dst_get() in psp_dev_get_for_sock()

PATCH Applied Eric Dumazet 4 participants 4 messages Sep 18, 2025 – Sep 19, 2025

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

PATCH 1/1 psp: do not use sk_dst_get() in psp_dev_get_for_sock()

Use __sk_dst_get() and dst_dev_rcu(), because dst->dev could be changed under us.

Fixes 6b46ca260e22 ("net: psp: add socket security association code")
Cc Daniel Zahka <[email protected]>
Cc Kuniyuki Iwashima <[email protected]>
Cc Willem de Bruijn <[email protected]>
---
 net/psp/psp_sock.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)
net/psp/psp_sock.c +7 -10
index afa966c6b69dc657a54425656131b57645c81f6f..d19e37e939672c1f8fc0ebb62e50a3fb32cc8d25 100644
@@ -11,21 +11,18 @@
 
 struct psp_dev *psp_dev_get_for_sock(struct sock *sk)
 {
+	struct psp_dev *psd = NULL;
 	struct dst_entry *dst;
-	struct psp_dev *psd;
-
-	dst = sk_dst_get(sk);
-	if (!dst)
-		return NULL;
 
 	rcu_read_lock();
-	psd = rcu_dereference(dst->dev->psp_dev);
-	if (psd && !psp_dev_tryget(psd))
-		psd = NULL;
+	dst = __sk_dst_get(sk);
+	if (dst) {
+		psd = rcu_dereference(dst_dev_rcu(dst)->psp_dev);
+		if (psd && !psp_dev_tryget(psd))
+			psd = NULL;
+	}
 	rcu_read_unlock();
 
-	dst_release(dst);
-
 	return psd;
 }
 
Signature · 1 line
2.51.0.384.g4c02a37b29-goog
#3 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Thu, 18 Sep 2025 11:52:38 +0000 you wrote:

Use __sk_dst_get() and dst_dev_rcu(), because dst->dev could be changed under us.

Fixes 6b46ca260e22 ("net: psp: add socket security association code")
Cc Daniel Zahka <[email protected]>
Cc Kuniyuki Iwashima <[email protected]>
Cc Willem de Bruijn <[email protected]>

[...]

Here is the summary with links:
- [net-next] psp: do not use sk_dst_get() in psp_dev_get_for_sock()

    https://git.kernel.org/netdev/net-next/c/17f1b7711e81

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html