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

net: use indirect call helpers for sk->sk_prot->release_cb()

When adding sk->sk_prot->release_cb() call from __sk_flush_backlog()
Paolo suggested using indirect call helpers to take care of
CONFIG_RETPOLINE=y case.

It turns out Google had such mitigation for years in release_sock(),
it is time to make this public :)

Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
41862d12 4fa5ce3e

+5 -2
+5 -2
net/core/sock.c
··· 3003 3003 __release_sock(sk); 3004 3004 3005 3005 if (sk->sk_prot->release_cb) 3006 - sk->sk_prot->release_cb(sk); 3006 + INDIRECT_CALL_INET_1(sk->sk_prot->release_cb, 3007 + tcp_release_cb, sk); 3008 + 3007 3009 spin_unlock_bh(&sk->sk_lock.slock); 3008 3010 } 3009 3011 EXPORT_SYMBOL_GPL(__sk_flush_backlog); ··· 3525 3523 __release_sock(sk); 3526 3524 3527 3525 if (sk->sk_prot->release_cb) 3528 - sk->sk_prot->release_cb(sk); 3526 + INDIRECT_CALL_INET_1(sk->sk_prot->release_cb, 3527 + tcp_release_cb, sk); 3529 3528 3530 3529 sock_release_ownership(sk); 3531 3530 if (waitqueue_active(&sk->sk_lock.wq))