sync with OpenBSD -current

This commit is contained in:
purplerain 2023-12-16 16:23:05 +00:00
parent 30cf31d90d
commit 8f3269c13c
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
27 changed files with 498 additions and 682 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: kern_ktrace.c,v 1.113 2023/12/12 15:30:55 deraadt Exp $ */
/* $OpenBSD: kern_ktrace.c,v 1.114 2023/12/15 15:12:08 deraadt Exp $ */
/* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */
/*
@ -401,6 +401,24 @@ ktrpledge(struct proc *p, int error, uint64_t code, int syscall)
atomic_clearbits_int(&p->p_flag, P_INKTR);
}
void
ktrpinsyscall(struct proc *p, int error, int syscall, vaddr_t addr)
{
struct ktr_header kth;
struct ktr_pinsyscall kp;
atomic_setbits_int(&p->p_flag, P_INKTR);
ktrinitheader(&kth, p, KTR_PINSYSCALL);
kp.error = error;
kp.syscall = syscall;
kp.addr = addr;
KERNEL_LOCK();
ktrwrite(p, &kth, &kp, sizeof(kp));
KERNEL_UNLOCK();
atomic_clearbits_int(&p->p_flag, P_INKTR);
}
/* Interface and common routines */
int

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ktrace.h,v 1.47 2023/12/12 15:30:55 deraadt Exp $ */
/* $OpenBSD: ktrace.h,v 1.48 2023/12/15 15:12:08 deraadt Exp $ */
/* $NetBSD: ktrace.h,v 1.12 1996/02/04 02:12:29 christos Exp $ */
/*
@ -166,6 +166,16 @@ struct ktr_pledge {
uint64_t code;
};
/*
* KTR_PINSYSCALL - details of pinsyscall violation
*/
#define KTR_PINSYSCALL 13
struct ktr_pinsyscall {
int error;
int syscall;
vaddr_t addr;
};
/*
* kernel trace points (in ps_traceflag)
*/
@ -180,6 +190,7 @@ struct ktr_pledge {
#define KTRFAC_EXECARGS (1<<KTR_EXECARGS)
#define KTRFAC_EXECENV (1<<KTR_EXECENV)
#define KTRFAC_PLEDGE (1<<KTR_PLEDGE)
#define KTRFAC_PINSYSCALL (1<<KTR_PINSYSCALL)
/*
* trace flags (also in ps_traceflag)
@ -212,6 +223,7 @@ void ktrsysret(struct proc *, register_t, int, const register_t [2]);
int ktruser(struct proc *, const char *, const void *, size_t);
void ktrexec(struct proc *, int, const char *, ssize_t);
void ktrpledge(struct proc *, int, uint64_t, int);
void ktrpinsyscall(struct proc *, int, int, vaddr_t);
void ktrcleartrace(struct process *);
void ktrsettrace(struct process *, int, struct vnode *, struct ucred *);