Skip to content

Commit d644d68

Browse files
committed
net: relax socket state check at accept time.
jira LE-1907 Rebuild_History Non-Buildable kernel-4.18.0-553.16.1.el8_10 commit-author Paolo Abeni <[email protected]> commit 26afda7 Empty-Commit: Cherry-Pick Conflicts during history rebuild. Will be included in final tarball splat. Ref for failed cherry-pick at: ciq/ciq_backports/kernel-4.18.0-553.16.1.el8_10/26afda78.failed Christoph reported the following splat: WARNING: CPU: 1 PID: 772 at net/ipv4/af_inet.c:761 __inet_accept+0x1f4/0x4a0 Modules linked in: CPU: 1 PID: 772 Comm: syz-executor510 Not tainted 6.9.0-rc7-g7da7119fe22b #56 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-2.el7 04/01/2014 RIP: 0010:__inet_accept+0x1f4/0x4a0 net/ipv4/af_inet.c:759 Code: 04 38 84 c0 0f 85 87 00 00 00 41 c7 04 24 03 00 00 00 48 83 c4 10 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc cc cc cc e8 ec b7 da fd <0f> 0b e9 7f fe ff ff e8 e0 b7 da fd 0f 0b e9 fe fe ff ff 89 d9 80 RSP: 0018:ffffc90000c2fc58 EFLAGS: 00010293 RAX: ffffffff836bdd14 RBX: 0000000000000000 RCX: ffff888104668000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: dffffc0000000000 R08: ffffffff836bdb89 R09: fffff52000185f64 R10: dffffc0000000000 R11: fffff52000185f64 R12: dffffc0000000000 R13: 1ffff92000185f98 R14: ffff88810754d880 R15: ffff8881007b7800 FS: 000000001c772880(0000) GS:ffff88811b280000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fb9fcf2e178 CR3: 00000001045d2002 CR4: 0000000000770ef0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 PKRU: 55555554 Call Trace: <TASK> inet_accept+0x138/0x1d0 net/ipv4/af_inet.c:786 do_accept+0x435/0x620 net/socket.c:1929 __sys_accept4_file net/socket.c:1969 [inline] __sys_accept4+0x9b/0x110 net/socket.c:1999 __do_sys_accept net/socket.c:2016 [inline] __se_sys_accept net/socket.c:2013 [inline] __x64_sys_accept+0x7d/0x90 net/socket.c:2013 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0x58/0x100 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x4315f9 Code: fd ff 48 81 c4 80 00 00 00 e9 f1 fe ff ff 0f 1f 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 ab b4 fd ff c3 66 2e 0f 1f 84 00 00 00 00 RSP: 002b:00007ffdb26d9c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002b RAX: ffffffffffffffda RBX: 0000000000400300 RCX: 00000000004315f9 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000004 RBP: 00000000006e1018 R08: 0000000000400300 R09: 0000000000400300 R10: 0000000000400300 R11: 0000000000000246 R12: 0000000000000000 R13: 000000000040cdf0 R14: 000000000040ce80 R15: 0000000000000055 </TASK> The reproducer invokes shutdown() before entering the listener status. After commit 9406279 ("tcp: defer shutdown(SEND_SHUTDOWN) for TCP_SYN_RECV sockets"), the above causes the child to reach the accept syscall in FIN_WAIT1 status. Eric noted we can relax the existing assertion in __inet_accept() Reported-by: Christoph Paasch <[email protected]> Closes: multipath-tcp/mptcp_net-next#490 Suggested-by: Eric Dumazet <[email protected]> Fixes: 9406279 ("tcp: defer shutdown(SEND_SHUTDOWN) for TCP_SYN_RECV sockets") Reviewed-by: Eric Dumazet <[email protected]> Link: https://lore.kernel.org/r/23ab880a44d8cfd967e84de8b93dbf48848e3d8c.1716299669.git.pabeni@redhat.com Signed-off-by: Paolo Abeni <[email protected]> (cherry picked from commit 26afda7) Signed-off-by: Jonathan Maple <[email protected]> # Conflicts: # net/ipv4/af_inet.c
1 parent 2daf3c8 commit d644d68

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
net: relax socket state check at accept time.
2+
3+
jira LE-1907
4+
Rebuild_History Non-Buildable kernel-4.18.0-553.16.1.el8_10
5+
commit-author Paolo Abeni <[email protected]>
6+
commit 26afda78cda3da974fd4c287962c169e9462c495
7+
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
8+
Will be included in final tarball splat. Ref for failed cherry-pick at:
9+
ciq/ciq_backports/kernel-4.18.0-553.16.1.el8_10/26afda78.failed
10+
11+
Christoph reported the following splat:
12+
13+
WARNING: CPU: 1 PID: 772 at net/ipv4/af_inet.c:761 __inet_accept+0x1f4/0x4a0
14+
Modules linked in:
15+
CPU: 1 PID: 772 Comm: syz-executor510 Not tainted 6.9.0-rc7-g7da7119fe22b #56
16+
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-2.el7 04/01/2014
17+
RIP: 0010:__inet_accept+0x1f4/0x4a0 net/ipv4/af_inet.c:759
18+
Code: 04 38 84 c0 0f 85 87 00 00 00 41 c7 04 24 03 00 00 00 48 83 c4 10 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc cc cc cc e8 ec b7 da fd <0f> 0b e9 7f fe ff ff e8 e0 b7 da fd 0f 0b e9 fe fe ff ff 89 d9 80
19+
RSP: 0018:ffffc90000c2fc58 EFLAGS: 00010293
20+
RAX: ffffffff836bdd14 RBX: 0000000000000000 RCX: ffff888104668000
21+
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
22+
RBP: dffffc0000000000 R08: ffffffff836bdb89 R09: fffff52000185f64
23+
R10: dffffc0000000000 R11: fffff52000185f64 R12: dffffc0000000000
24+
R13: 1ffff92000185f98 R14: ffff88810754d880 R15: ffff8881007b7800
25+
FS: 000000001c772880(0000) GS:ffff88811b280000(0000) knlGS:0000000000000000
26+
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
27+
CR2: 00007fb9fcf2e178 CR3: 00000001045d2002 CR4: 0000000000770ef0
28+
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
29+
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
30+
PKRU: 55555554
31+
Call Trace:
32+
<TASK>
33+
inet_accept+0x138/0x1d0 net/ipv4/af_inet.c:786
34+
do_accept+0x435/0x620 net/socket.c:1929
35+
__sys_accept4_file net/socket.c:1969 [inline]
36+
__sys_accept4+0x9b/0x110 net/socket.c:1999
37+
__do_sys_accept net/socket.c:2016 [inline]
38+
__se_sys_accept net/socket.c:2013 [inline]
39+
__x64_sys_accept+0x7d/0x90 net/socket.c:2013
40+
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
41+
do_syscall_64+0x58/0x100 arch/x86/entry/common.c:83
42+
entry_SYSCALL_64_after_hwframe+0x76/0x7e
43+
RIP: 0033:0x4315f9
44+
Code: fd ff 48 81 c4 80 00 00 00 e9 f1 fe ff ff 0f 1f 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 ab b4 fd ff c3 66 2e 0f 1f 84 00 00 00 00
45+
RSP: 002b:00007ffdb26d9c78 EFLAGS: 00000246 ORIG_RAX: 000000000000002b
46+
RAX: ffffffffffffffda RBX: 0000000000400300 RCX: 00000000004315f9
47+
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000004
48+
RBP: 00000000006e1018 R08: 0000000000400300 R09: 0000000000400300
49+
R10: 0000000000400300 R11: 0000000000000246 R12: 0000000000000000
50+
R13: 000000000040cdf0 R14: 000000000040ce80 R15: 0000000000000055
51+
</TASK>
52+
53+
The reproducer invokes shutdown() before entering the listener status.
54+
After commit 94062790aedb ("tcp: defer shutdown(SEND_SHUTDOWN) for
55+
TCP_SYN_RECV sockets"), the above causes the child to reach the accept
56+
syscall in FIN_WAIT1 status.
57+
58+
Eric noted we can relax the existing assertion in __inet_accept()
59+
60+
Reported-by: Christoph Paasch <[email protected]>
61+
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/490
62+
Suggested-by: Eric Dumazet <[email protected]>
63+
Fixes: 94062790aedb ("tcp: defer shutdown(SEND_SHUTDOWN) for TCP_SYN_RECV sockets")
64+
Reviewed-by: Eric Dumazet <[email protected]>
65+
Link: https://lore.kernel.org/r/23ab880a44d8cfd967e84de8b93dbf48848e3d8c.1716299669.git.pabeni@redhat.com
66+
Signed-off-by: Paolo Abeni <[email protected]>
67+
(cherry picked from commit 26afda78cda3da974fd4c287962c169e9462c495)
68+
Signed-off-by: Jonathan Maple <[email protected]>
69+
70+
# Conflicts:
71+
# net/ipv4/af_inet.c
72+
diff --cc net/ipv4/af_inet.c
73+
index 9b53bb49b5ce,86cce7e9c2d1..000000000000
74+
--- a/net/ipv4/af_inet.c
75+
+++ b/net/ipv4/af_inet.c
76+
@@@ -745,6 -753,22 +745,25 @@@ int inet_stream_connect(struct socket *
77+
}
78+
EXPORT_SYMBOL(inet_stream_connect);
79+
80+
++<<<<<<< HEAD
81+
++=======
82+
+ void __inet_accept(struct socket *sock, struct socket *newsock, struct sock *newsk)
83+
+ {
84+
+ sock_rps_record_flow(newsk);
85+
+ WARN_ON(!((1 << newsk->sk_state) &
86+
+ (TCPF_ESTABLISHED | TCPF_SYN_RECV |
87+
+ TCPF_FIN_WAIT1 | TCPF_FIN_WAIT2 |
88+
+ TCPF_CLOSING | TCPF_CLOSE_WAIT |
89+
+ TCPF_CLOSE)));
90+
+
91+
+ if (test_bit(SOCK_SUPPORT_ZC, &sock->flags))
92+
+ set_bit(SOCK_SUPPORT_ZC, &newsock->flags);
93+
+ sock_graft(newsk, newsock);
94+
+
95+
+ newsock->state = SS_CONNECTED;
96+
+ }
97+
+
98+
++>>>>>>> 26afda78cda3 (net: relax socket state check at accept time.)
99+
/*
100+
* Accept a pending connection. The TCP layer now gives BSD semantics.
101+
*/
102+
* Unmerged path net/ipv4/af_inet.c

0 commit comments

Comments
 (0)