signal: Requeue signals in the appropriate queue
authorEric W. Biederman <ebiederm@xmission.com>
Mon, 15 Nov 2021 19:47:13 +0000 (13:47 -0600)
committerEric W. Biederman <ebiederm@xmission.com>
Wed, 17 Nov 2021 16:39:12 +0000 (10:39 -0600)
commit5768d8906bc23d512b1a736c1e198aa833a6daa4
treee875cf8c82219bc4bb0aeecca2d461c509251fc9
parente7f7c99ba911f56bc338845c1cd72954ba591707
signal: Requeue signals in the appropriate queue

In the event that a tracer changes which signal needs to be delivered
and that signal is currently blocked then the signal needs to be
requeued for later delivery.

With the advent of CLONE_THREAD the kernel has 2 signal queues per
task.  The per process queue and the per task queue.  Update the code
so that if the signal is removed from the per process queue it is
requeued on the per process queue.  This is necessary to make it
appear the signal was never dequeued.

The rr debugger reasonably believes that the state of the process from
the last ptrace_stop it observed until PTRACE_EVENT_EXIT can be recreated
by simply letting a process run.  If a SIGKILL interrupts a ptrace_stop
this is not true today.

So return signals to their original queue in ptrace_signal so that
signals that are not delivered appear like they were never dequeued.

Fixes: 794aa320b79d ("[PATCH] sigfix-2.5.40-D6")
History Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.gi
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lkml.kernel.org/r/87zgq4d5r4.fsf_-_@email.froward.int.ebiederm.org
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
fs/signalfd.c
include/linux/sched/signal.h
kernel/signal.c