Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Tested-by: Daniel Zahka <daniel.zahka@gmail.com>
Reviewed-by: Daniel Zahka <daniel.zahka@gmail.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20250918115238.237475-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
17f1b771 315f423b

+7 -10
+7 -10
net/psp/psp_sock.c
··· 11 11 12 12 struct psp_dev *psp_dev_get_for_sock(struct sock *sk) 13 13 { 14 + struct psp_dev *psd = NULL; 14 15 struct dst_entry *dst; 15 - struct psp_dev *psd; 16 - 17 - dst = sk_dst_get(sk); 18 - if (!dst) 19 - return NULL; 20 16 21 17 rcu_read_lock(); 22 - psd = rcu_dereference(dst->dev->psp_dev); 23 - if (psd && !psp_dev_tryget(psd)) 24 - psd = NULL; 18 + dst = __sk_dst_get(sk); 19 + if (dst) { 20 + psd = rcu_dereference(dst_dev_rcu(dst)->psp_dev); 21 + if (psd && !psp_dev_tryget(psd)) 22 + psd = NULL; 23 + } 25 24 rcu_read_unlock(); 26 - 27 - dst_release(dst); 28 25 29 26 return psd; 30 27 }