* Remove 'handler' parameter to tracehook functions
2009-01-07 7:45 [PATCH 0/7][v6] Container-init signal semantics Sukadev Bhattiprolu
@ 2009-01-07 7:49 ` Sukadev Bhattiprolu
2009-01-07 7:50 ` [PATCH 2/7][v6] Protect init from unwanted signals more Sukadev Bhattiprolu
` (6 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Sukadev Bhattiprolu @ 2009-01-07 7:49 UTC (permalink / raw)
To: oleg, ebiederm, roland, bastian; +Cc: containers, linux-kernel, xemul
From: Oleg Nesterov <oleg@redhat.com>
Date: Wed, 24 Dec 2008 13:35:17 -0800
Subject: [PATCH 1/7][v6] Remove 'handler' parameter to tracehook functions
Based on an earlier patch submitted by Oleg Nesterov and comments
from Roland McGrath (http://lkml.org/lkml/2008/11/19/258).
The handler parameter is currently unused in the tracehook functions.
Besides, the tracehook functions are called with siglock held, so the
functions can check the handler if they later need to.
Removing the parameter simiplifies changes to sig_ignored() in a follow-on
patch.
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Acked-by: Roland McGrath <roland@redhat.com>
---
arch/x86/kernel/ptrace.c | 2 +-
include/linux/tracehook.h | 13 ++++---------
kernel/signal.c | 6 +++---
3 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 0a6d8c1..d6ef716 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -1585,6 +1585,6 @@ asmregparm void syscall_trace_leave(struct pt_regs *regs)
* system call instruction.
*/
if (test_thread_flag(TIF_SINGLESTEP) &&
- tracehook_consider_fatal_signal(current, SIGTRAP, SIG_DFL))
+ tracehook_consider_fatal_signal(current, SIGTRAP))
send_sigtrap(current, regs, 0, TRAP_BRKPT);
}
diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
index 6186a78..eb4c654 100644
--- a/include/linux/tracehook.h
+++ b/include/linux/tracehook.h
@@ -388,17 +388,14 @@ static inline void tracehook_signal_handler(int sig, siginfo_t *info,
* tracehook_consider_ignored_signal - suppress short-circuit of ignored signal
* @task: task receiving the signal
* @sig: signal number being sent
- * @handler: %SIG_IGN or %SIG_DFL
*
* Return zero iff tracing doesn't care to examine this ignored signal,
* so it can short-circuit normal delivery and never even get queued.
- * Either @handler is %SIG_DFL and @sig's default is ignore, or it's %SIG_IGN.
*
* Called with @task->sighand->siglock held.
*/
static inline int tracehook_consider_ignored_signal(struct task_struct *task,
- int sig,
- void __user *handler)
+ int sig)
{
return (task_ptrace(task) & PT_PTRACED) != 0;
}
@@ -407,19 +404,17 @@ static inline int tracehook_consider_ignored_signal(struct task_struct *task,
* tracehook_consider_fatal_signal - suppress special handling of fatal signal
* @task: task receiving the signal
* @sig: signal number being sent
- * @handler: %SIG_DFL or %SIG_IGN
*
* Return nonzero to prevent special handling of this termination signal.
- * Normally @handler is %SIG_DFL. It can be %SIG_IGN if @sig is ignored,
- * in which case force_sig() is about to reset it to %SIG_DFL.
+ * Normally handler for signal is %SIG_DFL. It can be %SIG_IGN if @sig is
+ * ignored, in which case force_sig() is about to reset it to %SIG_DFL.
* When this returns zero, this signal might cause a quick termination
* that does not give the debugger a chance to intercept the signal.
*
* Called with or without @task->sighand->siglock held.
*/
static inline int tracehook_consider_fatal_signal(struct task_struct *task,
- int sig,
- void __user *handler)
+ int sig)
{
return (task_ptrace(task) & PT_PTRACED) != 0;
}
diff --git a/kernel/signal.c b/kernel/signal.c
index 2a64304..7945e71 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -72,7 +72,7 @@ static int sig_ignored(struct task_struct *t, int sig)
/*
* Tracers may want to know about even ignored signals.
*/
- return !tracehook_consider_ignored_signal(t, sig, handler);
+ return !tracehook_consider_ignored_signal(t, sig);
}
/*
@@ -316,7 +316,7 @@ int unhandled_signal(struct task_struct *tsk, int sig)
return 1;
if (handler != SIG_IGN && handler != SIG_DFL)
return 0;
- return !tracehook_consider_fatal_signal(tsk, sig, handler);
+ return !tracehook_consider_fatal_signal(tsk, sig);
}
@@ -775,7 +775,7 @@ static void complete_signal(int sig, struct task_struct *p, int group)
!(signal->flags & (SIGNAL_UNKILLABLE | SIGNAL_GROUP_EXIT)) &&
!sigismember(&t->real_blocked, sig) &&
(sig == SIGKILL ||
- !tracehook_consider_fatal_signal(t, sig, SIG_DFL))) {
+ !tracehook_consider_fatal_signal(t, sig))) {
/*
* This signal will be fatal to the whole group.
*/
--
1.5.2.5
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 2/7][v6] Protect init from unwanted signals more
2009-01-07 7:45 [PATCH 0/7][v6] Container-init signal semantics Sukadev Bhattiprolu
2009-01-07 7:49 ` Remove 'handler' parameter to tracehook functions Sukadev Bhattiprolu
@ 2009-01-07 7:50 ` Sukadev Bhattiprolu
2009-01-07 7:51 ` [PATCH 3/7][v6] Add from_ancestor_ns parameter to send_signal() Sukadev Bhattiprolu
` (5 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Sukadev Bhattiprolu @ 2009-01-07 7:50 UTC (permalink / raw)
To: oleg, ebiederm, roland, bastian; +Cc: containers, linux-kernel, xemul
From: Oleg Nesterov <oleg@redhat.com>
Date: Wed, 24 Dec 2008 13:35:23 -0800
Subject: [PATCH 2/7][v6] Protect init from unwanted signals more
(This is a modified version of the patch submitted by Oleg Nesterov
http://lkml.org/lkml/2008/11/18/249 and tries to address comments
that came up in that discussion)
init ignores the SIG_DFL signals but we queue them anyway, including
SIGKILL. This is mostly OK, the signal will be dropped silently when
dequeued, but the pending SIGKILL has 2 bad implications:
- it implies fatal_signal_pending(), so we confuse things
like wait_for_completion_killable/lock_page_killable.
- for the sub-namespace inits, the pending SIGKILL can
mask (legacy_queue) the subsequent SIGKILL from the
parent namespace which must kill cinit reliably.
(preparation, cinits don't have SIGNAL_UNKILLABLE yet)
The patch can't help when init is ptraced, but ptracing of init is
not "safe" anyway.
Changelog[v5]:
- (Oleg Nesterov) Remove SIG_IGN check in sig_task_ignored()
and let sig_handler_ignored() check SIG_IGN.
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Acked-by: Roland McGrath <roland@redhat.com>
---
kernel/signal.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/kernel/signal.c b/kernel/signal.c
index 7945e71..87f3f30 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -53,10 +53,21 @@ static int sig_handler_ignored(void __user *handler, int sig)
(handler == SIG_DFL && sig_kernel_ignore(sig));
}
-static int sig_ignored(struct task_struct *t, int sig)
+static int sig_task_ignored(struct task_struct *t, int sig)
{
void __user *handler;
+ handler = sig_handler(t, sig);
+
+ if (unlikely(t->signal->flags & SIGNAL_UNKILLABLE) &&
+ handler == SIG_DFL)
+ return 1;
+
+ return sig_handler_ignored(handler, sig);
+}
+
+static int sig_ignored(struct task_struct *t, int sig)
+{
/*
* Blocked signals are never ignored, since the
* signal handler may change by the time it is
@@ -65,8 +76,7 @@ static int sig_ignored(struct task_struct *t, int sig)
if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig))
return 0;
- handler = sig_handler(t, sig);
- if (!sig_handler_ignored(handler, sig))
+ if (!sig_task_ignored(t, sig))
return 0;
/*
--
1.5.2.5
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 3/7][v6] Add from_ancestor_ns parameter to send_signal()
2009-01-07 7:45 [PATCH 0/7][v6] Container-init signal semantics Sukadev Bhattiprolu
2009-01-07 7:49 ` Remove 'handler' parameter to tracehook functions Sukadev Bhattiprolu
2009-01-07 7:50 ` [PATCH 2/7][v6] Protect init from unwanted signals more Sukadev Bhattiprolu
@ 2009-01-07 7:51 ` Sukadev Bhattiprolu
2009-01-07 7:51 ` [PATCH 4/7][v6] Define siginfo_from_ancestor_ns() Sukadev Bhattiprolu
` (4 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Sukadev Bhattiprolu @ 2009-01-07 7:51 UTC (permalink / raw)
To: oleg, ebiederm, roland, bastian; +Cc: containers, linux-kernel, xemul
From: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Date: Tue, 6 Jan 2009 17:28:05 -0800
Subject: [PATCH 3/7][v6] Add from_ancestor_ns parameter to send_signal()
send_signal() (or its helper) needs to determine the pid namespace
of the sender. But a signal sent via kill_pid_info_as_uid() comes
from within the kernel and send_signal() does not need to determine
the pid namespace of the sender. So define a helper for send_signal()
which takes an additional parameter, 'from_ancestor_ns' and have
kill_pid_info_as_uid() use that helper directly.
The 'from_ancestor_ns' parameter will be used in a follow-on patch.
Changelog[v6]:
- New patch added to this patchset, based on suggestions from
Roland McGrath and Oleg Nesterov.
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
kernel/signal.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/kernel/signal.c b/kernel/signal.c
index 87f3f30..bb3b6f5 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -821,8 +821,8 @@ static inline int legacy_queue(struct sigpending *signals, int sig)
return (sig < SIGRTMIN) && sigismember(&signals->signal, sig);
}
-static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
- int group)
+static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
+ int group, int from_ancestor_ns)
{
struct sigpending *pending;
struct sigqueue *q;
@@ -896,6 +896,12 @@ out_set:
return 0;
}
+static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
+ int group)
+{
+ return __send_signal(sig, info, t, group, 0);
+}
+
int print_fatal_signals;
static void print_fatal_signal(struct pt_regs *regs, int signr)
@@ -1138,7 +1144,7 @@ int kill_pid_info_as_uid(int sig, struct siginfo *info, struct pid *pid,
if (sig && p->sighand) {
unsigned long flags;
spin_lock_irqsave(&p->sighand->siglock, flags);
- ret = __group_send_sig_info(sig, info, p);
+ ret = __send_signal(sig, info, p, 1, 0);
spin_unlock_irqrestore(&p->sighand->siglock, flags);
}
out_unlock:
--
1.5.2.5
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 4/7][v6] Define siginfo_from_ancestor_ns()
2009-01-07 7:45 [PATCH 0/7][v6] Container-init signal semantics Sukadev Bhattiprolu
` (2 preceding siblings ...)
2009-01-07 7:51 ` [PATCH 3/7][v6] Add from_ancestor_ns parameter to send_signal() Sukadev Bhattiprolu
@ 2009-01-07 7:51 ` Sukadev Bhattiprolu
2009-01-07 7:51 ` [PATCH 5/7][v6] Protect cinit from unblocked SIG_DFL signals Sukadev Bhattiprolu
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Sukadev Bhattiprolu @ 2009-01-07 7:51 UTC (permalink / raw)
To: oleg, ebiederm, roland, bastian; +Cc: containers, linux-kernel, xemul
From: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Date: Wed, 24 Dec 2008 13:46:02 -0800
Subject: [PATCH 4/7][v6] Define siginfo_from_ancestor_ns()
Determine if sender of a signal is from an ancestor namespace. This
function will be used in a follow-on patch.
This is based on discussions on the patch from Oleg Nesterov and me
http://lkml.org/lkml/2008/11/25/462.
Changelog[v6]:
- (Oleg Nesterov) Simplify/correct comments
- (Oleg Nesterov) Remove 'ns == NULL' check since task_active_pid_ns()
will return a valid ns for the target.
- (Roland Mcgrath) Remove incorrect SI_ASYNCIO check in
siginfo_from_user().
Changelog[v5]:
- (Oleg Nesterov) Put siginfo_from_ancestor_ns() back under
CONFIG_PID_NS.
- (Oleg Nesterov) Remove the warning in rt_sigqueueinfo().
Changelog[v4]:
- siginfo_from_ancestor_ns() is fairly clean and it does not need
to be under CONFIG_PID_NS. Only siginfo_from_user() needs to be.
- Warn if rt_sigqueueinfo() uses SI_ASYNCIO.
- Added a check for pid-ns of receiver being NULL (in case it is
exiting).
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
kernel/signal.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/kernel/signal.c b/kernel/signal.c
index bb3b6f5..d0dfa0d 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -820,6 +820,43 @@ static inline int legacy_queue(struct sigpending *signals, int sig)
{
return (sig < SIGRTMIN) && sigismember(&signals->signal, sig);
}
+/*
+ * Return 1 if this signal originated directly from a user process (i.e via
+ * kill(), tkill(), sigqueue()). Return 0 otherwise.
+ */
+#ifdef CONFIG_PID_NS
+static inline int siginfo_from_user(siginfo_t *info)
+{
+ if (!is_si_special(info) && SI_FROMUSER(info))
+ return 1;
+
+ return 0;
+}
+
+static inline int siginfo_from_ancestor_ns(struct task_struct *t,
+ siginfo_t *info)
+{
+ /*
+ * If we do not have a pid in the receiver's namespace,
+ * we must be from an ancestor namespace.
+ */
+ if (siginfo_from_user(info) &&
+ task_pid_nr_ns(current, task_active_pid_ns(t)) <= 0) {
+ return 1;
+ }
+
+ return 0;
+}
+
+#else
+
+static inline int siginfo_from_ancestor_ns(struct task_struct *t,
+ siginfo_t *info)
+{
+ return 0;
+}
+
+#endif
static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
int group, int from_ancestor_ns)
--
1.5.2.5
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 5/7][v6] Protect cinit from unblocked SIG_DFL signals
2009-01-07 7:45 [PATCH 0/7][v6] Container-init signal semantics Sukadev Bhattiprolu
` (3 preceding siblings ...)
2009-01-07 7:51 ` [PATCH 4/7][v6] Define siginfo_from_ancestor_ns() Sukadev Bhattiprolu
@ 2009-01-07 7:51 ` Sukadev Bhattiprolu
2009-01-07 7:52 ` [PATCH 6/7][v6] Protect cinit from blocked fatal signals Sukadev Bhattiprolu
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: Sukadev Bhattiprolu @ 2009-01-07 7:51 UTC (permalink / raw)
To: oleg, ebiederm, roland, bastian; +Cc: containers, linux-kernel, xemul
From: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Date: Wed, 24 Dec 2008 14:03:57 -0800
Subject: [PATCH 5/7][v6] Protect cinit from unblocked SIG_DFL signals
Drop early any SIG_DFL or SIG_IGN signals to container-init from within
the same container. But queue SIGSTOP and SIGKILL to the container-init
if they are from an ancestor container.
Blocked, fatal signals (i.e when SIG_DFL is to terminate) from within the
container can still terminate the container-init. That will be addressed
in the next patch.
Note: To be bisect-safe, SIGNAL_UNKILLABLE will be set for container-inits
in a follow-on patch. Until then, this patch is just a preparatory
step.
Changelog[v6]:
- (Roland McGrath) Remove unnecessary helper signal_task_unkillable()
and fold checks into sig_task_ignored().
Changelog[v4]:
- (Oleg Nesterov) Remove SIGNAL_UNKILLABLE_FROM_NS and rename
'same_ns' to 'from_ancestor_ns'.
- SIGNAL_UNKILLABLE is not yet set for container-inits (will be
set in follow-on patch).
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
kernel/signal.c | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/kernel/signal.c b/kernel/signal.c
index d0dfa0d..3156dab 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -53,20 +53,21 @@ static int sig_handler_ignored(void __user *handler, int sig)
(handler == SIG_DFL && sig_kernel_ignore(sig));
}
-static int sig_task_ignored(struct task_struct *t, int sig)
+static int sig_task_ignored(struct task_struct *t, int sig,
+ int from_ancestor_ns)
{
void __user *handler;
handler = sig_handler(t, sig);
if (unlikely(t->signal->flags & SIGNAL_UNKILLABLE) &&
- handler == SIG_DFL)
+ handler == SIG_DFL && !from_ancestor_ns)
return 1;
return sig_handler_ignored(handler, sig);
}
-static int sig_ignored(struct task_struct *t, int sig)
+static int sig_ignored(struct task_struct *t, int sig, int from_ancestor_ns)
{
/*
* Blocked signals are never ignored, since the
@@ -76,7 +77,7 @@ static int sig_ignored(struct task_struct *t, int sig)
if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig))
return 0;
- if (!sig_task_ignored(t, sig))
+ if (!sig_task_ignored(t, sig, from_ancestor_ns))
return 0;
/*
@@ -632,7 +633,7 @@ static int check_kill_permission(int sig, struct siginfo *info,
* Returns true if the signal should be actually delivered, otherwise
* it should be dropped.
*/
-static int prepare_signal(int sig, struct task_struct *p)
+static int prepare_signal(int sig, struct task_struct *p, int from_ancestor_ns)
{
struct signal_struct *signal = p->signal;
struct task_struct *t;
@@ -716,7 +717,7 @@ static int prepare_signal(int sig, struct task_struct *p)
}
}
- return !sig_ignored(p, sig);
+ return !sig_ignored(p, sig, from_ancestor_ns);
}
/*
@@ -867,7 +868,8 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
trace_sched_signal_send(sig, t);
assert_spin_locked(&t->sighand->siglock);
- if (!prepare_signal(sig, t))
+
+ if (!prepare_signal(sig, t, from_ancestor_ns))
return 0;
pending = group ? &t->signal->shared_pending : &t->pending;
@@ -936,7 +938,11 @@ out_set:
static int send_signal(int sig, struct siginfo *info, struct task_struct *t,
int group)
{
- return __send_signal(sig, info, t, group, 0);
+ int from_ancestor_ns;
+
+ from_ancestor_ns = siginfo_from_ancestor_ns(t, info);
+
+ return __send_signal(sig, info, t, group, from_ancestor_ns);
}
int print_fatal_signals;
@@ -1368,7 +1374,7 @@ int send_sigqueue(struct sigqueue *q, struct task_struct *t, int group)
goto ret;
ret = 1; /* the signal is ignored */
- if (!prepare_signal(sig, t))
+ if (!prepare_signal(sig, t, 1))
goto out;
ret = 0;
--
1.5.2.5
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH 6/7][v6] Protect cinit from blocked fatal signals
2009-01-07 7:45 [PATCH 0/7][v6] Container-init signal semantics Sukadev Bhattiprolu
` (4 preceding siblings ...)
2009-01-07 7:51 ` [PATCH 5/7][v6] Protect cinit from unblocked SIG_DFL signals Sukadev Bhattiprolu
@ 2009-01-07 7:52 ` Sukadev Bhattiprolu
2009-01-11 6:15 ` Oleg Nesterov
2009-01-07 7:52 ` [PATCH 7/7][v6] SI_USER: Masquerade si_pid when crossing pid ns boundary Sukadev Bhattiprolu
2009-01-11 6:04 ` [PATCH 0/7][v6] Container-init signal semantics Oleg Nesterov
7 siblings, 1 reply; 11+ messages in thread
From: Sukadev Bhattiprolu @ 2009-01-07 7:52 UTC (permalink / raw)
To: oleg, ebiederm, roland, bastian; +Cc: containers, linux-kernel, xemul
From: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Date: Wed, 24 Dec 2008 14:04:24 -0800
Subject: [PATCH 6/7][v6] Protect cinit from blocked fatal signals
Normally SIG_DFL signals to global and container-init are dropped early.
But if a signal is blocked when it is posted, we cannot drop the signal
since the receiver may install a handler before unblocking the signal.
Once this signal is queued however, the receiver container-init has
no way of knowing if the signal was sent from an ancestor or descendant
namespace. This patch ensures that contianer-init drops all SIG_DFL
signals in get_signal_to_deliver() except SIGKILL/SIGSTOP.
If SIGSTOP/SIGKILL originate from a descendant of container-init they
are never queued (i.e dropped in sig_ignored() in an earler patch).
If SIGSTOP/SIGKILL originate from parent namespace, the signal is queued
and container-init processes the signal.
IOW, if get_signal_to_deliver() sees a sig_kernel_only() signal for global
or container-init, the signal must have been generated internally or must
have come from an ancestor ns and we process the signal.
Further, the signal_group_exit() check was needed to cover the case of
a multi-threaded init sending SIGKILL to other threads when doing an
exit() or exec(). But since the new sig_kernel_only() check covers the
SIGKILL, the signal_group_exit() check is no longer needed and can be
removed.
Finally, now that we have all pieces in place, set SIGNAL_UNKILLABLE for
container-inits.
Changelog[v6]:
- Add a note regarding the signal_group_exit() in patch description.
Changelog[v5]:
- (Oleg Nesterov) Drop signal_unkillable(), simplify check in
get_signal_to_deliver() and drop check for signal_group_exit()
since it is covered by sig_kernel_only().
Changelog[v4]:
- Rename sig_unkillable() to unkillable_by_sig()
- Remove SIGNAL_UNKILLABLE_FROM_NS flag and simplify (Oleg Nesterov)
- Set SIGNAL_UNKILLABLE for container-init in this patch.
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
kernel/fork.c | 2 ++
kernel/signal.c | 9 ++++++++-
2 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/kernel/fork.c b/kernel/fork.c
index dba2d3f..d3e93ef 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -812,6 +812,8 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
atomic_set(&sig->live, 1);
init_waitqueue_head(&sig->wait_chldexit);
sig->flags = 0;
+ if (clone_flags & CLONE_NEWPID)
+ sig->flags |= SIGNAL_UNKILLABLE;
sig->group_exit_code = 0;
sig->group_exit_task = NULL;
sig->group_stop_count = 0;
diff --git a/kernel/signal.c b/kernel/signal.c
index 3156dab..6ad47c0 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1890,9 +1890,16 @@ relock:
/*
* Global init gets no signals it doesn't want.
+ * Container-init gets no signals it doesn't want from same
+ * container.
+ *
+ * Note that if global/container-init sees a sig_kernel_only()
+ * signal here, the signal must have been generated internally
+ * or must have come from an ancestor namespace. In either
+ * case, the signal cannot be dropped.
*/
if (unlikely(signal->flags & SIGNAL_UNKILLABLE) &&
- !signal_group_exit(signal))
+ !sig_kernel_only(signr))
continue;
if (sig_kernel_stop(signr)) {
--
1.5.2.5
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH 6/7][v6] Protect cinit from blocked fatal signals
2009-01-07 7:52 ` [PATCH 6/7][v6] Protect cinit from blocked fatal signals Sukadev Bhattiprolu
@ 2009-01-11 6:15 ` Oleg Nesterov
0 siblings, 0 replies; 11+ messages in thread
From: Oleg Nesterov @ 2009-01-11 6:15 UTC (permalink / raw)
To: Sukadev Bhattiprolu
Cc: ebiederm, roland, bastian, containers, linux-kernel, xemul
On 01/06, Sukadev Bhattiprolu wrote:
>
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -1890,9 +1890,16 @@ relock:
>
> /*
> * Global init gets no signals it doesn't want.
> + * Container-init gets no signals it doesn't want from same
> + * container.
> + *
> + * Note that if global/container-init sees a sig_kernel_only()
> + * signal here, the signal must have been generated internally
> + * or must have come from an ancestor namespace. In either
> + * case, the signal cannot be dropped.
> */
> if (unlikely(signal->flags & SIGNAL_UNKILLABLE) &&
> - !signal_group_exit(signal))
> + !sig_kernel_only(signr))
Just for record. We still have small problem with fatal_signal_pending(cinit),
we should add a similar change to complete_signal to ensure that the pending
SIGKILL implies SIGNAL_GROUP_EXIT. But this needs another patch, and this
series is imho fine.
Oleg.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 7/7][v6] SI_USER: Masquerade si_pid when crossing pid ns boundary
2009-01-07 7:45 [PATCH 0/7][v6] Container-init signal semantics Sukadev Bhattiprolu
` (5 preceding siblings ...)
2009-01-07 7:52 ` [PATCH 6/7][v6] Protect cinit from blocked fatal signals Sukadev Bhattiprolu
@ 2009-01-07 7:52 ` Sukadev Bhattiprolu
2009-01-11 6:04 ` [PATCH 0/7][v6] Container-init signal semantics Oleg Nesterov
7 siblings, 0 replies; 11+ messages in thread
From: Sukadev Bhattiprolu @ 2009-01-07 7:52 UTC (permalink / raw)
To: oleg, ebiederm, roland, bastian; +Cc: containers, linux-kernel, xemul
From: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Date: Wed, 24 Dec 2008 14:14:18 -0800
Subject: [PATCH 7/7][v6] SI_USER: Masquerade si_pid when crossing pid ns boundary
When sending a signal to a descendant namespace, set ->si_pid to 0 since
the sender does not have a pid in the receiver's namespace.
Note:
- If rt_sigqueueinfo() sets si_code to SI_USER when sending a
signal across a pid namespace boundary, the value in ->si_pid
will be cleared to 0.
Changelog[v5]:
- (Oleg Nesterov) Address both sys_kill() and sys_tkill() cases
in send_signal() to simplify code (this drops patch 7/7 from
earlier version of patchset).
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
kernel/signal.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/kernel/signal.c b/kernel/signal.c
index 6ad47c0..d96ac1a 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -917,6 +917,8 @@ static int __send_signal(int sig, struct siginfo *info, struct task_struct *t,
break;
default:
copy_siginfo(&q->info, info);
+ if (from_ancestor_ns)
+ q->info.si_pid = 0;
break;
}
} else if (!is_si_special(info)) {
--
1.5.2.5
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH 0/7][v6] Container-init signal semantics
2009-01-07 7:45 [PATCH 0/7][v6] Container-init signal semantics Sukadev Bhattiprolu
` (6 preceding siblings ...)
2009-01-07 7:52 ` [PATCH 7/7][v6] SI_USER: Masquerade si_pid when crossing pid ns boundary Sukadev Bhattiprolu
@ 2009-01-11 6:04 ` Oleg Nesterov
2009-01-17 20:46 ` Sukadev Bhattiprolu
7 siblings, 1 reply; 11+ messages in thread
From: Oleg Nesterov @ 2009-01-11 6:04 UTC (permalink / raw)
To: Sukadev Bhattiprolu
Cc: ebiederm, roland, bastian, daniel, xemul, containers,
linux-kernel
Eric, Roland, what do you think ?
The whole series looks good to me. I think it adds minimal
complications to solove the problem.
Oleg.
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH 0/7][v6] Container-init signal semantics
2009-01-11 6:04 ` [PATCH 0/7][v6] Container-init signal semantics Oleg Nesterov
@ 2009-01-17 20:46 ` Sukadev Bhattiprolu
0 siblings, 0 replies; 11+ messages in thread
From: Sukadev Bhattiprolu @ 2009-01-17 20:46 UTC (permalink / raw)
To: Oleg Nesterov
Cc: ebiederm, roland, bastian, daniel, xemul, containers,
linux-kernel
Oleg Nesterov [oleg@redhat.com] wrote:
| Eric, Roland, what do you think ?
|
| The whole series looks good to me. I think it adds minimal
| complications to solove the problem.
Thanks Oleg.
I made a small style update - basically removed the helpers
siginfo_from_user() and siginfo_from_ancestor_ns() and moved their
logic into send_signal() (merged patch 4 and 5 from [v6] patchset).
Also added a patch to update /proc/pid/status to include SIG_DFL
signals and removed a pending todo for the patchset.
Roland, Eric, Daniel, Bastian, can you please comment on the [v7]
patchset ?
Thanks,
Sukadev
^ permalink raw reply [flat|nested] 11+ messages in thread