All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google.com>
To: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org, eric.dumazet@gmail.com,
	 Eric Dumazet <edumazet@google.com>,
	Daniel Zahka <daniel.zahka@gmail.com>,
	 Kuniyuki Iwashima <kuniyu@google.com>,
	Willem de Bruijn <willemb@google.com>
Subject: [PATCH net-next] psp: do not use sk_dst_get() in psp_dev_get_for_sock()
Date: Thu, 18 Sep 2025 11:52:38 +0000	[thread overview]
Message-ID: <20250918115238.237475-1-edumazet@google.com> (raw)

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


             reply	other threads:[~2025-09-18 11:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-18 11:52 Eric Dumazet [this message]
2025-09-18 13:15 ` [PATCH net-next] psp: do not use sk_dst_get() in psp_dev_get_for_sock() Daniel Zahka
2025-09-18 18:45 ` Kuniyuki Iwashima
2025-09-19 14:30 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250918115238.237475-1-edumazet@google.com \
    --to=edumazet@google.com \
    --cc=daniel.zahka@gmail.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.