From owner-p4-projects@FreeBSD.ORG Thu Nov 5 00:57:54 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6FD35106568F; Thu, 5 Nov 2009 00:57:54 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1B19C106566B for ; Thu, 5 Nov 2009 00:57:54 +0000 (UTC) (envelope-from trasz@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 085E38FC52 for ; Thu, 5 Nov 2009 00:57:54 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id nA50vrmw027562 for ; Thu, 5 Nov 2009 00:57:53 GMT (envelope-from trasz@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id nA50vrWd027560 for perforce@freebsd.org; Thu, 5 Nov 2009 00:57:53 GMT (envelope-from trasz@freebsd.org) Date: Thu, 5 Nov 2009 00:57:53 GMT Message-Id: <200911050057.nA50vrWd027560@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to trasz@freebsd.org using -f From: Edward Tomasz Napierala To: Perforce Change Reviews Precedence: bulk Cc: Subject: PERFORCE change 170207 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Nov 2009 00:57:54 -0000 http://p4web.freebsd.org/chv.cgi?CH=170207 Change 170207 by trasz@trasz_victim on 2009/11/05 00:57:37 Be rational. Instead of inventing two different semantics for VAPPEND, just stick to the notion that VAPPEND is just a modifier for VWRITE. Add a few KASSERTs to make sure this is the case. Affected files ... .. //depot/projects/soc2008/trasz_nfs4acl/share/man/man9/VOP_ACCESS.9#10 edit .. //depot/projects/soc2008/trasz_nfs4acl/sys/kern/subr_acl_nfs4.c#52 edit .. //depot/projects/soc2008/trasz_nfs4acl/sys/kern/subr_acl_posix1e.c#18 edit .. //depot/projects/soc2008/trasz_nfs4acl/sys/kern/vfs_subr.c#42 edit .. //depot/projects/soc2008/trasz_nfs4acl/sys/ufs/ufs/ufs_lookup.c#19 edit Differences ... ==== //depot/projects/soc2008/trasz_nfs4acl/share/man/man9/VOP_ACCESS.9#10 (text+ko) ==== @@ -80,6 +80,13 @@ To check for other flags, one has to use .Fn VOP_ACCESSX instead. +.Pp +The +.Dv VAPPEND +flag may only be set if +.Dv +VWRITE +flag is set. .Sh LOCKS The vnode will be locked on entry and should remain locked on return. .Sh RETURN VALUES ==== //depot/projects/soc2008/trasz_nfs4acl/sys/kern/subr_acl_nfs4.c#52 (text+ko) ==== @@ -82,6 +82,13 @@ access_mask |= accmode2mask[i].mask; } + /* + * VAPPEND is just a modifier for VWRITE; if the caller asked + * for 'VAPPEND | VWRITE', we want to check for ACL_APPEND_DATA only. + */ + if (access_mask & ACL_APPEND_DATA) + access_mask &= ~ACL_WRITE_DATA; + return (access_mask); } @@ -156,6 +163,9 @@ int denied, explicitly_denied, access_mask, is_directory, must_be_owner = 0; + KASSERT((accmode & VAPPEND) == 0 || (accmode & VWRITE), + ("VAPPEND without VWRITE")); + if (privused != NULL) *privused = 0; ==== //depot/projects/soc2008/trasz_nfs4acl/sys/kern/subr_acl_posix1e.c#18 (text+ko) ==== @@ -63,6 +63,8 @@ KASSERT((accmode & ~(VEXEC | VWRITE | VREAD | VADMIN | VAPPEND)) == 0, ("invalid bit in accmode")); + KASSERT((accmode & VAPPEND) == 0 || (accmode & VWRITE), + ("VAPPEND without VWRITE")); /* * Look for a normal, non-privileged way to access the file/directory ==== //depot/projects/soc2008/trasz_nfs4acl/sys/kern/vfs_subr.c#42 (text+ko) ==== @@ -3522,6 +3522,8 @@ KASSERT((accmode & ~(VEXEC | VWRITE | VREAD | VADMIN | VAPPEND)) == 0, ("invalid bit in accmode")); + KASSERT((accmode & VAPPEND) == 0 || (accmode & VWRITE), + ("VAPPEND without VWRITE")); /* * Look for a normal, non-privileged way to access the file/directory ==== //depot/projects/soc2008/trasz_nfs4acl/sys/ufs/ufs/ufs_lookup.c#19 (text+ko) ==== @@ -469,7 +469,7 @@ * XXX: Fix the comment above. */ if (flags & WILLBEDIR) - error = VOP_ACCESSX(vdp, VAPPEND, cred, cnp->cn_thread); + error = VOP_ACCESSX(vdp, VWRITE | VAPPEND, cred, cnp->cn_thread); else error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread); if (error) @@ -604,7 +604,7 @@ */ if (nameiop == RENAME && (flags & ISLASTCN)) { if (flags & WILLBEDIR) - error = VOP_ACCESSX(vdp, VAPPEND, cred, cnp->cn_thread); + error = VOP_ACCESSX(vdp, VWRITE | VAPPEND, cred, cnp->cn_thread); else error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread); if (error) @@ -637,7 +637,7 @@ * of EACCESS. */ if (tdp->v_type == VDIR) - error = VOP_ACCESSX(vdp, VAPPEND, cred, cnp->cn_thread); + error = VOP_ACCESSX(vdp, VWRITE | VAPPEND, cred, cnp->cn_thread); else error = VOP_ACCESS(vdp, VWRITE, cred, cnp->cn_thread); if (error) {