* [PATCH 01/10] signal: Always ignore SIGKILL and SIGSTOP sent to the global init
2018-09-03 20:41 [PATCH 00/10] Removing SEND_SIG_FORCED Eric W. Biederman
@ 2018-09-03 20:44 ` Eric W. Biederman
2018-09-03 20:44 ` [PATCH 02/10] signal: Properly deliver SIGILL from uprobes Eric W. Biederman
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Eric W. Biederman @ 2018-09-03 20:44 UTC (permalink / raw)
To: linux-kernel; +Cc: Oleg Nesterov, Linus Torvalds, linux-api, Eric W. Biederman
If the first process started (aka /sbin/init) receives a SIGKILL it
will panic the system if it is delivered. Making the system unusable
and undebugable. It isn't much better if the first process started
receives SIGSTOP.
So always ignore SIGSTOP and SIGKILL sent to init.
This is done in a separate clause in sig_task_ignored as force_sig_info
can clear SIG_UNKILLABLE and this protection should work even then.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
kernel/signal.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kernel/signal.c b/kernel/signal.c
index 5843c541fda9..b33264bb2064 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -78,6 +78,10 @@ static bool sig_task_ignored(struct task_struct *t, int sig, bool force)
handler = sig_handler(t, sig);
+ /* SIGKILL and SIGSTOP may not be sent to the global init */
+ if (unlikely(is_global_init(t) && sig_kernel_only(sig)))
+ return true;
+
if (unlikely(t->signal->flags & SIGNAL_UNKILLABLE) &&
handler == SIG_DFL && !(force && sig_kernel_only(sig)))
return true;
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 02/10] signal: Properly deliver SIGILL from uprobes
2018-09-03 20:41 [PATCH 00/10] Removing SEND_SIG_FORCED Eric W. Biederman
2018-09-03 20:44 ` [PATCH 01/10] signal: Always ignore SIGKILL and SIGSTOP sent to the global init Eric W. Biederman
@ 2018-09-03 20:44 ` Eric W. Biederman
2018-09-03 20:44 ` [PATCH 03/10] signal: Properly deliver SIGSEGV from x86 uprobes Eric W. Biederman
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Eric W. Biederman @ 2018-09-03 20:44 UTC (permalink / raw)
To: linux-kernel; +Cc: Oleg Nesterov, Linus Torvalds, linux-api, Eric W. Biederman
For userspace to tell the difference between a random signal and an
exception, the exception must include siginfo information.
Using SEND_SIG_FORCED for SIGILL is thus wrong, and it will result
in userspace seeing si_code == SI_USER (like a random signal) instead
of si_code == SI_KERNEL or a more specific si_code as all exceptions
deliver.
Therefore replace force_sig_info(SIGILL, SEND_SIG_FORCE, current)
with force_sig(SIG_ILL, current) which gets this right and is
shorter and easier to type.
Fixes: 014940bad8e4 ("uprobes/x86: Send SIGILL if arch_uprobe_post_xol() fails")
Fixes: 0b5256c7f173 ("uprobes: Send SIGILL if handle_trampoline() fails")
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
kernel/events/uprobes.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 3207a4d26849..2bf792d22087 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1858,7 +1858,7 @@ static void handle_trampoline(struct pt_regs *regs)
sigill:
uprobe_warn(current, "handle uretprobe, sending SIGILL.");
- force_sig_info(SIGILL, SEND_SIG_FORCED, current);
+ force_sig(SIGILL, current);
}
@@ -1966,7 +1966,7 @@ static void handle_singlestep(struct uprobe_task *utask, struct pt_regs *regs)
if (unlikely(err)) {
uprobe_warn(current, "execute the probed insn, sending SIGILL.");
- force_sig_info(SIGILL, SEND_SIG_FORCED, current);
+ force_sig(SIGILL, current);
}
}
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 03/10] signal: Properly deliver SIGSEGV from x86 uprobes
2018-09-03 20:41 [PATCH 00/10] Removing SEND_SIG_FORCED Eric W. Biederman
2018-09-03 20:44 ` [PATCH 01/10] signal: Always ignore SIGKILL and SIGSTOP sent to the global init Eric W. Biederman
2018-09-03 20:44 ` [PATCH 02/10] signal: Properly deliver SIGILL from uprobes Eric W. Biederman
@ 2018-09-03 20:44 ` Eric W. Biederman
2018-09-03 20:44 ` [PATCH 04/10] signal: Always deliver the kernel's SIGKILL and SIGSTOP to a pid namespace init Eric W. Biederman
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Eric W. Biederman @ 2018-09-03 20:44 UTC (permalink / raw)
To: linux-kernel; +Cc: Oleg Nesterov, Linus Torvalds, linux-api, Eric W. Biederman
For userspace to tell the difference between an random signal
and an exception, the exception must include siginfo information.
Using SEND_SIG_FORCED for SIGSEGV is thus wrong, and it will result in
userspace seeing si_code == SI_USER (like a random signal) instead of
si_code == SI_KERNEL or a more specific si_code as all exceptions
deliver.
Therefore replace force_sig_info(SIGSEGV, SEND_SIG_FORCE, current)
with force_sig(SIG_SEGV, current) which gets this right and is shorter
and easier to type.
Fixes: 791eca10107f ("uretprobes/x86: Hijack return address")
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
arch/x86/kernel/uprobes.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
index deb576b23b7c..843feb94a950 100644
--- a/arch/x86/kernel/uprobes.c
+++ b/arch/x86/kernel/uprobes.c
@@ -1086,7 +1086,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
pr_err("return address clobbered: pid=%d, %%sp=%#lx, %%ip=%#lx\n",
current->pid, regs->sp, regs->ip);
- force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
+ force_sig(SIGSEGV, current);
}
return -1;
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 04/10] signal: Always deliver the kernel's SIGKILL and SIGSTOP to a pid namespace init
2018-09-03 20:41 [PATCH 00/10] Removing SEND_SIG_FORCED Eric W. Biederman
` (2 preceding siblings ...)
2018-09-03 20:44 ` [PATCH 03/10] signal: Properly deliver SIGSEGV from x86 uprobes Eric W. Biederman
@ 2018-09-03 20:44 ` Eric W. Biederman
2018-09-03 20:44 ` [PATCH 05/10] signal: send_sig_all no longer needs SEND_SIG_FORCED Eric W. Biederman
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Eric W. Biederman @ 2018-09-03 20:44 UTC (permalink / raw)
To: linux-kernel; +Cc: Oleg Nesterov, Linus Torvalds, linux-api, Eric W. Biederman
Instead of playing whack-a-mole and changing SEND_SIG_PRIV to
SEND_SIG_FORCED throughout the kernel to ensure a pid namespace init
gets signals sent by the kernel, stop allowing a pid namespace init to
ignore SIGKILL or SIGSTOP sent by the kernel. A pid namespace init is
only supposed to be able to ignore signals sent from itself and
children with SIG_DFL.
Fixes: 921cf9f63089 ("signals: protect cinit from unblocked SIG_DFL signals")
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
kernel/signal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/signal.c b/kernel/signal.c
index b33264bb2064..8081ab79e97d 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1039,7 +1039,7 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
result = TRACE_SIGNAL_IGNORED;
if (!prepare_signal(sig, t,
- from_ancestor_ns || (info == SEND_SIG_FORCED)))
+ from_ancestor_ns || (info == SEND_SIG_PRIV) || (info == SEND_SIG_FORCED)))
goto ret;
pending = (type != PIDTYPE_PID) ? &t->signal->shared_pending : &t->pending;
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 05/10] signal: send_sig_all no longer needs SEND_SIG_FORCED
2018-09-03 20:41 [PATCH 00/10] Removing SEND_SIG_FORCED Eric W. Biederman
` (3 preceding siblings ...)
2018-09-03 20:44 ` [PATCH 04/10] signal: Always deliver the kernel's SIGKILL and SIGSTOP to a pid namespace init Eric W. Biederman
@ 2018-09-03 20:44 ` Eric W. Biederman
2018-09-03 20:44 ` [PATCH 06/10] signal: Remove the siginfo paramater from kernel_dqueue_signal Eric W. Biederman
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Eric W. Biederman @ 2018-09-03 20:44 UTC (permalink / raw)
To: linux-kernel; +Cc: Oleg Nesterov, Linus Torvalds, linux-api, Eric W. Biederman
Now that send_signal always delivers SEND_SIG_PRIV signals to a pid
namespace init it is no longer necessary to use SEND_SIG_FORCED when
calling do_send_sig_info to ensure that pid namespace inits are
signaled and possibly killed. Using SEND_SIG_PRIV is sufficient.
So use SEND_SIG_PRIV so that userspace when it receives a SIGTERM can
tell that the kernel sent the signal and not some random userspace
application.
Fixes: b82c32872db2 ("sysrq: use SEND_SIG_FORCED instead of force_sig()")
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
drivers/tty/sysrq.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
index 06ed20dd01ba..ad1ee5d01b53 100644
--- a/drivers/tty/sysrq.c
+++ b/drivers/tty/sysrq.c
@@ -348,7 +348,7 @@ static void send_sig_all(int sig)
if (is_global_init(p))
continue;
- do_send_sig_info(sig, SEND_SIG_FORCED, p, PIDTYPE_MAX);
+ do_send_sig_info(sig, SEND_SIG_PRIV, p, PIDTYPE_MAX);
}
read_unlock(&tasklist_lock);
}
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 06/10] signal: Remove the siginfo paramater from kernel_dqueue_signal
2018-09-03 20:41 [PATCH 00/10] Removing SEND_SIG_FORCED Eric W. Biederman
` (4 preceding siblings ...)
2018-09-03 20:44 ` [PATCH 05/10] signal: send_sig_all no longer needs SEND_SIG_FORCED Eric W. Biederman
@ 2018-09-03 20:44 ` Eric W. Biederman
2018-09-03 20:44 ` [PATCH 07/10] signal: Don't send siginfo to kthreads Eric W. Biederman
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Eric W. Biederman @ 2018-09-03 20:44 UTC (permalink / raw)
To: linux-kernel; +Cc: Oleg Nesterov, Linus Torvalds, linux-api, Eric W. Biederman
None of the callers use the it so remove it.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
drivers/usb/gadget/function/f_mass_storage.c | 2 +-
fs/jffs2/background.c | 2 +-
include/linux/sched/signal.h | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
index ca8a4b53c59f..70038a475c9f 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -2311,7 +2311,7 @@ static void handle_exception(struct fsg_common *common)
* into a high-priority EXIT exception.
*/
for (;;) {
- int sig = kernel_dequeue_signal(NULL);
+ int sig = kernel_dequeue_signal();
if (!sig)
break;
if (sig != SIGUSR1) {
diff --git a/fs/jffs2/background.c b/fs/jffs2/background.c
index 453a6a1fff34..2b4d5013dc5d 100644
--- a/fs/jffs2/background.c
+++ b/fs/jffs2/background.c
@@ -125,7 +125,7 @@ static int jffs2_garbage_collect_thread(void *_c)
if (try_to_freeze())
goto again;
- signr = kernel_dequeue_signal(NULL);
+ signr = kernel_dequeue_signal();
switch(signr) {
case SIGSTOP:
diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
index 1be35729c2c5..9b6968cbde14 100644
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -272,14 +272,14 @@ extern void ignore_signals(struct task_struct *);
extern void flush_signal_handlers(struct task_struct *, int force_default);
extern int dequeue_signal(struct task_struct *tsk, sigset_t *mask, siginfo_t *info);
-static inline int kernel_dequeue_signal(siginfo_t *info)
+static inline int kernel_dequeue_signal(void)
{
struct task_struct *tsk = current;
siginfo_t __info;
int ret;
spin_lock_irq(&tsk->sighand->siglock);
- ret = dequeue_signal(tsk, &tsk->blocked, info ?: &__info);
+ ret = dequeue_signal(tsk, &tsk->blocked, &__info);
spin_unlock_irq(&tsk->sighand->siglock);
return ret;
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 07/10] signal: Don't send siginfo to kthreads.
2018-09-03 20:41 [PATCH 00/10] Removing SEND_SIG_FORCED Eric W. Biederman
` (5 preceding siblings ...)
2018-09-03 20:44 ` [PATCH 06/10] signal: Remove the siginfo paramater from kernel_dqueue_signal Eric W. Biederman
@ 2018-09-03 20:44 ` Eric W. Biederman
2018-09-03 20:44 ` [PATCH 08/10] signal: Never allocate siginfo for SIGKILL or SIGSTOP Eric W. Biederman
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Eric W. Biederman @ 2018-09-03 20:44 UTC (permalink / raw)
To: linux-kernel; +Cc: Oleg Nesterov, Linus Torvalds, linux-api, Eric W. Biederman
Today kernel threads never dequeue siginfo so it is pointless to
enqueue siginfo for them. The usb gadget mass storage driver goes
one farther and uses SEND_SIG_FORCED to guarantee that no siginfo is
even enqueued.
Generalize the optimization of the usb mass storage driver and never
perform an unnecessary allocation when delivering signals to kthreads.
Switch the mass storage driver from sending signals with
SEND_SIG_FORCED to SEND_SIG_PRIV. As using SEND_SIG_FORCED is now
unnecessary.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
drivers/usb/gadget/function/f_mass_storage.c | 2 +-
kernel/signal.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/function/f_mass_storage.c b/drivers/usb/gadget/function/f_mass_storage.c
index 70038a475c9f..cb402e7a1e9b 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -403,7 +403,7 @@ static void raise_exception(struct fsg_common *common, enum fsg_state new_state)
common->exception_req_tag = common->ep0_req_tag;
common->state = new_state;
if (common->thread_task)
- send_sig_info(SIGUSR1, SEND_SIG_FORCED,
+ send_sig_info(SIGUSR1, SEND_SIG_PRIV,
common->thread_task);
}
spin_unlock_irqrestore(&common->lock, flags);
diff --git a/kernel/signal.c b/kernel/signal.c
index 8081ab79e97d..20931a892ace 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1057,7 +1057,7 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
* fast-pathed signals for kernel-internal things like SIGSTOP
* or SIGKILL.
*/
- if (info == SEND_SIG_FORCED)
+ if ((info == SEND_SIG_FORCED) || (t->flags & PF_KTHREAD))
goto out_set;
/*
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 08/10] signal: Never allocate siginfo for SIGKILL or SIGSTOP
2018-09-03 20:41 [PATCH 00/10] Removing SEND_SIG_FORCED Eric W. Biederman
` (6 preceding siblings ...)
2018-09-03 20:44 ` [PATCH 07/10] signal: Don't send siginfo to kthreads Eric W. Biederman
@ 2018-09-03 20:44 ` Eric W. Biederman
2018-09-03 20:44 ` [PATCH 09/10] signal: Use SEND_SIG_PRIV not SEND_SIG_FORCED with SIGKILL and SIGSTOP Eric W. Biederman
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Eric W. Biederman @ 2018-09-03 20:44 UTC (permalink / raw)
To: linux-kernel; +Cc: Oleg Nesterov, Linus Torvalds, linux-api, Eric W. Biederman
The SIGKILL and SIGSTOP signals are never delivered to userspace so
queued siginfo for these signals can never be observed. Therefore
remove the chance of failure by never even attempting to allocate
siginfo in those cases.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
kernel/signal.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/kernel/signal.c b/kernel/signal.c
index 20931a892ace..d7d1adf735f4 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1054,10 +1054,11 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
result = TRACE_SIGNAL_DELIVERED;
/*
- * fast-pathed signals for kernel-internal things like SIGSTOP
- * or SIGKILL.
+ * Skip useless siginfo allocation for SIGKILL SIGSTOP,
+ * and kernel threads.
*/
- if ((info == SEND_SIG_FORCED) || (t->flags & PF_KTHREAD))
+ if ((info == SEND_SIG_FORCED) ||
+ sig_kernel_only(sig) || (t->flags & PF_KTHREAD))
goto out_set;
/*
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 09/10] signal: Use SEND_SIG_PRIV not SEND_SIG_FORCED with SIGKILL and SIGSTOP
2018-09-03 20:41 [PATCH 00/10] Removing SEND_SIG_FORCED Eric W. Biederman
` (7 preceding siblings ...)
2018-09-03 20:44 ` [PATCH 08/10] signal: Never allocate siginfo for SIGKILL or SIGSTOP Eric W. Biederman
@ 2018-09-03 20:44 ` Eric W. Biederman
2018-09-03 20:44 ` [PATCH 10/10] signal: Remove SEND_SIG_FORCED Eric W. Biederman
2018-09-08 11:03 ` [PATCH 00/10] Removing SEND_SIG_FORCED Thomas Gleixner
10 siblings, 0 replies; 12+ messages in thread
From: Eric W. Biederman @ 2018-09-03 20:44 UTC (permalink / raw)
To: linux-kernel; +Cc: Oleg Nesterov, Linus Torvalds, linux-api, Eric W. Biederman
Now that siginfo is never allocated for SIGKILL and SIGSTOP there is
no difference between SEND_SIG_PRIV and SEND_SIG_FORCED for SIGKILL
and SIGSTOP. This makes SEND_SIG_FORCED unnecessary and redundant in
the presence of SIGKILL and SIGSTOP. Therefore change users of
SEND_SIG_FORCED that are sending SIGKILL or SIGSTOP to use
SEND_SIG_PRIV instead.
This removes the last users of SEND_SIG_FORCED.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
kernel/pid_namespace.c | 2 +-
kernel/ptrace.c | 4 ++--
mm/oom_kill.c | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index 2a2ac53d8b8b..c8d53397bbdd 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -216,7 +216,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
idr_for_each_entry_continue(&pid_ns->idr, pid, nr) {
task = pid_task(pid, PIDTYPE_PID);
if (task && !__fatal_signal_pending(task))
- send_sig_info(SIGKILL, SEND_SIG_FORCED, task);
+ send_sig_info(SIGKILL, SEND_SIG_PRIV, task);
}
read_unlock(&tasklist_lock);
rcu_read_unlock();
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 21fec73d45d4..45f77a1b9c97 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -396,7 +396,7 @@ static int ptrace_attach(struct task_struct *task, long request,
/* SEIZE doesn't trap tracee on attach */
if (!seize)
- send_sig_info(SIGSTOP, SEND_SIG_FORCED, task);
+ send_sig_info(SIGSTOP, SEND_SIG_PRIV, task);
spin_lock(&task->sighand->siglock);
@@ -563,7 +563,7 @@ void exit_ptrace(struct task_struct *tracer, struct list_head *dead)
list_for_each_entry_safe(p, n, &tracer->ptraced, ptrace_entry) {
if (unlikely(p->ptrace & PT_EXITKILL))
- send_sig_info(SIGKILL, SEND_SIG_FORCED, p);
+ send_sig_info(SIGKILL, SEND_SIG_PRIV, p);
if (__ptrace_detach(tracer, p))
list_add(&p->ptrace_entry, dead);
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index b5b25e4dcbbb..3bcfeaaeed87 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -858,7 +858,7 @@ static void __oom_kill_process(struct task_struct *victim)
* in order to prevent the OOM victim from depleting the memory
* reserves from the user space under its control.
*/
- do_send_sig_info(SIGKILL, SEND_SIG_FORCED, victim, PIDTYPE_TGID);
+ do_send_sig_info(SIGKILL, SEND_SIG_PRIV, victim, PIDTYPE_TGID);
mark_oom_victim(victim);
pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n",
task_pid_nr(victim), victim->comm, K(victim->mm->total_vm),
@@ -896,7 +896,7 @@ static void __oom_kill_process(struct task_struct *victim)
*/
if (unlikely(p->flags & PF_KTHREAD))
continue;
- do_send_sig_info(SIGKILL, SEND_SIG_FORCED, p, PIDTYPE_TGID);
+ do_send_sig_info(SIGKILL, SEND_SIG_PRIV, p, PIDTYPE_TGID);
}
rcu_read_unlock();
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 10/10] signal: Remove SEND_SIG_FORCED
2018-09-03 20:41 [PATCH 00/10] Removing SEND_SIG_FORCED Eric W. Biederman
` (8 preceding siblings ...)
2018-09-03 20:44 ` [PATCH 09/10] signal: Use SEND_SIG_PRIV not SEND_SIG_FORCED with SIGKILL and SIGSTOP Eric W. Biederman
@ 2018-09-03 20:44 ` Eric W. Biederman
2018-09-08 11:03 ` [PATCH 00/10] Removing SEND_SIG_FORCED Thomas Gleixner
10 siblings, 0 replies; 12+ messages in thread
From: Eric W. Biederman @ 2018-09-03 20:44 UTC (permalink / raw)
To: linux-kernel; +Cc: Oleg Nesterov, Linus Torvalds, linux-api, Eric W. Biederman
There are no more users of SEND_SIG_FORCED so it may be safely removed.
Remove the definition of SEND_SIG_FORCED, it's use in is_si_special,
it's use in TP_STORE_SIGINFO, and it's use in __send_signal as without
any users the uses of SEND_SIG_FORCED are now unncessary.
This makes the code simpler, easier to understand and use. Users of
signal sending functions now no longer need to ask themselves do I
need to use SEND_SIG_FORCED.
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
include/linux/sched/signal.h | 1 -
include/trace/events/signal.h | 3 +--
kernel/signal.c | 7 +++----
3 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
index 9b6968cbde14..9e07f3521549 100644
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -477,7 +477,6 @@ static inline int kill_cad_pid(int sig, int priv)
/* These can be the second arg to send_sig_info/send_group_sig_info. */
#define SEND_SIG_NOINFO ((struct siginfo *) 0)
#define SEND_SIG_PRIV ((struct siginfo *) 1)
-#define SEND_SIG_FORCED ((struct siginfo *) 2)
/*
* True if we are on the alternate signal stack.
diff --git a/include/trace/events/signal.h b/include/trace/events/signal.h
index 86582923d51c..3deeed50ffd0 100644
--- a/include/trace/events/signal.h
+++ b/include/trace/events/signal.h
@@ -11,8 +11,7 @@
#define TP_STORE_SIGINFO(__entry, info) \
do { \
- if (info == SEND_SIG_NOINFO || \
- info == SEND_SIG_FORCED) { \
+ if (info == SEND_SIG_NOINFO) { \
__entry->errno = 0; \
__entry->code = SI_USER; \
} else if (info == SEND_SIG_PRIV) { \
diff --git a/kernel/signal.c b/kernel/signal.c
index d7d1adf735f4..ec136fda457a 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -736,7 +736,7 @@ static void flush_sigqueue_mask(sigset_t *mask, struct sigpending *s)
static inline int is_si_special(const struct siginfo *info)
{
- return info <= SEND_SIG_FORCED;
+ return info <= SEND_SIG_PRIV;
}
static inline bool si_fromuser(const struct siginfo *info)
@@ -1039,7 +1039,7 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
result = TRACE_SIGNAL_IGNORED;
if (!prepare_signal(sig, t,
- from_ancestor_ns || (info == SEND_SIG_PRIV) || (info == SEND_SIG_FORCED)))
+ from_ancestor_ns || (info == SEND_SIG_PRIV)))
goto ret;
pending = (type != PIDTYPE_PID) ? &t->signal->shared_pending : &t->pending;
@@ -1057,8 +1057,7 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
* Skip useless siginfo allocation for SIGKILL SIGSTOP,
* and kernel threads.
*/
- if ((info == SEND_SIG_FORCED) ||
- sig_kernel_only(sig) || (t->flags & PF_KTHREAD))
+ if (sig_kernel_only(sig) || (t->flags & PF_KTHREAD))
goto out_set;
/*
--
2.17.1
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 00/10] Removing SEND_SIG_FORCED
2018-09-03 20:41 [PATCH 00/10] Removing SEND_SIG_FORCED Eric W. Biederman
` (9 preceding siblings ...)
2018-09-03 20:44 ` [PATCH 10/10] signal: Remove SEND_SIG_FORCED Eric W. Biederman
@ 2018-09-08 11:03 ` Thomas Gleixner
10 siblings, 0 replies; 12+ messages in thread
From: Thomas Gleixner @ 2018-09-08 11:03 UTC (permalink / raw)
To: Eric W. Biederman; +Cc: linux-kernel, Oleg Nesterov, Linus Torvalds, linux-api
On Mon, 3 Sep 2018, Eric W. Biederman wrote:
> SEND_SIG_FORCED has two functions. It forces a pid namespace init to
> receive a signal it would ordinarily ignore, and it causes a siginfo to
> not be allocated for a signal.
>
> This patchset makes __send_signal a little bit smarter so that it can
> detect when to apply these optimizations and the senders of signals
> don't have to worry about them.
>
> The coupling of forcing a signal to the pid namespace init and not
> allocating siginfo resulted in serveral minor bugs where a signal
> sent by the kernel was marked SI_USER suggesting another userspace
> process sent that signal. I have cc'd linux-api in case anyone cares
> about these minor userspace visible differences.
>
> Unless someone notices a bug I intend to merge these changes through my
> tree during the next merge window. While there are numerous fixes here
> none of them appear to be the kind that fixes real world problems so I
> don't see any urgency here.
>
> Please look read and send my your review. I will be out for about a
> week so I will address any comments when I get back.
Went through it carefuly and could not spot anything. Great work!
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
^ permalink raw reply [flat|nested] 12+ messages in thread