this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Added sys_pthread_kill()

+161 -1
+1
src/kernel/emulation/linux/CMakeLists.txt
··· 157 157 bsdthread/disable_threadsignal.c 158 158 bsdthread/workq_kernreturn.c 159 159 bsdthread/workq_open.c 160 + bsdthread/pthread_kill.c 160 161 psynch/psynch_mutexwait.c 161 162 psynch/psynch_mutexdrop.c 162 163 syscalls-table.S
+21
src/kernel/emulation/linux/bsdthread/pthread_kill.c
··· 1 + #include "pthread_kill.h" 2 + #include "../base.h" 3 + #include "../errno.h" 4 + #include "../signal/duct_signals.h" 5 + #include "../../../../../platform-include/sys/errno.h" 6 + #include <stddef.h> 7 + #include "../../../mach_server/client/lkm.h" 8 + #include "../../../../lkm/api.h" 9 + #include "../simple.h" 10 + 11 + long sys_pthread_kill(int thread_port, int sig) 12 + { 13 + struct pthread_kill_args args; 14 + 15 + args.thread_port = thread_port; 16 + args.sig = signum_bsd_to_linux(sig); 17 + 18 + return lkm_call(NR_pthread_kill_trap, &args); 19 + 20 + } 21 +
+7
src/kernel/emulation/linux/bsdthread/pthread_kill.h
··· 1 + #ifndef PTHREAD_KILL_H 2 + #define PTHREAD_KILL_H 3 + 4 + long sys_pthread_kill(int thread_port, int sig); 5 + 6 + #endif 7 +
+2
src/kernel/emulation/linux/syscalls.c
··· 117 117 #include "psynch/psynch_mutexdrop.h" 118 118 #include "bsdthread/workq_kernreturn.h" 119 119 #include "bsdthread/workq_open.h" 120 + #include "bsdthread/pthread_kill.h" 120 121 121 122 void* __bsd_syscall_table[512] = { 122 123 [1] = sys_exit, ··· 237 238 [244] = sys_posix_spawn, 238 239 [301] = sys_psynch_mutexwait, 239 240 [302] = sys_psynch_mutexdrop, 241 + [328] = sys_pthread_kill, 240 242 [329] = sys_sigprocmask, // __pthread_sigmask 241 243 [331] = sys_disable_threadsignal, 242 244 [334] = sys_semwait_signal,
+1 -1
src/lkm/Makefile
··· 22 22 mig/taskServer.o mig/thread_actServer.o \ 23 23 servers/thread_act.o \ 24 24 mig/duct.o proc_entry.o bsd_ioctl.o \ 25 - psynch/psynch_mutex.o 25 + psynch/psynch_mutex.o psynch/pthread_kill.o 26 26 27 27 # Otherwise we were called directly from the command 28 28 # line; invoke the kernel build system.
+7
src/lkm/api.h
··· 46 46 NR_bsdthread_terminate_trap, 47 47 NR_psynch_mutexwait_trap, 48 48 NR_psynch_mutexdrop_trap, 49 + NR_pthread_kill_trap, 49 50 }; 50 51 51 52 struct mach_port_mod_refs_args ··· 165 166 uint32_t ugen; 166 167 uint64_t tid; 167 168 uint32_t flags; 169 + }; 170 + 171 + struct pthread_kill_args 172 + { 173 + int thread_port; 174 + int sig; 168 175 }; 169 176 170 177 #endif
+87
src/lkm/psynch/pthread_kill.c
··· 1 + /* 2 + * Darling Mach Linux Kernel Module 3 + * Copyright (C) 2015 Lubos Dolezel 4 + * 5 + * This program is free software; you can redistribute it and/or 6 + * modify it under the terms of the GNU General Public License 7 + * as published by the Free Software Foundation; either version 2 8 + * of the License, or (at your option) any later version. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + * 15 + * You should have received a copy of the GNU General Public License 16 + * along with this program; if not, write to the Free Software 17 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 + */ 19 + 20 + #include "../mach_includes.h" 21 + #include "pthread_kill.h" 22 + #include <asm/siginfo.h> 23 + #include <linux/uaccess.h> 24 + #include <asm/siginfo.h> 25 + #include <linux/rcupdate.h> 26 + #include <linux/sched.h> 27 + #include "../servers/thread_act.h" 28 + #include "../ipc_types.h" 29 + #include "../ipc_space.h" 30 + #include "../ipc_right.h" 31 + #include "../darling_task.h" 32 + 33 + int pthread_kill_trap(mach_task_t* task, 34 + struct pthread_kill_args* in_args) 35 + { 36 + struct pthread_kill_args args; 37 + darling_mach_port_right_t* right = NULL; 38 + int ret; 39 + pid_t tid; 40 + struct siginfo info; 41 + struct task_struct *t; 42 + 43 + if (copy_from_user(&args, in_args, sizeof(args))) 44 + return -EFAULT; 45 + 46 + ipc_space_lock(&task->namespace); 47 + right = ipc_space_lookup(&task->namespace, args.thread_port); 48 + 49 + ipc_space_unlock(&task->namespace); 50 + if (right == NULL) 51 + { 52 + ret = -EINVAL; 53 + goto err; 54 + } 55 + 56 + tid = get_thread_pid(right->port); 57 + ipc_port_unlock(right->port); 58 + 59 + if (tid == 0) 60 + { 61 + // Not a thread port 62 + ret = -EINVAL; 63 + goto err; 64 + } 65 + 66 + rcu_read_lock(); 67 + t = pid_task(find_pid_ns(tid, &init_pid_ns), PIDTYPE_PID); 68 + 69 + if (t == NULL) 70 + { 71 + rcu_read_unlock(); 72 + ret = -ESRCH; 73 + goto err; 74 + } 75 + 76 + info.si_signo = args.sig; 77 + info.si_code = SI_TKILL; 78 + info.si_pid = t->tgid; 79 + info.si_uid = from_kuid_munged(current_user_ns(), current_uid()); 80 + info.si_errno = 0; 81 + 82 + ret = send_sig_info(args.sig, &info, t); 83 + rcu_read_unlock(); 84 + 85 + err: 86 + return ret; 87 + }
+30
src/lkm/psynch/pthread_kill.h
··· 1 + /* 2 + * Darling Mach Linux Kernel Module 3 + * Copyright (C) 2015 Lubos Dolezel 4 + * 5 + * This program is free software; you can redistribute it and/or 6 + * modify it under the terms of the GNU General Public License 7 + * as published by the Free Software Foundation; either version 2 8 + * of the License, or (at your option) any later version. 9 + * 10 + * This program is distributed in the hope that it will be useful, 11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 + * GNU General Public License for more details. 14 + * 15 + * You should have received a copy of the GNU General Public License 16 + * along with this program; if not, write to the Free Software 17 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 + */ 19 + 20 + #ifndef PTHREAD_KILL_H 21 + #define PTHREAD_KILL_H 22 + #include "../api.h" 23 + #include "../ipc_types.h" 24 + 25 + int pthread_kill_trap(mach_task_t* task, 26 + struct pthread_kill_args* args); 27 + 28 + 29 + #endif /* PTHREAD_KILL_H */ 30 +
+3
src/lkm/servers/thread_act.c
··· 56 56 { 57 57 struct thread_private* priv; 58 58 59 + if (port->server_port.subsystem != (mig_subsystem_t) &thread_act_subsystem) 60 + return 0; 61 + 59 62 priv = (struct thread_private*) port->server_port.private_data; 60 63 return priv->thread_id; 61 64 }
+2
src/lkm/traps.c
··· 43 43 #include "servers/thread_act.h" 44 44 #include "primitives/semaphore.h" 45 45 #include "psynch/psynch_mutex.h" 46 + #include "psynch/pthread_kill.h" 46 47 47 48 MODULE_LICENSE("GPL"); 48 49 ··· 79 80 [sc(NR_bsdthread_terminate_trap)] = (trap_handler) bsdthread_terminate_trap, 80 81 [sc(NR_psynch_mutexwait_trap)] = (trap_handler) psynch_mutexwait_trap, 81 82 [sc(NR_psynch_mutexdrop_trap)] = (trap_handler) psynch_mutexdrop_trap, 83 + [sc(NR_pthread_kill_trap)] = (trap_handler) pthread_kill_trap, 82 84 }; 83 85 #undef sc 84 86