Skip to contentSkip to conversation

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

PATCH Applied Eric Dumazet 2 participants 2 messages Sep 13, 2023 – Sep 16, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 :)

---
 net/core/sock.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
net/core/sock.c +5 -2
index bb89b88bc1e8a042c4ee40b3c8345dc58cb1b369..969b11ede8cd8c08138a8164279b4e5923f825e6 100644
@@ -3003,7 +3003,9 @@ void __sk_flush_backlog(struct sock *sk)
 	__release_sock(sk);
 
 	if (sk->sk_prot->release_cb)
-		sk->sk_prot->release_cb(sk);
+		INDIRECT_CALL_INET_1(sk->sk_prot->release_cb,
+				     tcp_release_cb, sk);
+
 	spin_unlock_bh(&sk->sk_lock.slock);
 }
 EXPORT_SYMBOL_GPL(__sk_flush_backlog);
@@ -3523,7 +3525,8 @@ void release_sock(struct sock *sk)
 		__release_sock(sk);
 
 	if (sk->sk_prot->release_cb)
-		sk->sk_prot->release_cb(sk);
+		INDIRECT_CALL_INET_1(sk->sk_prot->release_cb,
+				     tcp_release_cb, sk);
 
 	sock_release_ownership(sk);
 	if (waitqueue_active(&sk->sk_lock.wq))
Signature · 1 line
2.42.0.283.g2d96d420d3-goog
#1 lore raw
This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Quoted 8 lines · On Wed, 13 Sep 2023 12:58:35 +0000 you wrote:

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 :)

[...]

Here is the summary with links:
- [net-next] net: use indirect call helpers for sk->sk_prot->release_cb()

    https://git.kernel.org/netdev/net-next/c/41862d12e77f

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html