psp: do not use sk_dst_get() in psp_dev_get_for_sock()
Subsystems (3)
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")
Signed-off-by Eric Dumazet <[email protected]>
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
@@ -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
Quoted 6 lines · Eric Dumazet
Use
__sk_dst_get()anddst_dev_rcu(), becausedst->devcould be changed under us.Fixes 6b46ca260e22 ("net: psp: add socket security association code")Signed-off-by Eric Dumazet <[email protected]>
Tested-by Daniel Zahka <[email protected]>
Reviewed-by Daniel Zahka <[email protected]>
Quoted 6 lines · Eric Dumazet
Use
__sk_dst_get()anddst_dev_rcu(), becausedst->devcould be changed under us.Fixes 6b46ca260e22 ("net: psp: add socket security association code")Signed-off-by Eric Dumazet <[email protected]>
Reviewed-by Kuniyuki Iwashima <[email protected]>
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()anddst_dev_rcu(), becausedst->devcould be changed under us.Fixes 6b46ca260e22 ("net: psp: add socket security association code")Signed-off-by Eric Dumazet <[email protected]>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