All of lore.kernel.org
 help / color / mirror / Atom feed
* [NFS] [PATCH] nfs4, special files, and set/listxattr asymmetry
@ 2008-01-08  3:14 Erez Zadok
       [not found] ` <200801080314.m083EVbb011378-zop+azHP2WsZjdeEBZXbMidm6ipF23ct@public.gmane.org>
  0 siblings, 1 reply; 14+ messages in thread
From: Erez Zadok @ 2008-01-08  3:14 UTC (permalink / raw)
  To: nfs, Trond.Myklebust


Trond, I've discovered an asymmetry in how nfs4 (in v2.6.24-rc7) handles
listxattr vs. setxattr for special files.  I caught this with Unionfs when
testing a copyup of a character device from a readonly nfs4 mount to a
writable nfs4 mount.

nfs4_setxattr returns -EPERM if the inode isn't a regular file or a (sticky)
dir.  However, nfs4_listxattr returns XATTR_NAME_NFSV4_ACL (16 bytes,
"system.nfs4_acl") regardless of the type of the inode.  So during copyup, I
can ->listxattr fine from the source inode, but I get EPERM trying to
->setxattr on the destination branch of of the copyup.  (I already handle
the case when copying-up from a f/s which supports xattr's to one which
doesn't, but when both file systems are the same and mounted the same, there
typically should not be difference).

Assuming that the original intent of the EPERM check in nfs4_setxattr was to
prevent setting xattrs over nfs4 for non-files/dirs, then I "fixed" this by
adding a similar check in nfs4_listxattr, which returns an empty xattr list
for those.  I've included a patch below for your consideration/review.

Cheers,
Erez.

--cut-here----cut-here----cut-here----cut-here----cut-here----cut-here--

NFS4: ignore non files/dirs in nfs4_getxattr, same as nfs4_listxattr

Signed-off-by: Erez Zadok <ezk-EX0cT3Az47bauI2f2gSDlQ@public.gmane.org>

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 9e2e1c7..ad46fef 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -3656,9 +3656,13 @@ ssize_t nfs4_getxattr(struct dentry *dentry, const char *key, void *buf,
 ssize_t nfs4_listxattr(struct dentry *dentry, char *buf, size_t buflen)
 {
 	size_t len = strlen(XATTR_NAME_NFSV4_ACL) + 1;
+	struct inode *inode = dentry->d_inode;
 
 	if (!nfs4_server_supports_acls(NFS_SERVER(dentry->d_inode)))
 		return 0;
+	if (!S_ISREG(inode->i_mode) &&
+	    (!S_ISDIR(inode->i_mode) || inode->i_mode & S_ISVTX))
+		return 0;
 	if (buf && buflen < len)
 		return -ERANGE;
 	if (buf)


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs
_______________________________________________
Please note that nfs@lists.sourceforge.net is being discontinued.
Please subscribe to linux-nfs@vger.kernel.org instead.
    http://vger.kernel.org/vger-lists.html#linux-nfs


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

end of thread, other threads:[~2008-01-15 21:49 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-08  3:14 [NFS] [PATCH] nfs4, special files, and set/listxattr asymmetry Erez Zadok
     [not found] ` <200801080314.m083EVbb011378-zop+azHP2WsZjdeEBZXbMidm6ipF23ct@public.gmane.org>
2008-01-08  3:34   ` Trond Myklebust
     [not found]     ` <1199763245.21371.6.camel-rJ7iovZKK19ZJLDQqaL3InhyD016LWXt@public.gmane.org>
2008-01-08 17:46       ` J. Bruce Fields
2008-01-08 21:26         ` Erez Zadok
     [not found]           ` <200801082126.m08LQTZm021972-zop+azHP2WsZjdeEBZXbMidm6ipF23ct@public.gmane.org>
2008-01-08 21:45             ` J. Bruce Fields
2008-01-08 21:48               ` Erez Zadok
2008-01-15 21:43             ` [NFS] [PATCH] nfs4: allow nfsv4 acls on non-regular-files J. Bruce Fields
2008-01-15 21:48               ` Trond Myklebust
2008-01-08 18:20       ` [NFS] [PATCH] nfs4, special files, and set/listxattr asymmetry J. Bruce Fields
2008-01-08 21:47         ` Erez Zadok
     [not found]           ` <200801082147.m08LlF3D023364-zop+azHP2WsZjdeEBZXbMidm6ipF23ct@public.gmane.org>
2008-01-08 21:57             ` J. Bruce Fields
2008-01-08 22:05               ` Dave Quigley
     [not found]                 ` <1199829935.8434.75.camel-88+Bj4OksMGWPftkNcioYDMZycKHmlmlfvIqQ387n9k@public.gmane.org>
2008-01-08 22:25                   ` J. Bruce Fields
2008-01-08 22:18                     ` Dave Quigley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.