Paranoia: check KTRPOINT() before calling ktrpledge() to guarantee we
authorguenther <guenther@openbsd.org>
Sun, 10 Jul 2016 00:39:23 +0000 (00:39 +0000)
committerguenther <guenther@openbsd.org>
Sun, 10 Jul 2016 00:39:23 +0000 (00:39 +0000)
can't (in the future) loop from ktrace writing hitting a pledge condition.

diff from Michal Mazurek (akfaew (at) jasminek.net)

sys/kern/kern_pledge.c

index 8e2180a..2d254dc 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: kern_pledge.c,v 1.174 2016/07/03 04:36:08 semarie Exp $       */
+/*     $OpenBSD: kern_pledge.c,v 1.175 2016/07/10 00:39:23 guenther Exp $      */
 
 /*
  * Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -577,7 +577,8 @@ pledge_fail(struct proc *p, int error, uint64_t code)
        printf("%s(%d): syscall %d \"%s\"\n", p->p_comm, p->p_pid,
            p->p_pledge_syscall, codes);
 #ifdef KTRACE
-       ktrpledge(p, error, code, p->p_pledge_syscall);
+       if (KTRPOINT(p, KTR_PLEDGE))
+               ktrpledge(p, error, code, p->p_pledge_syscall);
 #endif
        /* Send uncatchable SIGABRT for coredump */
        memset(&sa, 0, sizeof sa);