mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-11 17:04:19 +01:00
Add thr_kill2 syscall which sends a signal to a thread in another process.
Submitted by: Tijl Coosemans tijl at ulyssis dot org Approved by: re (kensmith)
This commit is contained in:
parent
2dad8a55be
commit
0b1f0611b4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=171859
@ -53,6 +53,8 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <machine/frame.h>
|
||||
|
||||
#include <security/audit/audit.h>
|
||||
|
||||
#ifdef COMPAT_IA32
|
||||
|
||||
extern struct sysentvec ia32_freebsd_sysvec;
|
||||
@ -336,6 +338,59 @@ thr_kill(struct thread *td, struct thr_kill_args *uap)
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
thr_kill2(struct thread *td, struct thr_kill2_args *uap)
|
||||
/* pid_t pid, long id, int sig */
|
||||
{
|
||||
struct thread *ttd;
|
||||
struct proc *p;
|
||||
int error;
|
||||
|
||||
AUDIT_ARG(signum, uap->sig);
|
||||
|
||||
if (uap->pid == td->td_proc->p_pid) {
|
||||
p = td->td_proc;
|
||||
PROC_LOCK(p);
|
||||
} else if ((p = pfind(uap->pid)) == NULL) {
|
||||
return (ESRCH);
|
||||
}
|
||||
AUDIT_ARG(process, p);
|
||||
|
||||
error = p_cansignal(td, p, uap->sig);
|
||||
if (error == 0) {
|
||||
if (uap->id == -1) {
|
||||
if (uap->sig != 0 && !_SIG_VALID(uap->sig)) {
|
||||
error = EINVAL;
|
||||
} else {
|
||||
error = ESRCH;
|
||||
FOREACH_THREAD_IN_PROC(p, ttd) {
|
||||
if (ttd != td) {
|
||||
error = 0;
|
||||
if (uap->sig == 0)
|
||||
break;
|
||||
tdsignal(p, ttd, uap->sig, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (uap->id != td->td_tid)
|
||||
ttd = thread_find(p, uap->id);
|
||||
else
|
||||
ttd = td;
|
||||
if (ttd == NULL)
|
||||
error = ESRCH;
|
||||
else if (uap->sig == 0)
|
||||
;
|
||||
else if (!_SIG_VALID(uap->sig))
|
||||
error = EINVAL;
|
||||
else
|
||||
tdsignal(p, ttd, uap->sig, NULL);
|
||||
}
|
||||
}
|
||||
PROC_UNLOCK(p);
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
thr_suspend(struct thread *td, struct thr_suspend_args *uap)
|
||||
/* const struct timespec *timeout */
|
||||
|
@ -846,5 +846,6 @@
|
||||
int whence); }
|
||||
479 AUE_TRUNCATE STD { int truncate(char *path, off_t length); }
|
||||
480 AUE_FTRUNCATE STD { int ftruncate(int fd, off_t length); }
|
||||
481 AUE_KILL STD { int thr_kill2(pid_t pid, long id, int sig); }
|
||||
; Please copy any additions and changes to the following compatability tables:
|
||||
; sys/compat/freebsd32/syscalls.master
|
||||
|
@ -30,8 +30,14 @@
|
||||
#ifndef _SYS_THR_H_
|
||||
#define _SYS_THR_H_
|
||||
|
||||
#include <sys/_types.h>
|
||||
#include <sys/sched.h>
|
||||
|
||||
#ifndef _SIZE_T_DECLARED
|
||||
typedef __size_t size_t;
|
||||
#define _SIZE_T_DECLARED
|
||||
#endif
|
||||
|
||||
/* Create the thread in the suspended state. */
|
||||
#define THR_SUSPENDED 0x0001
|
||||
/* Create the system scope thread. */
|
||||
@ -55,12 +61,19 @@ struct thr_param {
|
||||
* See pthread_*
|
||||
*/
|
||||
#ifndef _KERNEL
|
||||
#include <sys/ucontext.h>
|
||||
|
||||
#ifndef _PID_T_DECLARED
|
||||
typedef __pid_t pid_t;
|
||||
#define _PID_T_DECLARED
|
||||
#endif
|
||||
|
||||
int thr_create(ucontext_t *ctx, long *id, int flags);
|
||||
int thr_new(struct thr_param *param, int param_size);
|
||||
int thr_self(long *id);
|
||||
void thr_exit(long *state);
|
||||
int thr_kill(long id, int sig);
|
||||
int thr_kill2(pid_t pid, long id, int sig);
|
||||
int thr_suspend(const struct timespec *timeout);
|
||||
int thr_wake(long id);
|
||||
int thr_set_name(long id, const char *name);
|
||||
|
Loading…
Reference in New Issue
Block a user