From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Roland McGrath <roland@redhat.com>,
Oleg Nesterov <oleg@redhat.com>,
Michael Kerrisk <mtk.manpages@googlemail.com>,
Ulrich Drepper <drepper@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Ingo Molnar <mingo@elte.hu>
Subject: [patch 2/3] signals: implement sys_rt_tgsigqueueinfo
Date: Tue, 24 Mar 2009 10:35:15 -0000 [thread overview]
Message-ID: <20090324102523.731851892@linutronix.de> (raw)
In-Reply-To: <20090324102516.459441533@linutronix.de>
[-- Attachment #1: signals-implement-rt-tgsigqueueinfo.patch --]
[-- Type: text/plain, Size: 3582 bytes --]
sys_kill has the per thread counterpart sys_tgkill. sigqueueinfo is
missing a thread directed counterpart. Such an interface is important
for migrating applications from other OSes which have the per thread
delivery implemented.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/compat.h | 2 ++
include/linux/signal.h | 2 ++
kernel/compat.c | 11 +++++++++++
kernel/signal.c | 26 ++++++++++++++++++++++++++
4 files changed, 41 insertions(+)
Index: linux-2.6/include/linux/compat.h
===================================================================
--- linux-2.6.orig/include/linux/compat.h
+++ linux-2.6/include/linux/compat.h
@@ -208,6 +208,8 @@ int copy_siginfo_from_user32(siginfo_t *
int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from);
int get_compat_sigevent(struct sigevent *event,
const struct compat_sigevent __user *u_event);
+long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid, compat_pid_t pid, int sig,
+ struct compat_siginfo __user *uinfo);
static inline int compat_timeval_compare(struct compat_timeval *lhs,
struct compat_timeval *rhs)
Index: linux-2.6/include/linux/signal.h
===================================================================
--- linux-2.6.orig/include/linux/signal.h
+++ linux-2.6/include/linux/signal.h
@@ -235,6 +235,8 @@ static inline int valid_signal(unsigned
extern int next_signal(struct sigpending *pending, sigset_t *mask);
extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p);
extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
+extern long do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig,
+ siginfo_t *info);
extern long do_sigpending(void __user *, unsigned long);
extern int sigprocmask(int, sigset_t *, sigset_t *);
extern int show_unhandled_signals;
Index: linux-2.6/kernel/compat.c
===================================================================
--- linux-2.6.orig/kernel/compat.c
+++ linux-2.6/kernel/compat.c
@@ -882,6 +882,17 @@ compat_sys_rt_sigtimedwait (compat_sigse
}
+asmlinkage long
+compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid, compat_pid_t pid, int sig,
+ struct compat_siginfo __user *uinfo)
+{
+ siginfo_t info;
+
+ if (copy_siginfo_from_user32(&info, uinfo))
+ return -EFAULT;
+ return do_rt_tgsigqueueinfo(tgid, pid, sig, &info);
+}
+
#ifdef __ARCH_WANT_COMPAT_SYS_TIME
/* compat_time_t is a 32 bit "long" and needs to get converted. */
Index: linux-2.6/kernel/signal.c
===================================================================
--- linux-2.6.orig/kernel/signal.c
+++ linux-2.6/kernel/signal.c
@@ -2326,6 +2326,32 @@ SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t,
return kill_proc_info(sig, &info, pid);
}
+long do_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig, siginfo_t *info)
+{
+ /* This is only valid for single tasks */
+ if (pid <= 0 || tgid <= 0)
+ return -EINVAL;
+
+ /* Not even root can pretend to send signals from the kernel.
+ Nor can they impersonate a kill(), which adds source info. */
+ if (info->si_code >= 0)
+ return -EPERM;
+ info->si_signo = sig;
+
+ return do_send_specific(tgid, pid, sig, info);
+}
+
+SYSCALL_DEFINE4(rt_tgsigqueueinfo, pid_t, tgid, pid_t, pid, int, sig,
+ siginfo_t __user *, uinfo)
+{
+ siginfo_t info;
+
+ if (copy_from_user(&info, uinfo, sizeof(siginfo_t)))
+ return -EFAULT;
+
+ return do_rt_tgsigqueueinfo(tgid, pid, sig, &info);
+}
+
int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
{
struct task_struct *t = current;
next prev parent reply other threads:[~2009-03-24 10:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-24 10:35 [patch 0/3] add rt_tgsigqueueinfo syscall -V2 Thomas Gleixner
2009-03-24 10:35 ` [patch 1/3] signals: split do_tkill Thomas Gleixner
2009-03-24 10:35 ` Thomas Gleixner [this message]
2009-03-24 10:35 ` [patch 3/3] x86: hookup sys_rt_tgsigqueueinfo Thomas Gleixner
2009-03-31 15:26 ` [patch 0/3] add rt_tgsigqueueinfo syscall -V2 Oleg Nesterov
2009-04-01 1:16 ` Michael Kerrisk
2009-04-01 1:25 ` Roland McGrath
2009-04-01 1:44 ` Michael Kerrisk
-- strict thread matches above, loose matches on Subject: below --
2009-04-04 21:00 [patch 0/3] add rt_tgsigqueueinfo syscall for 2.6.30 Thomas Gleixner
2009-04-04 21:01 ` [patch 2/3] signals: implement sys_rt_tgsigqueueinfo Thomas Gleixner
2009-02-26 13:35 [patch 0/3] add rt_tgsigqueueinfo syscall [RESEND] Thomas Gleixner
2009-02-26 13:35 ` [patch 2/3] signals: implement sys_rt_tgsigqueueinfo Thomas Gleixner
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=20090324102523.731851892@linutronix.de \
--to=tglx@linutronix.de \
--cc=akpm@linux-foundation.org \
--cc=drepper@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mtk.manpages@googlemail.com \
--cc=oleg@redhat.com \
--cc=roland@redhat.com \
/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
Powered by JetHome