* [PATCH] tcp: tcp_make_synack() can be called from process context
@ 2023-03-08 19:07 Breno Leitao
2023-03-09 13:37 ` Eric Dumazet
2023-03-10 7:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Breno Leitao @ 2023-03-08 19:07 UTC (permalink / raw)
To: edumazet, davem, kuba, pabeni
Cc: netdev, laurent.fasnacht, hkchu, leit, linux-kernel
tcp_rtx_synack() now could be called in process context as explained in
0a375c822497 ("tcp: tcp_rtx_synack() can be called from process
context").
tcp_rtx_synack() might call tcp_make_synack(), which will touch per-CPU
variables with preemption enabled. This causes the following BUG:
BUG: using __this_cpu_add() in preemptible [00000000] code: ThriftIO1/5464
caller is tcp_make_synack+0x841/0xac0
Call Trace:
<TASK>
dump_stack_lvl+0x10d/0x1a0
check_preemption_disabled+0x104/0x110
tcp_make_synack+0x841/0xac0
tcp_v6_send_synack+0x5c/0x450
tcp_rtx_synack+0xeb/0x1f0
inet_rtx_syn_ack+0x34/0x60
tcp_check_req+0x3af/0x9e0
tcp_rcv_state_process+0x59b/0x2030
tcp_v6_do_rcv+0x5f5/0x700
release_sock+0x3a/0xf0
tcp_sendmsg+0x33/0x40
____sys_sendmsg+0x2f2/0x490
__sys_sendmsg+0x184/0x230
do_syscall_64+0x3d/0x90
Avoid calling __TCP_INC_STATS() with will touch per-cpu variables. Use
TCP_INC_STATS() which is safe to be called from context switch.
Fixes: 8336886f786f ("tcp: TCP Fast Open Server - support TFO listeners")
Signed-off-by: Breno Leitao <leitao@debian.org>
---
net/ipv4/tcp_output.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 71d01cf3c13e..ba839e441450 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -3605,7 +3605,7 @@ struct sk_buff *tcp_make_synack(const struct sock *sk, struct dst_entry *dst,
th->window = htons(min(req->rsk_rcv_wnd, 65535U));
tcp_options_write(th, NULL, &opts);
th->doff = (tcp_header_size >> 2);
- __TCP_INC_STATS(sock_net(sk), TCP_MIB_OUTSEGS);
+ TCP_INC_STATS(sock_net(sk), TCP_MIB_OUTSEGS);
#ifdef CONFIG_TCP_MD5SIG
/* Okay, we have all we need - do the md5 hash if needed */
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tcp: tcp_make_synack() can be called from process context
2023-03-08 19:07 [PATCH] tcp: tcp_make_synack() can be called from process context Breno Leitao
@ 2023-03-09 13:37 ` Eric Dumazet
2023-03-10 7:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2023-03-09 13:37 UTC (permalink / raw)
To: Breno Leitao
Cc: davem, kuba, pabeni, netdev, laurent.fasnacht, hkchu, leit, linux-kernel
On Wed, Mar 8, 2023 at 8:07 PM Breno Leitao <leitao@debian.org> wrote:
>
> tcp_rtx_synack() now could be called in process context as explained in
> 0a375c822497 ("tcp: tcp_rtx_synack() can be called from process
> context").
>
> tcp_rtx_synack() might call tcp_make_synack(), which will touch per-CPU
> variables with preemption enabled. This causes the following BUG:
>
>
> Avoid calling __TCP_INC_STATS() with will touch per-cpu variables. Use
> TCP_INC_STATS() which is safe to be called from context switch.
>
> Fixes: 8336886f786f ("tcp: TCP Fast Open Server - support TFO listeners")
> Signed-off-by: Breno Leitao <leitao@debian.org>
>
This looks good to me, thanks !
Reviewed-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tcp: tcp_make_synack() can be called from process context
2023-03-08 19:07 [PATCH] tcp: tcp_make_synack() can be called from process context Breno Leitao
2023-03-09 13:37 ` Eric Dumazet
@ 2023-03-10 7:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-03-10 7:20 UTC (permalink / raw)
To: Breno Leitao
Cc: edumazet, davem, kuba, pabeni, netdev, laurent.fasnacht, hkchu,
leit, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 8 Mar 2023 11:07:45 -0800 you wrote:
> tcp_rtx_synack() now could be called in process context as explained in
> 0a375c822497 ("tcp: tcp_rtx_synack() can be called from process
> context").
>
> tcp_rtx_synack() might call tcp_make_synack(), which will touch per-CPU
> variables with preemption enabled. This causes the following BUG:
>
> [...]
Here is the summary with links:
- tcp: tcp_make_synack() can be called from process context
https://git.kernel.org/netdev/net/c/bced3f7db95f
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-10 7:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08 19:07 [PATCH] tcp: tcp_make_synack() can be called from process context Breno Leitao
2023-03-09 13:37 ` Eric Dumazet
2023-03-10 7:20 ` patchwork-bot+netdevbpf
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.