Dong Chenchen
7ed59c4027
net: Remove acked SYN flag from packet in the transmit queue correctly
...
[ Upstream commit f99cd56230f56c8b6b33713c5be4da5d6766be1f ]
syzkaller report:
kernel BUG at net/core/skbuff.c:3452!
invalid opcode: 0000 [#1 ] PREEMPT SMP KASAN PTI
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 6.7.0-rc4-00009-gbee0e7762ad2-dirty #135
RIP: 0010:skb_copy_and_csum_bits (net/core/skbuff.c:3452)
Call Trace:
icmp_glue_bits (net/ipv4/icmp.c:357)
__ip_append_data.isra.0 (net/ipv4/ip_output.c:1165)
ip_append_data (net/ipv4/ip_output.c:1362 net/ipv4/ip_output.c:1341)
icmp_push_reply (net/ipv4/icmp.c:370)
__icmp_send (./include/net/route.h:252 net/ipv4/icmp.c:772)
ip_fragment.constprop.0 (./include/linux/skbuff.h:1234 net/ipv4/ip_output.c:592 net/ipv4/ip_output.c:577)
__ip_finish_output (net/ipv4/ip_output.c:311 net/ipv4/ip_output.c:295)
ip_output (net/ipv4/ip_output.c:427)
__ip_queue_xmit (net/ipv4/ip_output.c:535)
__tcp_transmit_skb (net/ipv4/tcp_output.c:1462)
__tcp_retransmit_skb (net/ipv4/tcp_output.c:3387)
tcp_retransmit_skb (net/ipv4/tcp_output.c:3404)
tcp_retransmit_timer (net/ipv4/tcp_timer.c:604)
tcp_write_timer (./include/linux/spinlock.h:391 net/ipv4/tcp_timer.c:716)
The panic issue was trigered by tcp simultaneous initiation.
The initiation process is as follows:
TCP A TCP B
1. CLOSED CLOSED
2. SYN-SENT --> <SEQ=100><CTL=SYN> ...
3. SYN-RECEIVED <-- <SEQ=300><CTL=SYN> <-- SYN-SENT
4. ... <SEQ=100><CTL=SYN> --> SYN-RECEIVED
5. SYN-RECEIVED --> <SEQ=100><ACK=301><CTL=SYN,ACK> ...
// TCP B: not send challenge ack for ack limit or packet loss
// TCP A: close
tcp_close
tcp_send_fin
if (!tskb && tcp_under_memory_pressure(sk))
tskb = skb_rb_last(&sk->tcp_rtx_queue); //pick SYN_ACK packet
TCP_SKB_CB(tskb)->tcp_flags |= TCPHDR_FIN; // set FIN flag
6. FIN_WAIT_1 --> <SEQ=100><ACK=301><END_SEQ=102><CTL=SYN,FIN,ACK> ...
// TCP B: send challenge ack to SYN_FIN_ACK
7. ... <SEQ=301><ACK=101><CTL=ACK> <-- SYN-RECEIVED //challenge ack
// TCP A: <SND.UNA=101>
8. FIN_WAIT_1 --> <SEQ=101><ACK=301><END_SEQ=102><CTL=SYN,FIN,ACK> ... // retransmit panic
__tcp_retransmit_skb //skb->len=0
tcp_trim_head
len = tp->snd_una - TCP_SKB_CB(skb)->seq // len=101-100
__pskb_trim_head
skb->data_len -= len // skb->len=-1, wrap around
... ...
ip_fragment
icmp_glue_bits //BUG_ON
If we use tcp_trim_head() to remove acked SYN from packet that contains data
or other flags, skb->len will be incorrectly decremented. We can remove SYN
flag that has been acked from rtx_queue earlier than tcp_trim_head(), which
can fix the problem mentioned above.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Co-developed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Dong Chenchen <dongchenchen2@huawei.com>
Link: https://lore.kernel.org/r/20231210020200.1539875-1-dongchenchen2@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-12-20 15:44:28 +01:00
..
2020-08-10 12:06:44 -07:00
2023-10-10 21:53:29 +02:00
2023-06-09 10:30:05 +02:00
2021-04-14 08:42:05 +02:00
2022-04-13 21:00:57 +02:00
2020-09-25 13:58:01 -07:00
2022-07-21 21:20:08 +02:00
2022-10-30 09:41:19 +01:00
2023-09-19 12:20:29 +02:00
2023-06-28 10:28:11 +02:00
2023-10-25 11:54:19 +02:00
2023-03-22 13:30:00 +01:00
2021-12-08 09:03:26 +01:00
2023-10-25 11:54:23 +02:00
2023-10-25 11:54:23 +02:00
2020-10-02 19:11:11 -07:00
2021-01-12 20:18:12 +01:00
2020-08-03 15:29:44 -07:00
2023-04-20 12:10:21 +02:00
2023-12-08 08:46:13 +01:00
2023-07-27 08:44:42 +02:00
2021-12-22 09:30:53 +01:00
2022-01-27 10:54:33 +01:00
2023-07-27 08:44:40 +02:00
2023-07-27 08:44:40 +02:00
2022-07-21 21:20:07 +02:00
2022-07-29 17:19:12 +02:00
2022-01-27 10:54:33 +01:00
2023-12-13 18:27:00 +01:00
2023-09-19 12:20:26 +02:00
2020-08-25 06:28:02 -07:00
2023-09-19 12:20:09 +02:00
2023-06-05 09:07:04 +02:00
2023-08-16 18:21:01 +02:00
2023-03-22 13:29:58 +01:00
2023-08-26 15:26:52 +02:00
2020-07-09 12:55:37 +02:00
2021-06-18 10:00:05 +02:00
2020-06-30 12:29:39 -07:00
2022-02-16 12:54:25 +01:00
2022-12-02 17:40:05 +01:00
2020-07-10 13:54:00 -07:00
2023-02-01 08:23:24 +01:00
2020-10-30 12:57:39 +01:00
2022-11-03 23:57:54 +09:00
2022-06-09 10:21:09 +02:00
2021-11-18 14:04:08 +01:00
2023-06-05 09:07:04 +02:00
2023-12-08 08:46:08 +01:00
2023-11-20 11:06:46 +01:00
2023-07-27 08:44:42 +02:00
2021-08-18 08:59:13 +02:00
2023-05-30 12:57:46 +01:00
2022-11-25 17:45:55 +01:00
2021-05-14 09:50:46 +02:00
2021-12-01 09:19:06 +01:00
2023-07-27 08:44:43 +02:00
2020-07-06 13:23:03 -07:00
2020-07-06 13:23:03 -07:00
2023-12-13 18:27:00 +01:00
2023-10-25 11:54:19 +02:00
2023-11-20 11:06:45 +01:00
2023-07-27 08:44:40 +02:00
2021-08-12 13:22:05 +02:00
2023-12-20 15:44:28 +01:00
2022-05-09 09:05:03 +02:00
2023-10-25 11:54:20 +02:00
2020-08-24 17:31:20 -07:00
2023-09-19 12:20:08 +02:00
2023-01-24 07:20:01 +01:00
2020-10-13 17:11:52 -07:00
2020-07-06 13:23:03 -07:00
2023-07-27 08:44:43 +02:00
2020-07-09 12:51:36 +02:00
2021-07-28 14:35:37 +02:00
2020-07-24 15:41:54 -07:00
2021-08-12 13:22:05 +02:00
2023-01-14 10:15:43 +01:00
2022-03-02 11:42:51 +01:00
2020-07-10 13:54:00 -07:00
2023-11-20 11:06:44 +01:00
2023-05-30 12:57:57 +01:00
2023-06-28 10:28:10 +02:00
2022-06-14 18:32:40 +02:00
2020-10-09 12:29:48 +02:00