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

* Re: [PATCH net-next] psp: do not use sk_dst_get() in psp_dev_get_for_sock()
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Zahka @ 2025-09-18 13:15 UTC (permalink / raw)
  To: Eric Dumazet, David S . Miller, Jakub Kicinski, Paolo Abeni
  Cc: Simon Horman, netdev, eric.dumazet, Kuniyuki Iwashima,
	Willem de Bruijn



On 9/18/25 7:52 AM, Eric Dumazet 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")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
>

Tested-by: Daniel Zahka <daniel.zahka@gmail.com>
Reviewed-by: Daniel Zahka <daniel.zahka@gmail.com>

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

* Re: [PATCH net-next] psp: do not use sk_dst_get() in psp_dev_get_for_sock()
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Kuniyuki Iwashima @ 2025-09-18 18:45 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David S . Miller, Jakub Kicinski, Paolo Abeni, Simon Horman,
	netdev, eric.dumazet, Daniel Zahka, Willem de Bruijn

On Thu, Sep 18, 2025 at 4:52 AM Eric Dumazet <edumazet@google.com> 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")
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>

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

* Re: [PATCH net-next] psp: do not use sk_dst_get() in psp_dev_get_for_sock()
  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
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-19 14:30 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: davem, kuba, pabeni, horms, netdev, eric.dumazet, daniel.zahka,
	kuniyu, willemb

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

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")
> 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>
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[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.