kern_ktrace.c (104354) | kern_ktrace.c (109623) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)kern_ktrace.c 8.2 (Berkeley) 9/23/93 | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)kern_ktrace.c 8.2 (Berkeley) 9/23/93 |
34 * $FreeBSD: head/sys/kern/kern_ktrace.c 104354 2002-10-02 07:44:29Z scottl $ | 34 * $FreeBSD: head/sys/kern/kern_ktrace.c 109623 2003-01-21 08:56:16Z alfred $ |
35 */ 36 37#include "opt_ktrace.h" 38#include "opt_mac.h" 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/fcntl.h> --- 83 unchanged lines hidden (view full) --- 126 struct ktr_request *req; 127 int i; 128 129 mtx_init(&ktrace_mtx, "ktrace", NULL, MTX_DEF | MTX_QUIET); 130 sema_init(&ktrace_sema, 0, "ktrace"); 131 STAILQ_INIT(&ktr_todo); 132 STAILQ_INIT(&ktr_free); 133 for (i = 0; i < ktr_requestpool; i++) { | 35 */ 36 37#include "opt_ktrace.h" 38#include "opt_mac.h" 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/fcntl.h> --- 83 unchanged lines hidden (view full) --- 126 struct ktr_request *req; 127 int i; 128 129 mtx_init(&ktrace_mtx, "ktrace", NULL, MTX_DEF | MTX_QUIET); 130 sema_init(&ktrace_sema, 0, "ktrace"); 131 STAILQ_INIT(&ktr_todo); 132 STAILQ_INIT(&ktr_free); 133 for (i = 0; i < ktr_requestpool; i++) { |
134 req = malloc(sizeof(struct ktr_request), M_KTRACE, M_WAITOK); | 134 req = malloc(sizeof(struct ktr_request), M_KTRACE, 0); |
135 STAILQ_INSERT_HEAD(&ktr_free, req, ktr_list); 136 } 137 kthread_create(ktr_loop, NULL, NULL, RFHIGHPID, 0, "ktrace"); 138} 139SYSINIT(ktrace_init, SI_SUB_KTRACE, SI_ORDER_ANY, ktrace_init, NULL); 140 141static int 142sysctl_kern_ktrace_request_pool(SYSCTL_HANDLER_ARGS) --- 51 unchanged lines hidden (view full) --- 194 free(req, M_KTRACE); 195 mtx_lock(&ktrace_mtx); 196 } 197 else 198 /* Grow pool up to newsize. */ 199 while (ktr_requestpool < newsize) { 200 mtx_unlock(&ktrace_mtx); 201 req = malloc(sizeof(struct ktr_request), M_KTRACE, | 135 STAILQ_INSERT_HEAD(&ktr_free, req, ktr_list); 136 } 137 kthread_create(ktr_loop, NULL, NULL, RFHIGHPID, 0, "ktrace"); 138} 139SYSINIT(ktrace_init, SI_SUB_KTRACE, SI_ORDER_ANY, ktrace_init, NULL); 140 141static int 142sysctl_kern_ktrace_request_pool(SYSCTL_HANDLER_ARGS) --- 51 unchanged lines hidden (view full) --- 194 free(req, M_KTRACE); 195 mtx_lock(&ktrace_mtx); 196 } 197 else 198 /* Grow pool up to newsize. */ 199 while (ktr_requestpool < newsize) { 200 mtx_unlock(&ktrace_mtx); 201 req = malloc(sizeof(struct ktr_request), M_KTRACE, |
202 M_WAITOK); | 202 0); |
203 mtx_lock(&ktrace_mtx); 204 STAILQ_INSERT_HEAD(&ktr_free, req, ktr_list); 205 ktr_requestpool++; 206 } 207 return (ktr_requestpool); 208} 209 210static struct ktr_request * --- 105 unchanged lines hidden (view full) --- 316{ 317 struct ktr_request *req; 318 struct ktr_syscall *ktp; 319 size_t buflen; 320 char *buf = NULL; 321 322 buflen = sizeof(register_t) * narg; 323 if (buflen > 0) { | 203 mtx_lock(&ktrace_mtx); 204 STAILQ_INSERT_HEAD(&ktr_free, req, ktr_list); 205 ktr_requestpool++; 206 } 207 return (ktr_requestpool); 208} 209 210static struct ktr_request * --- 105 unchanged lines hidden (view full) --- 316{ 317 struct ktr_request *req; 318 struct ktr_syscall *ktp; 319 size_t buflen; 320 char *buf = NULL; 321 322 buflen = sizeof(register_t) * narg; 323 if (buflen > 0) { |
324 buf = malloc(buflen, M_KTRACE, M_WAITOK); | 324 buf = malloc(buflen, M_KTRACE, 0); |
325 bcopy(args, buf, buflen); 326 } 327 req = ktr_getrequest(KTR_SYSCALL); 328 if (req == NULL) { 329 if (buf != NULL) 330 free(buf, M_KTRACE); 331 return; 332 } --- 33 unchanged lines hidden (view full) --- 366 char *path; 367{ 368 struct ktr_request *req; 369 int namelen; 370 char *buf = NULL; 371 372 namelen = strlen(path); 373 if (namelen > 0) { | 325 bcopy(args, buf, buflen); 326 } 327 req = ktr_getrequest(KTR_SYSCALL); 328 if (req == NULL) { 329 if (buf != NULL) 330 free(buf, M_KTRACE); 331 return; 332 } --- 33 unchanged lines hidden (view full) --- 366 char *path; 367{ 368 struct ktr_request *req; 369 int namelen; 370 char *buf = NULL; 371 372 namelen = strlen(path); 373 if (namelen > 0) { |
374 buf = malloc(namelen, M_KTRACE, M_WAITOK); | 374 buf = malloc(namelen, M_KTRACE, 0); |
375 bcopy(path, buf, namelen); 376 } 377 req = ktr_getrequest(KTR_NAMEI); 378 if (req == NULL) { 379 if (buf != NULL) 380 free(buf, M_KTRACE); 381 return; 382 } --- 25 unchanged lines hidden (view full) --- 408 int datalen; 409 char *buf; 410 411 if (error) 412 return; 413 uio->uio_offset = 0; 414 uio->uio_rw = UIO_WRITE; 415 datalen = imin(uio->uio_resid, ktr_geniosize); | 375 bcopy(path, buf, namelen); 376 } 377 req = ktr_getrequest(KTR_NAMEI); 378 if (req == NULL) { 379 if (buf != NULL) 380 free(buf, M_KTRACE); 381 return; 382 } --- 25 unchanged lines hidden (view full) --- 408 int datalen; 409 char *buf; 410 411 if (error) 412 return; 413 uio->uio_offset = 0; 414 uio->uio_rw = UIO_WRITE; 415 datalen = imin(uio->uio_resid, ktr_geniosize); |
416 buf = malloc(datalen, M_KTRACE, M_WAITOK); | 416 buf = malloc(datalen, M_KTRACE, 0); |
417 if (uiomove(buf, datalen, uio)) { 418 free(buf, M_KTRACE); 419 return; 420 } 421 req = ktr_getrequest(KTR_GENIO); 422 if (req == NULL) { 423 free(buf, M_KTRACE); 424 return; --- 195 unchanged lines hidden (view full) --- 620 struct ktr_request *req; 621 void *cp; 622 int error; 623 624 if (!KTRPOINT(td, KTR_USER)) 625 return (0); 626 if (uap->len > KTR_USER_MAXLEN) 627 return (EINVAL); | 417 if (uiomove(buf, datalen, uio)) { 418 free(buf, M_KTRACE); 419 return; 420 } 421 req = ktr_getrequest(KTR_GENIO); 422 if (req == NULL) { 423 free(buf, M_KTRACE); 424 return; --- 195 unchanged lines hidden (view full) --- 620 struct ktr_request *req; 621 void *cp; 622 int error; 623 624 if (!KTRPOINT(td, KTR_USER)) 625 return (0); 626 if (uap->len > KTR_USER_MAXLEN) 627 return (EINVAL); |
628 cp = malloc(uap->len, M_KTRACE, M_WAITOK); | 628 cp = malloc(uap->len, M_KTRACE, 0); |
629 error = copyin(uap->addr, cp, uap->len); 630 if (error) { 631 free(cp, M_KTRACE); 632 return (error); 633 } 634 req = ktr_getrequest(KTR_USER); 635 if (req == NULL) { 636 free(cp, M_KTRACE); --- 225 unchanged lines hidden --- | 629 error = copyin(uap->addr, cp, uap->len); 630 if (error) { 631 free(cp, M_KTRACE); 632 return (error); 633 } 634 req = ktr_getrequest(KTR_USER); 635 if (req == NULL) { 636 free(cp, M_KTRACE); --- 225 unchanged lines hidden --- |