From owner-p4-projects Thu Aug 1 9:45:38 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 133A837B401; Thu, 1 Aug 2002 09:45:30 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A754737B400 for ; Thu, 1 Aug 2002 09:45:29 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4615043E6E for ; Thu, 1 Aug 2002 09:45:29 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from freefall.freebsd.org (perforce@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g71GjTJU000879 for ; Thu, 1 Aug 2002 09:45:29 -0700 (PDT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g71GjT6t000871 for perforce@freebsd.org; Thu, 1 Aug 2002 09:45:29 -0700 (PDT) Date: Thu, 1 Aug 2002 09:45:29 -0700 (PDT) Message-Id: <200208011645.g71GjT6t000871@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson Subject: PERFORCE change 15388 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=15388 Change 15388 by rwatson@rwatson_paprika on 2002/08/01 09:45:20 Alternate formulate of security checks in vn_open_cred() that does enforce appropriate protections at open-time for MAC despite O_CREAT being set or not. As with other failures during the O_CREAT case, a dud file is left around to be cleaned up by the user. Remove various comments about problems that this change should fix. Affected files ... .. //depot/projects/trustedbsd/mac/sys/kern/vfs_vnops.c#35 edit Differences ... ==== //depot/projects/trustedbsd/mac/sys/kern/vfs_vnops.c#35 (text+ko) ==== @@ -196,32 +196,29 @@ error = EOPNOTSUPP; goto bad; } + mode = 0; + if (fmode & (VWRITE | O_TRUNC)) { + if (vp->v_type == VDIR) { + error = EISDIR; + goto bad; + } + mode |= VWRITE; + } + if (fmode & FREAD) + mode |= VREAD; + if (fmode & O_APPEND) + mode |= VAPPEND; +#ifdef MAC + error = mac_check_vnode_open(cred, vp, mode); + if (error) + goto bad; +#endif if ((fmode & O_CREAT) == 0) { - mode = 0; - if (fmode & (FWRITE | O_TRUNC)) { - if (vp->v_type == VDIR) { - error = EISDIR; - goto bad; - } + if (mode & VWRITE) { error = vn_writechk(vp); if (error) goto bad; - mode |= VWRITE; } - if (fmode & FREAD) - mode |= VREAD; - if (fmode & O_APPEND) - mode |= VAPPEND; -#ifdef MAC - /* - * XXXMAC: Note that for newly created files, we never - * perform an open check. This is probably wrong, but if - * we add it, the failure modes need to be right. - */ - error = mac_check_vnode_open(cred, vp, mode); - if (error) - goto bad; -#endif /* MAC */ if (mode) { error = VOP_ACCESS(vp, mode, cred, td); if (error) @@ -232,11 +229,6 @@ vp->v_cachedfs = vap->va_fsid; vp->v_cachedid = vap->va_fileid; } -#ifdef MAC - /* - * XXXMAC: Open check should probably be here. - */ -#endif if ((error = VOP_OPEN(vp, fmode, cred, td)) != 0) goto bad; /* To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message