From: riku.voipio@linaro.org
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>
Subject: [Qemu-devel] [PULL 20/44] linux-user: Use safe_syscall for kill, tkill and tgkill syscalls
Date: Wed, 8 Jun 2016 16:30:01 +0300 [thread overview]
Message-ID: <bef653d92e4e1c47c60f5c020ff6de69dba83478.1465392531.git.riku.voipio@linaro.org> (raw)
In-Reply-To: <cover.1465392530.git.riku.voipio@linaro.org>
From: Peter Maydell <peter.maydell@linaro.org>
Use the safe_syscall wrapper for the kill, tkill and tgkill syscalls.
Without this, if a thread sent a SIGKILL to itself it could kill the
thread before we had a chance to process a signal that arrived just
before the SIGKILL, and that signal would get lost.
We drop all the ifdeffery for tkill and tgkill, because every guest
architecture we support implements them, and they've been in Linux
since 2003 so we can assume the host headers define the __NR_tkill
and __NR_tgkill constants.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f3061a9..c0d086c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -191,8 +191,6 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \
#define __NR_sys_getpriority __NR_getpriority
#define __NR_sys_rt_sigqueueinfo __NR_rt_sigqueueinfo
#define __NR_sys_syslog __NR_syslog
-#define __NR_sys_tgkill __NR_tgkill
-#define __NR_sys_tkill __NR_tkill
#define __NR_sys_futex __NR_futex
#define __NR_sys_inotify_init __NR_inotify_init
#define __NR_sys_inotify_add_watch __NR_inotify_add_watch
@@ -230,12 +228,6 @@ _syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo,
#endif
_syscall3(int,sys_rt_sigqueueinfo,int,pid,int,sig,siginfo_t *,uinfo)
_syscall3(int,sys_syslog,int,type,char*,bufp,int,len)
-#if defined(TARGET_NR_tgkill) && defined(__NR_tgkill)
-_syscall3(int,sys_tgkill,int,tgid,int,pid,int,sig)
-#endif
-#if defined(TARGET_NR_tkill) && defined(__NR_tkill)
-_syscall2(int,sys_tkill,int,tid,int,sig)
-#endif
#ifdef __NR_exit_group
_syscall1(int,exit_group,int,error_code)
#endif
@@ -717,6 +709,9 @@ safe_syscall6(int, pselect6, int, nfds, fd_set *, readfds, fd_set *, writefds, \
safe_syscall6(int,futex,int *,uaddr,int,op,int,val, \
const struct timespec *,timeout,int *,uaddr2,int,val3)
safe_syscall2(int, rt_sigsuspend, sigset_t *, newset, size_t, sigsetsize)
+safe_syscall2(int, kill, pid_t, pid, int, sig)
+safe_syscall2(int, tkill, int, tid, int, sig)
+safe_syscall3(int, tgkill, int, tgid, int, pid, int, sig)
static inline int host_to_target_sock_type(int host_type)
{
@@ -7169,7 +7164,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
ret = 0;
break;
case TARGET_NR_kill:
- ret = get_errno(kill(arg1, target_to_host_signal(arg2)));
+ ret = get_errno(safe_kill(arg1, target_to_host_signal(arg2)));
break;
#ifdef TARGET_NR_rename
case TARGET_NR_rename:
@@ -10405,18 +10400,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
break;
#endif
-#if defined(TARGET_NR_tkill) && defined(__NR_tkill)
case TARGET_NR_tkill:
- ret = get_errno(sys_tkill((int)arg1, target_to_host_signal(arg2)));
+ ret = get_errno(safe_tkill((int)arg1, target_to_host_signal(arg2)));
break;
-#endif
-#if defined(TARGET_NR_tgkill) && defined(__NR_tgkill)
case TARGET_NR_tgkill:
- ret = get_errno(sys_tgkill((int)arg1, (int)arg2,
+ ret = get_errno(safe_tgkill((int)arg1, (int)arg2,
target_to_host_signal(arg3)));
- break;
-#endif
+ break;
#ifdef TARGET_NR_set_robust_list
case TARGET_NR_set_robust_list:
--
2.1.4
next prev parent reply other threads:[~2016-06-08 13:31 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-08 13:29 [Qemu-devel] [PULL 00/44] linux-user update riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 01/44] linux-user: Fix qemu-binfmt-conf.sh to store config across reboot riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 02/44] linux-user: add rtnetlink(7) support riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 03/44] linux-user: support netlink protocol NETLINK_KOBJECT_UEVENT riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 04/44] linux-user: add netlink audit riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 05/44] linux-user: check if NETLINK_ROUTE is available riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 06/44] linux-user: Factor out handle_signal code from process_pending_signals() riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 07/44] linux-user: Move handle_pending_signal() to avoid need for declaration riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 08/44] linux-user: Fix stray tab-indent riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 09/44] linux-user: Factor out uses of do_sigprocmask() from sigreturn code riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 10/44] linux-user: Define macro for size of host kernel sigset_t riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 11/44] linux-user: Use safe_syscall for sigsuspend syscalls riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 12/44] linux-user: Fix race between multiple signals riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 13/44] linux-user: Remove redundant default action check in queue_signal() riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 14/44] linux-user: Remove redundant gdb_queuesig() riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 15/44] linux-user: Remove real-time signal queuing riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 16/44] linux-user: Queue synchronous signals separately riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 17/44] linux-user: Block signals during sigaction() handling riku.voipio
2016-06-08 13:29 ` [Qemu-devel] [PULL 18/44] linux-user: pause() should not pause if signal pending riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 19/44] linux-user: Restart exit() " riku.voipio
2016-06-08 13:30 ` riku.voipio [this message]
2016-06-08 13:30 ` [Qemu-devel] [PULL 21/44] linux-user: Restart fork() if signals pending riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 22/44] linux-user: Use both si_code and si_signo when converting siginfo_t riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 23/44] linux-user: Avoid possible misalignment in target_to_host_siginfo() riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 24/44] linux-user: provide frame information in x86-64 safe_syscall riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 25/44] linux-user: Fix handling of arm_fadvise64_64 syscall riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 26/44] linux-user: Fix NR_fadvise64 and NR_fadvise64_64 for 32-bit guests riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 27/44] linux-user: Fix error conversion in 64-bit fadvise syscall riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 28/44] linux-user: Use safe_syscall wrapper for readv and writev syscalls riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 29/44] linux-user: Use safe_syscall wrapper for connect syscall riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 30/44] linux-user: Use safe_syscall wrapper for send* and recv* syscalls riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 31/44] linux-user: Use safe_syscall wrapper for msgsnd and msgrcv riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 32/44] linux-user: Use safe_syscall wrapper for mq_timedsend and mq_timedreceive riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 33/44] linux-user: Use safe_syscall wrapper for flock riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 34/44] linux-user: Use safe_syscall wrapper for rt_sigtimedwait syscall riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 35/44] linux-user: Use safe_syscall wrapper for sleep syscalls riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 36/44] linux-user: Use safe_syscall wrapper for poll and ppoll syscalls riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 37/44] linux-user: Use safe_syscall wrapper for epoll_wait syscalls riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 38/44] linux-user: Use safe_syscall wrapper for semop riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 39/44] linux-user: Use safe_syscall wrapper for accept and accept4 syscalls riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 40/44] linux-user: Use safe_syscall wrapper for ioctl riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 41/44] linux-user: Correct signedness of target_flock l_start and l_len fields riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 42/44] linux-user: Make target_strerror() return 'const char *' riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 43/44] linux-user: Special-case ERESTARTSYS in target_strerror() riku.voipio
2016-06-08 13:30 ` [Qemu-devel] [PULL 44/44] linux-user: In fork_end(), remove correct CPUs from CPU list riku.voipio
2016-06-08 18:37 ` [Qemu-devel] [PULL 00/44] linux-user update Peter Maydell
2016-06-09 20:19 ` Laurent Vivier
2016-06-09 20:53 ` Peter Maydell
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=bef653d92e4e1c47c60f5c020ff6de69dba83478.1465392531.git.riku.voipio@linaro.org \
--to=riku.voipio@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).