mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: <linux-kernel@vger.kernel.org>
Cc: <vserver@list.linux-vserver.org>,
	Herbert Poetzl <herbert@13thfloor.at>,
	"Serge E. Hallyn" <serue@us.ibm.com>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Dave Hansen <haveblue@us.ibm.com>,
	Arjan van de Ven <arjan@infradead.org>,
	Suleiman Souhlal <ssouhlal@FreeBSD.org>,
	Hubertus Franke <frankeh@watson.ibm.com>,
	Cedric Le Goater <clg@fr.ibm.com>,
	Kyle Moffett <mrmacman_g4@mac.com>
Subject: [PATCH 3/5] pid:  Implement kill_tref.
Date: Sun, 29 Jan 2006 00:28:28 -0700	[thread overview]
Message-ID: <m1d5iba3xf.fsf_-_@ebiederm.dsl.xmission.com> (raw)
In-Reply-To: <m1hd7na44b.fsf_-_@ebiederm.dsl.xmission.com> (Eric W. Biederman's message of "Sun, 29 Jan 2006 00:24:20 -0700")


Currently most functions for sending a signal to
a task or group of tasks take a pid as an argoument.
kill_ref instead takes a task_ref.  I would use a
function that simply takes a task but the tasklist_lock
must be taken to ensure that there is not a race in
derferencing task_ref->task.

kill_tref can stand in for either kill_proc, or kill_pg
depending on the type of the reference.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>


---

 include/linux/sched.h |    3 +++
 kernel/signal.c       |   31 +++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)

2d2627206f44ce032e521705efb5f712d440ba13
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 12f3cc5..8cd8075 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1109,6 +1109,9 @@ extern int send_sig_info(int, struct sig
 extern int send_group_sig_info(int, struct siginfo *, struct task_struct *);
 extern int force_sigsegv(int, struct task_struct *);
 extern int force_sig_info(int, struct siginfo *, struct task_struct *);
+extern int __kill_tref_info(int sig, struct siginfo *info, struct task_ref *ref);
+extern int kill_tref_info(int sig, struct siginfo *info, struct task_ref *ref);
+extern int kill_tref(struct task_ref *ref, int sig, int priv);
 extern int __kill_pg_info(int sig, struct siginfo *info, pid_t pgrp);
 extern int kill_pg_info(int, struct siginfo *, pid_t);
 extern int kill_proc_info(int, struct siginfo *, pid_t);
diff --git a/kernel/signal.c b/kernel/signal.c
index d3efafd..20a67ae 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1146,6 +1146,32 @@ retry:
 	return ret;
 }
 
+int __kill_tref_info(int sig, struct siginfo *info, struct task_ref *ref)
+{
+	struct task_struct *p = ref->task;
+	int retval, success;
+
+	success = 0;
+	retval = -ESRCH;
+	do_each_task(p, ref->type) {
+		int err = group_send_sig_info(sig, info, p);
+		success |= !err;
+		retval = err;
+	} while_each_task(p, ref->type);
+	return success ? 0 : retval;
+}
+
+int kill_tref_info(int sig, struct siginfo *info, struct task_ref *ref)
+{
+	int retval;
+
+	read_lock(&tasklist_lock);
+	retval = __kill_tref_info(sig, info, ref);
+	read_unlock(&tasklist_lock);
+
+	return retval;
+}
+
 /*
  * kill_pg_info() sends a signal to a process group: this is what the tty
  * control characters do (^C, ^Z etc)
@@ -1365,6 +1391,11 @@ kill_proc(pid_t pid, int sig, int priv)
 	return kill_proc_info(sig, __si_special(priv), pid);
 }
 
+int kill_tref(struct task_ref *ref, int sig, int priv)
+{
+	return kill_tref_info(sig, __si_special(priv), ref);
+}
+
 /*
  * These functions support sending signals using preallocated sigqueue
  * structures.  This is needed "because realtime applications cannot
-- 
1.1.5.g3480


  reply	other threads:[~2006-01-29  7:29 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-29  7:19 [RFC][PATCH 0/5] Task references Eric W. Biederman
2006-01-29  7:22 ` [PATCH 1/5] pid: Implement task references Eric W. Biederman
2006-01-29  7:24   ` [PATCH 2/5] pid: Add macros for interating through tasks by type Eric W. Biederman
2006-01-29  7:28     ` Eric W. Biederman [this message]
2006-01-29  7:33       ` [PATCH 4/5] vt: Update spawnpid to use a task_ref Eric W. Biederman
2006-01-29  7:35         ` [PATCH 5/5] file: Modify struct fown_struct to contain a tref Eric W. Biederman
2006-01-29  8:43           ` Suleiman Souhlal
2006-01-29  9:18             ` Eric W. Biederman
2006-01-30 10:51         ` [PATCH 4/5] vt: Update spawnpid to use a task_ref Pavel Machek
2006-01-30 20:39           ` Eric W. Biederman
2006-01-30 21:05             ` Pavel Machek
2006-01-30 21:15               ` Eric W. Biederman
2006-01-29  8:46   ` [PATCH 1/5] pid: Implement task references Suleiman Souhlal
2006-01-29 19:05   ` Greg KH
2006-01-29 21:58     ` Eric W. Biederman
2006-01-30  4:51       ` Greg KH
2006-01-30  5:19         ` Eric Dumazet
2006-01-30  5:35           ` Kyle Moffett
2006-01-30  5:46             ` Eric Dumazet
2006-01-30  6:46               ` Kyle Moffett
2006-01-30 18:43           ` Greg KH
2006-01-30 19:58             ` Eric Dumazet
2006-01-30 20:45               ` Eric W. Biederman
2006-01-30 21:32                 ` Eric Dumazet
2006-01-30 21:51                   ` Eric W. Biederman
2006-01-30 20:13         ` Eric W. Biederman
2006-01-31  6:58           ` Greg KH
2006-01-31 16:04             ` Eric W. Biederman
2006-01-29  8:05 ` [RFC][PATCH 0/5] Task references Kyle Moffett
2006-02-06  8:09 ` Eric W. Biederman
2006-02-06 14:36   ` Serge E. Hallyn

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=m1d5iba3xf.fsf_-_@ebiederm.dsl.xmission.com \
    --to=ebiederm@xmission.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=arjan@infradead.org \
    --cc=clg@fr.ibm.com \
    --cc=frankeh@watson.ibm.com \
    --cc=haveblue@us.ibm.com \
    --cc=herbert@13thfloor.at \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mrmacman_g4@mac.com \
    --cc=serue@us.ibm.com \
    --cc=ssouhlal@FreeBSD.org \
    --cc=vserver@list.linux-vserver.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®