From owner-freebsd-hackers Fri Jul 23 22:12:31 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 2859114FA6 for ; Fri, 23 Jul 1999 22:12:30 -0700 (PDT) (envelope-from jkoshy@FreeBSD.org) Received: (from jkoshy@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id WAA19120; Fri, 23 Jul 1999 22:12:29 -0700 (PDT) (envelope-from jkoshy@FreeBSD.org) Date: Fri, 23 Jul 1999 22:12:29 -0700 (PDT) From: Message-Id: <199907240512.WAA19120@freefall.freebsd.org> X-Mailer: exmh version 2.0.2 2/24/98 To: freebsd-hackers@freebsd.org Cc: Subject: deny ktrace without read permissions? Mime-Version: 1.0 Content-Type: text/plain Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG PR bin/3546 asks that `ktrace(1)' not be allowed on files that do not have read permissions for the user attempting to execute them. The intent of this change is to prevent a user from seeing how an executable with '--x--x--x' perms works by ktrace'ing its execution. My question to the -hackers is: is this a useful semantic? Would it break anything if added? A patch to "/sys/kern/kern_exec.c" that adds this functionality is attached for those who would like to play with the change. Regards, Koshy Index: /sys/kern/kern_exec.c =================================================================== RCS file: /home/ncvs/src/sys/kern/kern_exec.c,v retrieving revision 1.99 diff -u -r1.99 kern_exec.c --- kern_exec.c 1999/04/27 11:15:55 1.99 +++ kern_exec.c 1999/07/24 10:35:09 @@ -26,6 +26,8 @@ * $Id: kern_exec.c,v 1.99 1999/04/27 11:15:55 phk Exp $ */ +#include "opt_ktrace.h" + #include #include #include @@ -48,6 +50,9 @@ #include #include #include +#ifdef KTRACE +#include +#endif #include #include @@ -650,6 +655,7 @@ struct vnode *vp = imgp->vp; struct vattr *attr = imgp->attr; int error; + int mode; /* Get file attributes */ error = VOP_GETATTR(vp, attr, p->p_ucred, p); @@ -677,9 +683,14 @@ return (ENOEXEC); /* - * Check for execute permission to file based on current credentials. + * Check for execute permission to file based on current credentials. */ - error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); + mode = VEXEC; +#ifdef KTRACE + if (p->p_traceflag & KTRFAC_MASK) + mode |= VREAD; +#endif + error = VOP_ACCESS(vp, mode, p->p_ucred, p); if (error) return (error); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message