From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
Al Viro <viro@zeniv.linux.org.uk>,
Alexey Dobriyan <adobriyan@gmail.com>,
"Eric W. Biederman" <ebiederm@xmission.com>,
James Morris <james.l.morris@oracle.com>,
Greg KH <gregkh@linuxfoundation.org>, Ingo Molnar <mingo@elte.hu>,
Roland McGrath <roland@hack.frob.com>,
Solar Designer <solar@openwall.com>,
Djalal Harouni <tixxdz@opendz.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] exit_signal: fix the "parent has changed security domain" logic
Date: Mon, 19 Mar 2012 17:03:41 +0100 [thread overview]
Message-ID: <20120319160341.GC4910@redhat.com> (raw)
In-Reply-To: <20120319160249.GA4910@redhat.com>
exit_notify() changes ->exit_signal if the parent already did exec.
This doesn't really work, we are not going to send the signal now
if there is another live thread or the exiting task is traced. The
parent can exec before the last dies or the tracer detaches.
Move this check into do_notify_parent() which actually sends the
signal.
The user-visible change is that we do not change ->exit_signal,
and thus the exiting task is still "clone children" for
do_wait()->eligible_child(__WCLONE). Hopefully this is fine, the
current logic is racy anyway.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
kernel/exit.c | 14 --------------
kernel/signal.c | 9 +++++++++
2 files changed, 9 insertions(+), 14 deletions(-)
diff --git a/kernel/exit.c b/kernel/exit.c
index 522c1aa..bd9f4c9 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -818,20 +818,6 @@ static void exit_notify(struct task_struct *tsk, int group_dead)
if (group_dead)
kill_orphaned_pgrp(tsk->group_leader, NULL);
- /* Let father know we died
- *
- * Thread signals are configurable, but you aren't going to use
- * that to send signals to arbitrary processes.
- * That stops right now.
- *
- * If the parent exec id doesn't match the exec id we saved
- * when we started then we know the parent has changed security
- * domain.
- */
- if (thread_group_leader(tsk) && tsk->exit_signal != SIGCHLD &&
- tsk->parent_exec_id != tsk->real_parent->self_exec_id)
- tsk->exit_signal = SIGCHLD;
-
if (unlikely(tsk->ptrace)) {
int sig = thread_group_leader(tsk) &&
thread_group_empty(tsk) &&
diff --git a/kernel/signal.c b/kernel/signal.c
index c73c428..b09cf3b 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1642,6 +1642,15 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
BUG_ON(!tsk->ptrace &&
(tsk->group_leader != tsk || !thread_group_empty(tsk)));
+ if (sig != SIGCHLD) {
+ /*
+ * This is only possible if parent == real_parent.
+ * Check if it has changed security domain.
+ */
+ if (tsk->parent_exec_id != tsk->parent->self_exec_id)
+ sig = SIGCHLD;
+ }
+
info.si_signo = sig;
info.si_errno = 0;
/*
--
1.5.5.1
next prev parent reply other threads:[~2012-03-19 16:11 UTC|newest]
Thread overview: 102+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-10 23:25 [kernel-hardening] [PATCH 0/9] proc: protect /proc/<pid>/* files across execve Djalal Harouni
2012-03-10 23:25 ` Djalal Harouni
2012-03-10 23:25 ` [kernel-hardening] [PATCH 1/9] exec: add a global execve counter Djalal Harouni
2012-03-10 23:25 ` Djalal Harouni
2012-03-11 0:12 ` [kernel-hardening] " Linus Torvalds
2012-03-11 0:12 ` Linus Torvalds
2012-03-11 0:36 ` [kernel-hardening] " Linus Torvalds
2012-03-11 0:36 ` Linus Torvalds
2012-03-11 0:58 ` [kernel-hardening] " Linus Torvalds
2012-03-11 0:58 ` Linus Torvalds
2012-03-11 8:24 ` [kernel-hardening] " Solar Designer
2012-03-11 8:24 ` Solar Designer
2012-03-11 9:56 ` [kernel-hardening] " Ingo Molnar
2012-03-11 9:56 ` Ingo Molnar
2012-03-11 14:03 ` [kernel-hardening] " Alan Cox
2012-03-11 14:03 ` Alan Cox
2012-03-11 17:15 ` [kernel-hardening] " Djalal Harouni
2012-03-11 17:15 ` Djalal Harouni
2012-03-11 8:39 ` [kernel-hardening] " Djalal Harouni
2012-03-11 8:39 ` Djalal Harouni
2012-03-11 9:40 ` [kernel-hardening] " Solar Designer
2012-03-11 9:40 ` Solar Designer
2012-03-11 17:25 ` [kernel-hardening] " Oleg Nesterov
2012-03-11 17:25 ` Oleg Nesterov
2012-03-11 17:49 ` [kernel-hardening] self_exec_id/parent_exec_id && CLONE_PARENT Oleg Nesterov
2012-03-11 17:49 ` Oleg Nesterov
2012-03-11 18:02 ` [kernel-hardening] " Linus Torvalds
2012-03-11 18:02 ` Linus Torvalds
2012-03-11 18:37 ` [kernel-hardening] " richard -rw- weinberger
2012-03-11 18:37 ` richard -rw- weinberger
2012-03-11 18:39 ` [kernel-hardening] " Oleg Nesterov
2012-03-11 18:39 ` Oleg Nesterov
2012-03-14 18:55 ` [kernel-hardening] [PATCH 0/1] (Was: self_exec_id/parent_exec_id && CLONE_PARENT) Oleg Nesterov
2012-03-14 18:55 ` Oleg Nesterov
2012-03-14 18:55 ` [kernel-hardening] [PATCH 1/1] CLONE_PARENT shouldn't allow to set ->exit_signal Oleg Nesterov
2012-03-14 18:55 ` Oleg Nesterov
2012-03-18 18:25 ` [kernel-hardening] " Linus Torvalds
2012-03-18 18:25 ` Linus Torvalds
2012-03-18 20:53 ` [kernel-hardening] " Oleg Nesterov
2012-03-18 20:53 ` Oleg Nesterov
[not found] ` <20120314190939.GC14172@redhat.com>
2012-03-19 16:02 ` [PATCH 0/3] exec_id/exit_signal fixes Oleg Nesterov
2012-03-19 16:03 ` [PATCH 1/3] exit_signal: simplify the "we have changed execution domain" logic Oleg Nesterov
2012-03-19 16:03 ` Oleg Nesterov [this message]
2012-03-19 16:04 ` [PATCH 3/3] exec: move de_thread()->setmax_mm_hiwater_rss() into exec_mmap() Oleg Nesterov
2012-03-11 22:48 ` [kernel-hardening] Re: [PATCH 1/9] exec: add a global execve counter Linus Torvalds
2012-03-11 22:48 ` Linus Torvalds
2012-03-11 23:32 ` [kernel-hardening] " Djalal Harouni
2012-03-11 23:32 ` Djalal Harouni
2012-03-11 23:42 ` [kernel-hardening] " Linus Torvalds
2012-03-11 23:42 ` Linus Torvalds
2012-03-12 0:25 ` [kernel-hardening] " Djalal Harouni
2012-03-12 0:25 ` Djalal Harouni
2012-03-12 10:11 ` [kernel-hardening] " Linus Torvalds
2012-03-12 10:11 ` Linus Torvalds
2012-03-12 10:11 ` Linus Torvalds
2012-03-12 14:01 ` [kernel-hardening] " Djalal Harouni
2012-03-12 14:01 ` Djalal Harouni
2012-03-12 14:01 ` Djalal Harouni
2012-03-11 23:36 ` [kernel-hardening] " Djalal Harouni
2012-03-11 23:36 ` Djalal Harouni
2012-03-12 14:34 ` [kernel-hardening] " Oleg Nesterov
2012-03-12 14:34 ` Oleg Nesterov
2012-03-10 23:25 ` [kernel-hardening] [PATCH 2/9] proc: add proc_file_private struct to store private information Djalal Harouni
2012-03-10 23:25 ` Djalal Harouni
2012-03-10 23:25 ` [kernel-hardening] [PATCH 3/9] proc: new proc_exec_id_ok() helper function Djalal Harouni
2012-03-10 23:25 ` Djalal Harouni
2012-03-10 23:25 ` [kernel-hardening] [PATCH 4/9] proc: protect /proc/<pid>/* INF files from reader across execve Djalal Harouni
2012-03-10 23:25 ` Djalal Harouni
2012-03-10 23:25 ` [kernel-hardening] [PATCH 5/9] proc: add protection support for /proc/<pid>/* ONE files Djalal Harouni
2012-03-10 23:25 ` Djalal Harouni
2012-03-10 23:25 ` [kernel-hardening] [PATCH 6/9] proc: protect /proc/<pid>/* ONE files from reader across execve Djalal Harouni
2012-03-10 23:25 ` Djalal Harouni
2012-03-10 23:25 ` [kernel-hardening] [PATCH 7/9] proc: protect /proc/<pid>/{maps,smaps,numa_maps} Djalal Harouni
2012-03-10 23:25 ` Djalal Harouni
2012-03-10 23:25 ` [kernel-hardening] [PATCH 8/9] proc: protect /proc/<pid>/{environ,pagemap} across execve Djalal Harouni
2012-03-10 23:25 ` Djalal Harouni
2012-03-11 8:05 ` [kernel-hardening] " Alexey Dobriyan
2012-03-11 8:05 ` Alexey Dobriyan
2012-03-11 17:01 ` [kernel-hardening] " Djalal Harouni
2012-03-11 17:01 ` Djalal Harouni
2012-03-10 23:25 ` [kernel-hardening] [PATCH 9/9] proc: improve and clean up /proc/<pid>/mem protection Djalal Harouni
2012-03-10 23:25 ` Djalal Harouni
2012-03-11 0:01 ` [kernel-hardening] Re: [PATCH 0/9] proc: protect /proc/<pid>/* files across execve Linus Torvalds
2012-03-11 0:01 ` Linus Torvalds
2012-03-11 0:27 ` [kernel-hardening] " Djalal Harouni
2012-03-11 0:27 ` Djalal Harouni
2012-03-11 8:46 ` [kernel-hardening] " Djalal Harouni
2012-03-11 8:46 ` Djalal Harouni
2012-03-11 10:35 ` [kernel-hardening] exec_id protection from bad child exit signals (was: Re: [PATCH 0/9] proc: protect /proc/<pid>/* files across execve) Solar Designer
2012-03-11 10:35 ` Solar Designer
2012-03-11 18:20 ` [kernel-hardening] " Oleg Nesterov
2012-03-11 18:20 ` Oleg Nesterov
2012-03-12 19:13 ` [kernel-hardening] Re: [PATCH 0/9] proc: protect /proc/<pid>/* files across execve Eric W. Biederman
2012-03-12 19:13 ` Eric W. Biederman
2012-03-12 20:44 ` [kernel-hardening] " Djalal Harouni
2012-03-12 20:44 ` Djalal Harouni
2012-03-12 21:47 ` [kernel-hardening] " Eric W. Biederman
2012-03-12 21:47 ` Eric W. Biederman
2012-03-12 22:41 ` [kernel-hardening] " Djalal Harouni
2012-03-12 22:41 ` Djalal Harouni
2012-03-12 23:10 ` [kernel-hardening] " Eric W. Biederman
2012-03-12 23:10 ` Eric W. Biederman
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=20120319160341.GC4910@redhat.com \
--to=oleg@redhat.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=ebiederm@xmission.com \
--cc=gregkh@linuxfoundation.org \
--cc=james.l.morris@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=roland@hack.frob.com \
--cc=solar@openwall.com \
--cc=tixxdz@opendz.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@zeniv.linux.org.uk \
/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.