diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-06-20 10:48:56 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2018-06-20 10:48:56 +0000 |
commit | 367bd392c9b11685df777a9444ca906cec454a1d (patch) | |
tree | 68244099e1e5b366c2b5da6998e5191be0c562e8 /sys/kern | |
parent | 8aca34b80e48c79b05777c052e31cb9a6a9a6f1f (diff) |
Grab and/or assert for the KERNEL_LOCK() in in ktrace & pledge.
This is required to run network syscall mostly without the KERNEL_LOCK().
ok visa@, kettenis@ as part of a larger diff.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_ktrace.c | 18 | ||||
-rw-r--r-- | sys/kern/kern_pledge.c | 4 |
2 files changed, 16 insertions, 6 deletions
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 0996084952f..7315d41b26d 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_ktrace.c,v 1.97 2018/05/27 06:02:14 visa Exp $ */ +/* $OpenBSD: kern_ktrace.c,v 1.98 2018/06/20 10:48:55 mpi Exp $ */ /* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */ /* @@ -225,7 +225,7 @@ ktrgenio(struct proc *p, int fd, enum uio_rw rw, struct iovec *iov, struct ktr_header kth; struct ktr_genio ktp; caddr_t cp; - int count; + int count, error; int buflen; atomic_setbits_int(&p->p_flag, P_INKTR); @@ -254,7 +254,10 @@ ktrgenio(struct proc *p, int fd, enum uio_rw rw, struct iovec *iov, if (copyin(iov->iov_base, cp, count)) break; - if (ktrwrite2(p, &kth, &ktp, sizeof(ktp), cp, count) != 0) + KERNEL_LOCK(); + error = ktrwrite2(p, &kth, &ktp, sizeof(ktp), cp, count); + KERNEL_UNLOCK(); + if (error != 0) break; iov->iov_len -= count; @@ -294,13 +297,14 @@ ktrstruct(struct proc *p, const char *name, const void *data, size_t datalen) { struct ktr_header kth; - KERNEL_ASSERT_LOCKED(); atomic_setbits_int(&p->p_flag, P_INKTR); ktrinitheader(&kth, p, KTR_STRUCT); - + if (data == NULL) datalen = 0; + KERNEL_LOCK(); ktrwrite2(p, &kth, name, strlen(name) + 1, data, datalen); + KERNEL_UNLOCK(); atomic_clearbits_int(&p->p_flag, P_INKTR); } @@ -386,7 +390,9 @@ ktrpledge(struct proc *p, int error, uint64_t code, int syscall) kp.code = code; kp.syscall = syscall; + KERNEL_LOCK(); ktrwrite(p, &kth, &kp, sizeof(kp)); + KERNEL_UNLOCK(); atomic_clearbits_int(&p->p_flag, P_INKTR); } @@ -623,6 +629,8 @@ ktrwriteraw(struct proc *curp, struct vnode *vp, struct ucred *cred, struct process *pr; int error; + KERNEL_ASSERT_LOCKED(); + auio.uio_iov = &aiov[0]; auio.uio_offset = 0; auio.uio_segflg = UIO_SYSSPACE; diff --git a/sys/kern/kern_pledge.c b/sys/kern/kern_pledge.c index 9f253d1e6f7..504a3658769 100644 --- a/sys/kern/kern_pledge.c +++ b/sys/kern/kern_pledge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_pledge.c,v 1.232 2018/06/16 15:37:00 florian Exp $ */ +/* $OpenBSD: kern_pledge.c,v 1.233 2018/06/20 10:48:55 mpi Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org> @@ -524,6 +524,7 @@ pledge_fail(struct proc *p, int error, uint64_t code) if (p->p_p->ps_pledge & PLEDGE_ERROR) return (ENOSYS); + KERNEL_LOCK(); log(LOG_ERR, "%s[%d]: pledge \"%s\", syscall %d\n", p->p_p->ps_comm, p->p_p->ps_pid, codes, p->p_pledge_syscall); p->p_p->ps_acflag |= APLEDGE; @@ -536,6 +537,7 @@ pledge_fail(struct proc *p, int error, uint64_t code) psignal(p, SIGABRT); p->p_p->ps_pledge = 0; /* Disable all PLEDGE_ flags */ + KERNEL_UNLOCK(); return (error); } |