mptcp: fix sleep in atomic at close time
Subsystems (2)
Paolo Abeni
maintainerPATCH 1/1 mptcp: fix sleep in atomic at close time
Mat reported a splat at msk close time:
BUG: sleeping function called from invalid context at net/mptcp/protocol.c:2877
in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 155, name: packetdrillpreempt_count: 201, expected: 0
RCU nest depth: 0, expected: 0
4 locks held by packetdrill/155:
#0: ffff888001536990 (&sb->s_type->i_mutex_key#6){+.+.}-{3:3}, at: __sock_release (net/socket.c:650) #1: ffff88800b498130 (sk_lock-AF_INET){+.+.}-{0:0}, at: mptcp_close (net/mptcp/protocol.c:2973) #2: ffff88800b49a130 (sk_lock-AF_INET/1){+.+.}-{0:0}, at: __mptcp_close_ssk (net/mptcp/protocol.c:2363) #3: ffff88800b49a0b0 (slock-AF_INET){+...}-{2:2}, at: __lock_sock_fast (include/net/sock.h:1820) Preemption disabled at:0x0
CPU: 1 PID: 155 Comm: packetdrill Not tainted 6.1.0-rc5 #365 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 Call Trace: <TASK> dump_stack_lvl (lib/dump_stack.c:107 (discriminator 4))
__might_resched.cold (kernel/sched/core.c:9891) __mptcp_destroy_sock (include/linux/kernel.h:110) __mptcp_close (net/mptcp/protocol.c:2959) mptcp_subflow_queue_clean (include/net/sock.h:1777) __mptcp_close_ssk (net/mptcp/protocol.c:2363) mptcp_destroy_common (net/mptcp/protocol.c:3170) mptcp_destroy (include/net/sock.h:1495) __mptcp_destroy_sock (net/mptcp/protocol.c:2886) __mptcp_close (net/mptcp/protocol.c:2959)mptcp_close (net/mptcp/protocol.c:2974)inet_release (net/ipv4/af_inet.c:432)__sock_release (net/socket.c:651)sock_close (net/socket.c:1367)__fput (fs/file_table.c:320)task_work_run (kernel/task_work.c:181 (discriminator 1)) exit_to_user_mode_prepare (include/linux/resume_user_mode.h:49) syscall_exit_to_user_mode (kernel/entry/common.c:130) do_syscall_64 (arch/x86/entry/common.c:87) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:120)
We can't acquire call mptcp_close under the 'fast' socket lock veriant, replace it with a sock_lock_nested() as the relevant code is already under the listening msk socket lock protection.
--- net/mptcp/subflow.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/mptcp/subflow.c +3 -3
@@ -1802,16 +1802,16 @@ void mptcp_subflow_queue_clean(struct sock *listener_ssk)for (msk = head; msk; msk = next) {struct sock *sk = (struct sock *)msk; -bool slow, do_cancel_work; +bool do_cancel_work;sock_hold (sk); - slow =lock_sock_fast_nested (sk); +lock_sock_nested (sk,SINGLE_DEPTH_NESTING ); next = msk->dl_next; msk->first =NULL ; msk->dl_next =NULL ; do_cancel_work =__mptcp_close (sk,0 ); -unlock_sock_fast (sk, slow); +release_sock (sk);if (do_cancel_work)mptcp_cancel_work (sk);sock_put (sk);
Signature · 1 line
2.38.1
Re: mptcp: fix sleep in atomic at close time: Tests Results
Hi Paolo,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal:
- Success! ✅:
- Task: https://cirrus-ci.com/task/6329217620115456
- Summary: https://api.cirrus-ci.com/v1/artifact/task/6329217620115456/summary/summary.txt
- KVM Validation: debug:
- Success! ✅:
- Task: https://cirrus-ci.com/task/5865717434679296
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5865717434679296/summary/summary.txt
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/cbc71d5d8b05
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-debugFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (Tessares)
Hi Paolo,
Thank you for the patch!
Quoted 38 lines · Paolo Abeni
Mat reported a splat at msk close time:
BUG: sleeping function called from invalid context at net/mptcp/protocol.c:2877
in_atomic(): 1,irqs_disabled(): 0,non_block: 0, pid: 155, name: packetdrillpreempt_count: 201, expected: 0
RCU nest depth: 0, expected: 0
4 locks held by packetdrill/155:
#0:ffff888001536990(&sb->s_type->i_mutex_key#6){+.+.}-{3:3}, at:__sock_release(net/socket.c:650) #1:ffff88800b498130(sk_lock-AF_INET){+.+.}-{0:0}, at:mptcp_close(net/mptcp/protocol.c:2973) #2:ffff88800b49a130(sk_lock-AF_INET/1){+.+.}-{0:0}, at:__mptcp_close_ssk(net/mptcp/protocol.c:2363) #3:ffff88800b49a0b0(slock-AF_INET){+...}-{2:2}, at:__lock_sock_fast(include/net/sock.h:1820) Preemption disabled at:0x0CPU: 1 PID: 155 Comm: packetdrill Not tainted 6.1.0-rc5 #365 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 Call Trace: <TASK> dump_stack_lvl (lib/dump_stack.c:107 (discriminator 4))__might_resched.cold (
kernel/sched/core.c:9891)__mptcp_destroy_sock(include/linux/kernel.h:110)__mptcp_close(net/mptcp/protocol.c:2959)mptcp_subflow_queue_clean(include/net/sock.h:1777)__mptcp_close_ssk(net/mptcp/protocol.c:2363)mptcp_destroy_common(net/mptcp/protocol.c:3170)mptcp_destroy(include/net/sock.h:1495)__mptcp_destroy_sock(net/mptcp/protocol.c:2886)__mptcp_close(net/mptcp/protocol.c:2959)mptcp_close(net/mptcp/protocol.c:2974)inet_release(net/ipv4/af_inet.c:432)__sock_release(net/socket.c:651)sock_close(net/socket.c:1367)__fput(fs/file_table.c:320)task_work_run(kernel/task_work.c:181(discriminator 1))exit_to_user_mode_prepare(include/linux/resume_user_mode.h:49)syscall_exit_to_user_mode(kernel/entry/common.c:130)do_syscall_64(arch/x86/entry/common.c:87)entry_SYSCALL_64_after_hwframe(arch/x86/entry/entry_64.S:120)
Quoted 1 line
We can't acquire call
mptcp_closeunder the 'fast' socket lock veriant,
I guess I can remove "acquire" (and s/veriant/variant/)
Quoted 5 lines
replace it with a
sock_lock_nested()as the relevant code is already under the listening msk socket lock protection.Reported-by Matthieu Baerts <[email protected]>Closes Matthieu Baerts <[email protected]>
Please don't close me, it took me some times to find how to re-open myself...
For the rest, it looks good to me!
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net
Paolo Abeni
maintainerQuoted 5 lines · Matthieu Baerts
Quoted 2 lines
Reported-by Matthieu Baerts <[email protected]>Closes Matthieu Baerts <[email protected]>Please don't close me, it took me some times to find how to re-open myself...
What can I say? at I list did not accidently close the b&b ;)
Quoted 5 lines
For the rest, it looks good to me!
Reviewed-by Matthieu Baerts <[email protected]>
feel free to add even your tested-by tag, as you already did that :) and we can produce same monster tag like 'reported-reviewed-and-tested-
by: ...' ;)
Or do you prefer I'll repost?
Thanks!
/P
Quoted 8 lines · Paolo Abeni
Quoted 5 lines · Matthieu Baerts
Quoted 2 lines
Reported-by Matthieu Baerts <[email protected]>Closes Matthieu Baerts <[email protected]>Please don't close me, it took me some times to find how to re-open myself...
What can I say? at I list did not accidently close the b&b ;)
:-P
Quoted 9 lines
Quoted 5 lines
For the rest, it looks good to me!
Reviewed-by Matthieu Baerts <[email protected]>feel free to add even your tested-by tag, as you already did that :) and we can produce same monster tag like 'reported-reviewed-and-tested-
by: ...' ;)
I guess it is better to avoid them :)
We don't need my Tested-by but I will keep the Reported-by just to understand to which "Mat" you are talking about at the beginning ;)
Quoted 1 line
Or do you prefer I'll repost?
No, thank you, I can of course do the modifications when applying the patch!
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net
Hi Paolo,
Quoted 1 line · Paolo Abeni
Mat reported a splat at msk close time:
(...)
Quoted 3 lines
We can't acquire call
mptcp_closeunder the 'fast' socket lock veriant, replace it with asock_lock_nested()as the relevant code is already under the listening msk socket lock protection.
Thank you for the patch!
Now in our tree (fix for -net) with my RvB tag (and the 3 other small fixes mentioned in my previous email)
New patches for t/upstream-net:
- ff05017f41a8: mptcp: fix sleep in atomic at close time
- Results: 4b0094499418..515e95912b40 (export-net)
- Results: 3d12c8bc8c2c..e97e3cfdc32b (export)
Tests are now in progress:
https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20221123T164310
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net
Re: mptcp: fix sleep in atomic at close time: Tests Results
In reply to Paolo AbeniHi Paolo,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal:
- Success! ✅:
- Task: https://cirrus-ci.com/task/5289200753311744
- Summary: https://api.cirrus-ci.com/v1/artifact/task/5289200753311744/summary/summary.txt
- KVM Validation: debug:
- Unstable: 1 failed test(s): selftest_mptcp_connect 🔴:
- Task: https://cirrus-ci.com/task/6415100660154368
- Summary: https://api.cirrus-ci.com/v1/artifact/task/6415100660154368/summary/summary.txt
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/1b888ac1f43d
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-debugFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (Tessares)