Skip to contentSkip to conversation

vfs: Pass setxattr(2) flags properly

PATCH In review Jan Kara 3 participants 5 messages Apr 20, 2011 – Apr 21, 2011 VFS

lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

PATCH 1/1 vfs: Pass setxattr(2) flags properly

For some reason generic_setxattr() did not pass flags (XATTR_CREATE, XATTR_REPLACE) to the filesystem specific helper. This caused that setxattr(2) syscall just ignored these flags.

Fix the bug by passing flags correctly.

---
 fs/xattr.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Who's handling VFS changes when Al is away? Andrew?

fs/xattr.c +1 -1
index a19acdb..f1ef949 100644
@@ -666,7 +666,7 @@ generic_setxattr(struct dentry *dentry, const char *name, const void *value, siz
 	handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
 	if (!handler)
 		return -EOPNOTSUPP;
-	return handler->set(dentry, name, value, size, 0, handler->flags);
+	return handler->set(dentry, name, value, size, flags, handler->flags);
 }
 
 /*
Signature · 1 line
1.7.1
#1 lore raw

Hmm. This patch looks very sane, but it's been that way - ignoring the 'flags' value - since 2009. Does anybody actually _use_ the flags field?

Judging by commit 431547b3c453 (that introduced the thing), it looks like a plain mistake, and the previous "flags" was replaced by a "0" in the call when it added the "hander->flags" argument at the end. But the fact that it's been two years, and nobody noticed, makes me go "hmm.."

Christoph added to participants, since he's the cause of that change.

Quoted 4 lines · Jan Kara

For some reason generic_setxattr() did not pass flags (XATTR_CREATE, XATTR_REPLACE) to the filesystem specific helper. This caused that setxattr(2) syscall just ignored these flags.

Quoted 8 lines

Fix the bug by passing flags correctly.

---
 fs/xattr.c |    2 +-

 1 files changed, 1 insertions(+), 1 deletions(-)

 Who's handling VFS changes when Al is away? Andrew?

I guess it's mostly me for at least the path handling, but for something like this I'd like Christoph to take a look too. Even if it _looks_ like a really obvious fix.

Quoted 18 lines
fs/xattr.c +1 -2
index a19acdb..f1ef949 100644
@@ -666,7 +666,7 @@ generic_setxattr(struct dentry *dentry, const char *name, const void *value, siz
        handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
        if (!handler)
                return -EOPNOTSUPP;
-       return handler->set(dentry, name, value, size, 0, handler->flags);
+       return handler->set(dentry, name, value, size, flags, handler->flags);
  }
 
  /*
--

1.7.1

#2 lore raw
Quoted 9 lines · Linus Torvalds

Hmm. This patch looks very sane, but it's been that way - ignoring the 'flags' value - since 2009. Does anybody actually _use_ the flags field?

Judging by commit 431547b3c453 (that introduced the thing), it looks like a plain mistake, and the previous "flags" was replaced by a "0" in the call when it added the "hander->flags" argument at the end. But the fact that it's been two years, and nobody noticed, makes me go "hmm.."

It's not really used very much. The only use of XATTR_CREATE is to prevent creating the attrs used for ACLs from the normal xattrs interface instead of going through the ACL code, and XATTR_REPLACE is only used to return -ENOATTR when it's set but the attribute actually is empty.

The first one could probably be used (by root) to create invalid attrs that confuse the ACL code, and the second may confuse application using it, although I doubt there are many.

#3 lore raw
Quoted 10 lines · Christoph Hellwig

It's not really used very much.  The only use of XATTR_CREATE is to prevent creating the attrs used for ACLs from the normal xattrs interface instead of going through the ACL code, and XATTR_REPLACE is only used to return -ENOATTR when it's set but the attribute actually is empty.

The first one could probably be used (by root) to create invalid attrs that confuse the ACL code, and the second may confuse application using it, although I doubt there are many.

Ok.

So nobody much i going to care. But I presume that you ack the patch itself as correct?

Linus

#4 lore raw
Quoted 2 lines · Linus Torvalds

So nobody much i going to care. But I presume that you ack the patch itself as correct?

Yes, the patch looks correct.