public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* bug: truncate to zero + setuid
@ 2007-10-28 14:36 Roger Willcocks
  2007-10-29  0:54 ` Tim Shimmin
  0 siblings, 1 reply; 8+ messages in thread
From: Roger Willcocks @ 2007-10-28 14:36 UTC (permalink / raw)
  To: xfs

The nfsv3 setattr call permits a simultaneous truncate + setuid/gid 
operation. Normally XFS handles this fine, but if the file's being 
truncated to zero, and the file's already empty, XFS simply ignores the 
setuid/gid part, returning 'success'.

The error's in xfs_vnodeops.c/xfs_setattr below the comment 
'Short circuit the truncate case for zero length files', which bypasses 
all other changes.

The simplest fix is to test whether this is the only change that's 
happening, otherwise you get tangled in transactions.

        if (mask & XFS_AT_SIZE) {
                /* Short circuit the truncate case for zero length files */
-               if ((vap->va_size == 0) &&
+               if (((mask & ~XFS_AT_SIZE) == 0) && (vap->va_size == 0) &&
                   (ip->i_d.di_size == 0) && (ip->i_d.di_nextents == 0)) {


--
Roger

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-11-08  3:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-28 14:36 bug: truncate to zero + setuid Roger Willcocks
2007-10-29  0:54 ` Tim Shimmin
2007-10-29 18:56   ` Roger Willcocks
2007-10-30  4:06     ` Timothy Shimmin
2007-10-30 17:28       ` Roger Willcocks
2007-11-02  1:11         ` Timothy Shimmin
2007-11-04 11:59           ` Roger Willcocks
2007-11-08  3:13             ` Timothy Shimmin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox