All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] psp: do not use sk_dst_get() in psp_dev_get_for_sock()
@ 2025-09-18 11:52 Eric Dumazet
  2025-09-18 13:15 ` Daniel Zahka
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Dumazet @ 2025-09-18 11:52 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, netdev, eric.dumazet, Eric Dumazet, Daniel Zahka,
	Kuniyuki Iwashima, Willem de Bruijn

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")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Daniel Zahka <daniel.zahka@gmail.com>
Cc: Kuniyuki Iwashima <kuniyu@google.com>
Cc: Willem de Bruijn <willemb@google.com>
---
 net/psp/psp_sock.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/net/psp/psp_sock.c b/net/psp/psp_sock.c
index afa966c6b69dc657a54425656131b57645c81f6f..d19e37e939672c1f8fc0ebb62e50a3fb32cc8d25 100644
--- a/net/psp/psp_sock.c
+++ b/net/psp/psp_sock.c
@@ -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;
 }
 
-- 
2.51.0.384.g4c02a37b29-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-09-19 14:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-18 11:52 [PATCH net-next] psp: do not use sk_dst_get() in psp_dev_get_for_sock() Eric Dumazet
2025-09-18 13:15 ` Daniel Zahka
2025-09-18 18:45 ` Kuniyuki Iwashima
2025-09-19 14:30 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.