svn commit: r198874 - head/sys/kern

Edward Tomasz Napierała trasz at FreeBSD.org
Wed Nov 4 18:16:13 UTC 2009


Wiadomość napisana przez Pawel Jakub Dawidek w dniu 2009-11-04, o  
godz. 08:04:
> On Wed, Nov 04, 2009 at 06:48:34AM +0000, Edward Tomasz Napierala  
> wrote:
>> Author: trasz
>> Date: Wed Nov  4 06:48:34 2009
>> New Revision: 198874
>> URL: http://svn.freebsd.org/changeset/base/198874
>>
>> Log:
>>  Make sure we don't end up with VAPPEND without VWRITE, if someone  
>> calls open(2)
>>  like this: open(..., O_APPEND).
>>
>> Modified:
>>  head/sys/kern/vfs_vnops.c
>>
>> Modified: head/sys/kern/vfs_vnops.c
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- head/sys/kern/vfs_vnops.c	Wed Nov  4 06:47:14 2009	(r198873)
>> +++ head/sys/kern/vfs_vnops.c	Wed Nov  4 06:48:34 2009	(r198874)
>> @@ -213,7 +213,7 @@ restart:
>> 	if (fmode & FEXEC)
>> 		accmode |= VEXEC;
>> 	if (fmode & O_APPEND)
>> -		accmode |= VAPPEND;
>> +		accmode |= VWRITE | VAPPEND;
>> #ifdef MAC
>> 	error = mac_vnode_check_open(cred, vp, accmode);
>> 	if (error)
>
> Why? If someone does O_APPEND only we don't want to give him write
> access...

As it is now, VAPPEND is not a real V* flag - it's a kind of modifier  
to VWRITE.
Which means that it doesn't really make sense, from the conceptual  
point of view,
to have VAPPEND without VWRITE being set at the same time.  This  
doesn't break
things right now - at least I don't know about any such breakage - but  
in the
future I'd like to have a few KASSERTs to verify that VAPPEND is never  
specified
without VWRITE, just to make sure something unexpected doesn't happen  
somewhere.

As it is now, doing open(..., O_APPEND) will result in a  
filedescriptor open
for... reading.  So, the change above would change the behaviour.   
What about
something like this instead:

Index: vfs_vnops.c
===================================================================
--- vfs_vnops.c (revision 198876)
+++ vfs_vnops.c (working copy)
@@ -212,7 +212,7 @@
                 accmode |= VREAD;
         if (fmode & FEXEC)
                 accmode |= VEXEC;
-       if (fmode & O_APPEND)
+       if ((fmode & O_APPEND) && (fmode & FWRITE))
                 accmode |= VAPPEND;
  #ifdef MAC
         error = mac_vnode_check_open(cred, vp, accmode);

--
If you cut off my head, what would I say?  Me and my head, or me and  
my body?



More information about the svn-src-all mailing list