Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 98e9cb57 authored by Andreas Gruenbacher's avatar Andreas Gruenbacher Committed by Al Viro
Browse files

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: default avatarAndreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: default avatarJames Morris <james.l.morris@oracle.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 97d79299
Loading
Loading
Loading
Loading
+5 −11
Original line number Diff line number Diff line
@@ -220,15 +220,12 @@ static int v9fs_xattr_get_acl(const struct xattr_handler *handler,
	struct posix_acl *acl;
	int error;

	if (strcmp(name, "") != 0)
		return -EINVAL;

	v9ses = v9fs_dentry2v9ses(dentry);
	/*
	 * We allow set/get/list of acl when access=client is not specified
	 */
	if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
		return v9fs_xattr_get(dentry, handler->prefix, buffer, size);
		return v9fs_xattr_get(dentry, handler->name, buffer, size);

	acl = v9fs_get_cached_acl(d_inode(dentry), handler->flags);
	if (IS_ERR(acl))
@@ -250,16 +247,13 @@ static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
	struct v9fs_session_info *v9ses;
	struct inode *inode = d_inode(dentry);

	if (strcmp(name, "") != 0)
		return -EINVAL;

	v9ses = v9fs_dentry2v9ses(dentry);
	/*
	 * set the attribute on the remote. Without even looking at the
	 * xattr value. We leave it to the server to validate
	 */
	if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
		return v9fs_xattr_set(dentry, handler->prefix, value, size,
		return v9fs_xattr_set(dentry, handler->name, value, size,
				      flags);

	if (S_ISLNK(inode->i_mode))
@@ -319,7 +313,7 @@ static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
	default:
		BUG();
	}
	retval = v9fs_xattr_set(dentry, handler->prefix, value, size, flags);
	retval = v9fs_xattr_set(dentry, handler->name, value, size, flags);
	if (!retval)
		set_cached_acl(inode, handler->flags, acl);
err_out:
@@ -328,14 +322,14 @@ static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
}

const struct xattr_handler v9fs_xattr_acl_access_handler = {
	.prefix	= XATTR_NAME_POSIX_ACL_ACCESS,
	.name	= XATTR_NAME_POSIX_ACL_ACCESS,
	.flags	= ACL_TYPE_ACCESS,
	.get	= v9fs_xattr_get_acl,
	.set	= v9fs_xattr_set_acl,
};

const struct xattr_handler v9fs_xattr_acl_default_handler = {
	.prefix	= XATTR_NAME_POSIX_ACL_DEFAULT,
	.name	= XATTR_NAME_POSIX_ACL_DEFAULT,
	.flags	= ACL_TYPE_DEFAULT,
	.get	= v9fs_xattr_get_acl,
	.set	= v9fs_xattr_set_acl,
+0 −4
Original line number Diff line number Diff line
@@ -143,8 +143,6 @@ static int v9fs_xattr_handler_get(const struct xattr_handler *handler,
{
	const char *full_name = xattr_full_name(handler, name);

	if (strcmp(name, "") == 0)
		return -EINVAL;
	return v9fs_xattr_get(dentry, full_name, buffer, size);
}

@@ -154,8 +152,6 @@ static int v9fs_xattr_handler_set(const struct xattr_handler *handler,
{
	const char *full_name = xattr_full_name(handler, name);

	if (strcmp(name, "") == 0)
		return -EINVAL;
	return v9fs_xattr_set(dentry, full_name, value, size, flags);
}

+0 −4
Original line number Diff line number Diff line
@@ -28,8 +28,6 @@ ext2_xattr_security_get(const struct xattr_handler *handler,
			struct dentry *dentry, const char *name,
			void *buffer, size_t size)
{
	if (strcmp(name, "") == 0)
		return -EINVAL;
	return ext2_xattr_get(d_inode(dentry), EXT2_XATTR_INDEX_SECURITY, name,
			      buffer, size);
}
@@ -39,8 +37,6 @@ ext2_xattr_security_set(const struct xattr_handler *handler,
			struct dentry *dentry, const char *name,
			const void *value, size_t size, int flags)
{
	if (strcmp(name, "") == 0)
		return -EINVAL;
	return ext2_xattr_set(d_inode(dentry), EXT2_XATTR_INDEX_SECURITY, name,
			      value, size, flags);
}
+0 −4
Original line number Diff line number Diff line
@@ -32,8 +32,6 @@ ext2_xattr_trusted_get(const struct xattr_handler *handler,
		       struct dentry *dentry, const char *name,
		       void *buffer, size_t size)
{
	if (strcmp(name, "") == 0)
		return -EINVAL;
	return ext2_xattr_get(d_inode(dentry), EXT2_XATTR_INDEX_TRUSTED, name,
			      buffer, size);
}
@@ -43,8 +41,6 @@ ext2_xattr_trusted_set(const struct xattr_handler *handler,
		       struct dentry *dentry, const char *name,
		       const void *value, size_t size, int flags)
{
	if (strcmp(name, "") == 0)
		return -EINVAL;
	return ext2_xattr_set(d_inode(dentry), EXT2_XATTR_INDEX_TRUSTED, name,
			      value, size, flags);
}
+0 −4
Original line number Diff line number Diff line
@@ -34,8 +34,6 @@ ext2_xattr_user_get(const struct xattr_handler *handler,
		    struct dentry *dentry, const char *name,
		    void *buffer, size_t size)
{
	if (strcmp(name, "") == 0)
		return -EINVAL;
	if (!test_opt(dentry->d_sb, XATTR_USER))
		return -EOPNOTSUPP;
	return ext2_xattr_get(d_inode(dentry), EXT2_XATTR_INDEX_USER,
@@ -47,8 +45,6 @@ ext2_xattr_user_set(const struct xattr_handler *handler,
		    struct dentry *dentry, const char *name,
		    const void *value, size_t size, int flags)
{
	if (strcmp(name, "") == 0)
		return -EINVAL;
	if (!test_opt(dentry->d_sb, XATTR_USER))
		return -EOPNOTSUPP;

Loading