Date: Thu, 1 Aug 2002 09:45:29 -0700 (PDT) From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 15388 for review Message-ID: <200208011645.g71GjT6t000871@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200208011645.g71GjT6t000871>