From: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
To: oleg@redhat.com, ebiederm@xmission.com, roland@redhat.com,
bastian@waldi.eu.org
Cc: containers@lists.osdl.org, linux-kernel@vger.kernel.org,
xemul@openvz.org
Subject: [PATCH 4/7][v6] Define siginfo_from_ancestor_ns()
Date: Tue, 6 Jan 2009 23:51:23 -0800 [thread overview]
Message-ID: <20090107075123.GD27985@us.ibm.com> (raw)
In-Reply-To: <20090107074558.GA27881@us.ibm.com>
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
next prev parent reply other threads:[~2009-01-07 7:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` [PATCH 3/7][v6] Add from_ancestor_ns parameter to send_signal() Sukadev Bhattiprolu
2009-01-07 7:51 ` Sukadev Bhattiprolu [this message]
2009-01-07 7:51 ` [PATCH 5/7][v6] Protect cinit from unblocked SIG_DFL signals Sukadev Bhattiprolu
2009-01-07 7:52 ` [PATCH 6/7][v6] Protect cinit from blocked fatal signals Sukadev Bhattiprolu
[not found] ` <20090107075214.GF27985-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-01-11 6:15 ` Oleg Nesterov
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
2009-01-17 20:46 ` Sukadev Bhattiprolu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090107075123.GD27985@us.ibm.com \
--to=sukadev@linux.vnet.ibm.com \
--cc=bastian@waldi.eu.org \
--cc=containers@lists.osdl.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=roland@redhat.com \
--cc=xemul@openvz.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.