* [PATCH RESEND] signal: unconditionally leave the frozen state in ptrace_stop()
@ 2019-05-16 17:38 Roman Gushchin
2019-05-16 17:45 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Roman Gushchin @ 2019-05-16 17:38 UTC (permalink / raw)
To: Tejun Heo
Cc: Oleg Nesterov, Alex Xu, kernel-team, cgroups, linux-kernel,
Roman Gushchin
Alex Xu reported a regression in strace, caused by the introduction of
the cgroup v2 freezer. The regression can be reproduced by stracing
the following simple program:
#include <unistd.h>
int main() {
write(1, "a", 1);
return 0;
}
An attempt to run strace ./a.out leads to the infinite loop:
[ pre-main omitted ]
write(1, "a", 1) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
write(1, "a", 1) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
write(1, "a", 1) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
write(1, "a", 1) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
write(1, "a", 1) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
write(1, "a", 1) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
[ repeats forever ]
The problem occurs because the traced task leaves ptrace_stop()
(and the signal handling loop) with the frozen bit set. So let's
call cgroup_leave_frozen(true) unconditionally after sleeping
in ptrace_stop().
With this patch applied, strace works as expected:
[ pre-main omitted ]
write(1, "a", 1) = 1
exit_group(0) = ?
+++ exited with 0 +++
Reported-by: Alex Xu <alex_y_xu@yahoo.ca>
Fixes: 76f969e8948d ("cgroup: cgroup v2 freezer")
Signed-off-by: Roman Gushchin <guro@fb.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Tejun Heo <tj@kernel.org>
---
kernel/signal.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/kernel/signal.c b/kernel/signal.c
index 8607b11ff936..565ba14d89d5 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2112,6 +2112,7 @@ static void ptrace_stop(int exit_code, int why, int clear_code, kernel_siginfo_t
preempt_enable_no_resched();
cgroup_enter_frozen();
freezable_schedule();
+ cgroup_leave_frozen(true);
} else {
/*
* By the time we got the lock, our tracer went away.
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH RESEND] signal: unconditionally leave the frozen state in ptrace_stop()
2019-05-16 17:38 [PATCH RESEND] signal: unconditionally leave the frozen state in ptrace_stop() Roman Gushchin
@ 2019-05-16 17:45 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2019-05-16 17:45 UTC (permalink / raw)
To: Roman Gushchin; +Cc: Oleg Nesterov, Alex Xu, kernel-team, cgroups, linux-kernel
On Thu, May 16, 2019 at 10:38:21AM -0700, Roman Gushchin wrote:
> Alex Xu reported a regression in strace, caused by the introduction of
> the cgroup v2 freezer. The regression can be reproduced by stracing
> the following simple program:
>
> #include <unistd.h>
>
> int main() {
> write(1, "a", 1);
> return 0;
> }
>
> An attempt to run strace ./a.out leads to the infinite loop:
> [ pre-main omitted ]
> write(1, "a", 1) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
> write(1, "a", 1) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
> write(1, "a", 1) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
> write(1, "a", 1) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
> write(1, "a", 1) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
> write(1, "a", 1) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
> [ repeats forever ]
>
> The problem occurs because the traced task leaves ptrace_stop()
> (and the signal handling loop) with the frozen bit set. So let's
> call cgroup_leave_frozen(true) unconditionally after sleeping
> in ptrace_stop().
>
> With this patch applied, strace works as expected:
> [ pre-main omitted ]
> write(1, "a", 1) = 1
> exit_group(0) = ?
> +++ exited with 0 +++
>
> Reported-by: Alex Xu <alex_y_xu@yahoo.ca>
> Fixes: 76f969e8948d ("cgroup: cgroup v2 freezer")
> Signed-off-by: Roman Gushchin <guro@fb.com>
> Acked-by: Oleg Nesterov <oleg@redhat.com>
> Cc: Tejun Heo <tj@kernel.org>
Applied to cgroup/for-5.2-fixes.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-05-16 17:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-16 17:38 [PATCH RESEND] signal: unconditionally leave the frozen state in ptrace_stop() Roman Gushchin
2019-05-16 17:45 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).