mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
vfs: Distinguish between full xattr names and proper prefixes
Add an additional "name" field to struct xattr_handler. When the name
is set, the handler matches attributes with exactly that name. When the
prefix is set instead, the handler matches attributes with the given
prefix and with a non-empty suffix.
This patch should avoid bugs like the one fixed in commit c361016a in
the future.
Signed-off-by: Andreas Gruenbacher <[email protected]>
Reviewed-by: James Morris <[email protected]>
Signed-off-by: Al Viro <[email protected]>
This commit is contained in:
parent
97d7929922
commit
98e9cb5711
22 changed files with 47 additions and 130 deletions
27
fs/xattr.c
27
fs/xattr.c
|
|
@ -681,13 +681,20 @@ xattr_resolve_name(const struct xattr_handler **handlers, const char **name)
|
|||
return NULL;
|
||||
|
||||
for_each_xattr_handler(handlers, handler) {
|
||||
const char *n = strcmp_prefix(*name, handler->prefix);
|
||||
const char *n;
|
||||
|
||||
n = strcmp_prefix(*name, xattr_prefix(handler));
|
||||
if (n) {
|
||||
if (!handler->prefix ^ !*n) {
|
||||
if (*n)
|
||||
continue;
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
*name = n;
|
||||
break;
|
||||
return handler;
|
||||
}
|
||||
}
|
||||
return handler;
|
||||
return ERR_PTR(-EOPNOTSUPP);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -699,8 +706,8 @@ generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t s
|
|||
const struct xattr_handler *handler;
|
||||
|
||||
handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
|
||||
if (!handler)
|
||||
return -EOPNOTSUPP;
|
||||
if (IS_ERR(handler))
|
||||
return PTR_ERR(handler);
|
||||
return handler->get(handler, dentry, name, buffer, size);
|
||||
}
|
||||
|
||||
|
|
@ -746,8 +753,8 @@ generic_setxattr(struct dentry *dentry, const char *name, const void *value, siz
|
|||
if (size == 0)
|
||||
value = ""; /* empty EA, do not remove */
|
||||
handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
|
||||
if (!handler)
|
||||
return -EOPNOTSUPP;
|
||||
if (IS_ERR(handler))
|
||||
return PTR_ERR(handler);
|
||||
return handler->set(handler, dentry, name, value, size, flags);
|
||||
}
|
||||
|
||||
|
|
@ -761,8 +768,8 @@ generic_removexattr(struct dentry *dentry, const char *name)
|
|||
const struct xattr_handler *handler;
|
||||
|
||||
handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
|
||||
if (!handler)
|
||||
return -EOPNOTSUPP;
|
||||
if (IS_ERR(handler))
|
||||
return PTR_ERR(handler);
|
||||
return handler->set(handler, dentry, name, NULL, 0, XATTR_REPLACE);
|
||||
}
|
||||
|
||||
|
|
@ -789,7 +796,7 @@ EXPORT_SYMBOL(generic_removexattr);
|
|||
const char *xattr_full_name(const struct xattr_handler *handler,
|
||||
const char *name)
|
||||
{
|
||||
size_t prefix_len = strlen(handler->prefix);
|
||||
size_t prefix_len = strlen(xattr_prefix(handler));
|
||||
|
||||
return name - prefix_len;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue