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

Commit 5d2eb548 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull vfs xattr cleanups from Al Viro.

* 'for-linus-3' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  f2fs: xattr simplifications
  squashfs: xattr simplifications
  9p: xattr simplifications
  xattr handlers: Pass handler to operations instead of flags
  jffs2: Add missing capability check for listing trusted xattrs
  hfsplus: Remove unused xattr handler list operations
  ubifs: Remove unused security xattr handler
  vfs: Fix the posix_acl_xattr_list return value
  vfs: Check attribute names in posix acl xattr handers
parents 2870f6c4 29608d20
Loading
Loading
Loading
Loading
+1 −4
Original line number Original line Diff line number Diff line
@@ -10,10 +10,7 @@ obj-$(CONFIG_9P_FS) := 9p.o
	vfs_dentry.o \
	vfs_dentry.o \
	v9fs.o \
	v9fs.o \
	fid.o  \
	fid.o  \
	xattr.o \
	xattr.o
	xattr_user.o \
	xattr_trusted.o


9p-$(CONFIG_9P_FSCACHE) += cache.o
9p-$(CONFIG_9P_FSCACHE) += cache.o
9p-$(CONFIG_9P_FS_POSIX_ACL) += acl.o
9p-$(CONFIG_9P_FS_POSIX_ACL) += acl.o
9p-$(CONFIG_9P_FS_SECURITY) += xattr_security.o
+13 −52
Original line number Original line Diff line number Diff line
@@ -212,26 +212,9 @@ int v9fs_acl_mode(struct inode *dir, umode_t *modep,
	return 0;
	return 0;
}
}


static int v9fs_remote_get_acl(struct dentry *dentry, const char *name,
static int v9fs_xattr_get_acl(const struct xattr_handler *handler,
			       void *buffer, size_t size, int type)
			      struct dentry *dentry, const char *name,
{
			      void *buffer, size_t size)
	char *full_name;

	switch (type) {
	case ACL_TYPE_ACCESS:
		full_name =  POSIX_ACL_XATTR_ACCESS;
		break;
	case ACL_TYPE_DEFAULT:
		full_name = POSIX_ACL_XATTR_DEFAULT;
		break;
	default:
		BUG();
	}
	return v9fs_xattr_get(dentry, full_name, buffer, size);
}

static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name,
			      void *buffer, size_t size, int type)
{
{
	struct v9fs_session_info *v9ses;
	struct v9fs_session_info *v9ses;
	struct posix_acl *acl;
	struct posix_acl *acl;
@@ -245,9 +228,9 @@ static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name,
	 * We allow set/get/list of acl when access=client is not specified
	 * We allow set/get/list of acl when access=client is not specified
	 */
	 */
	if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
	if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
		return v9fs_remote_get_acl(dentry, name, buffer, size, type);
		return v9fs_xattr_get(dentry, handler->prefix, buffer, size);


	acl = v9fs_get_cached_acl(d_inode(dentry), type);
	acl = v9fs_get_cached_acl(d_inode(dentry), handler->flags);
	if (IS_ERR(acl))
	if (IS_ERR(acl))
		return PTR_ERR(acl);
		return PTR_ERR(acl);
	if (acl == NULL)
	if (acl == NULL)
@@ -258,29 +241,9 @@ static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name,
	return error;
	return error;
}
}


static int v9fs_remote_set_acl(struct dentry *dentry, const char *name,
static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
			      const void *value, size_t size,
			      struct dentry *dentry, const char *name,
			      int flags, int type)
			      const void *value, size_t size, int flags)
{
	char *full_name;

	switch (type) {
	case ACL_TYPE_ACCESS:
		full_name =  POSIX_ACL_XATTR_ACCESS;
		break;
	case ACL_TYPE_DEFAULT:
		full_name = POSIX_ACL_XATTR_DEFAULT;
		break;
	default:
		BUG();
	}
	return v9fs_xattr_set(dentry, full_name, value, size, flags);
}


static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
			      const void *value, size_t size,
			      int flags, int type)
{
{
	int retval;
	int retval;
	struct posix_acl *acl;
	struct posix_acl *acl;
@@ -296,8 +259,8 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
	 * xattr value. We leave it to the server to validate
	 * xattr value. We leave it to the server to validate
	 */
	 */
	if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
	if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
		return v9fs_remote_set_acl(dentry, name,
		return v9fs_xattr_set(dentry, handler->prefix, value, size,
					   value, size, flags, type);
				      flags);


	if (S_ISLNK(inode->i_mode))
	if (S_ISLNK(inode->i_mode))
		return -EOPNOTSUPP;
		return -EOPNOTSUPP;
@@ -316,9 +279,8 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
	} else
	} else
		acl = NULL;
		acl = NULL;


	switch (type) {
	switch (handler->flags) {
	case ACL_TYPE_ACCESS:
	case ACL_TYPE_ACCESS:
		name = POSIX_ACL_XATTR_ACCESS;
		if (acl) {
		if (acl) {
			umode_t mode = inode->i_mode;
			umode_t mode = inode->i_mode;
			retval = posix_acl_equiv_mode(acl, &mode);
			retval = posix_acl_equiv_mode(acl, &mode);
@@ -349,7 +311,6 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
		}
		}
		break;
		break;
	case ACL_TYPE_DEFAULT:
	case ACL_TYPE_DEFAULT:
		name = POSIX_ACL_XATTR_DEFAULT;
		if (!S_ISDIR(inode->i_mode)) {
		if (!S_ISDIR(inode->i_mode)) {
			retval = acl ? -EINVAL : 0;
			retval = acl ? -EINVAL : 0;
			goto err_out;
			goto err_out;
@@ -358,9 +319,9 @@ static int v9fs_xattr_set_acl(struct dentry *dentry, const char *name,
	default:
	default:
		BUG();
		BUG();
	}
	}
	retval = v9fs_xattr_set(dentry, name, value, size, flags);
	retval = v9fs_xattr_set(dentry, handler->prefix, value, size, flags);
	if (!retval)
	if (!retval)
		set_cached_acl(inode, type, acl);
		set_cached_acl(inode, handler->flags, acl);
err_out:
err_out:
	posix_acl_release(acl);
	posix_acl_release(acl);
	return retval;
	return retval;
+42 −0
Original line number Original line Diff line number Diff line
@@ -137,6 +137,48 @@ ssize_t v9fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
	return v9fs_xattr_get(dentry, NULL, buffer, buffer_size);
	return v9fs_xattr_get(dentry, NULL, buffer, buffer_size);
}
}


static int v9fs_xattr_handler_get(const struct xattr_handler *handler,
				  struct dentry *dentry, const char *name,
				  void *buffer, size_t size)
{
	const char *full_name = xattr_full_name(handler, name);

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

static int v9fs_xattr_handler_set(const struct xattr_handler *handler,
				  struct dentry *dentry, const char *name,
				  const void *value, size_t size, int flags)
{
	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);
}

static struct xattr_handler v9fs_xattr_user_handler = {
	.prefix	= XATTR_USER_PREFIX,
	.get	= v9fs_xattr_handler_get,
	.set	= v9fs_xattr_handler_set,
};

static struct xattr_handler v9fs_xattr_trusted_handler = {
	.prefix	= XATTR_TRUSTED_PREFIX,
	.get	= v9fs_xattr_handler_get,
	.set	= v9fs_xattr_handler_set,
};

#ifdef CONFIG_9P_FS_SECURITY
static struct xattr_handler v9fs_xattr_security_handler = {
	.prefix	= XATTR_SECURITY_PREFIX,
	.get	= v9fs_xattr_handler_get,
	.set	= v9fs_xattr_handler_set,
};
#endif

const struct xattr_handler *v9fs_xattr_handlers[] = {
const struct xattr_handler *v9fs_xattr_handlers[] = {
	&v9fs_xattr_user_handler,
	&v9fs_xattr_user_handler,
	&v9fs_xattr_trusted_handler,
	&v9fs_xattr_trusted_handler,
+0 −3
Original line number Original line Diff line number Diff line
@@ -19,9 +19,6 @@
#include <net/9p/client.h>
#include <net/9p/client.h>


extern const struct xattr_handler *v9fs_xattr_handlers[];
extern const struct xattr_handler *v9fs_xattr_handlers[];
extern struct xattr_handler v9fs_xattr_user_handler;
extern struct xattr_handler v9fs_xattr_trusted_handler;
extern struct xattr_handler v9fs_xattr_security_handler;
extern const struct xattr_handler v9fs_xattr_acl_access_handler;
extern const struct xattr_handler v9fs_xattr_acl_access_handler;
extern const struct xattr_handler v9fs_xattr_acl_default_handler;
extern const struct xattr_handler v9fs_xattr_acl_default_handler;


fs/9p/xattr_security.c

deleted100644 → 0
+0 −80
Original line number Original line Diff line number Diff line
/*
 * Copyright IBM Corporation, 2010
 * Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2.1 of the GNU Lesser General Public License
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it would be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 */


#include <linux/module.h>
#include <linux/string.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include "xattr.h"

static int v9fs_xattr_security_get(struct dentry *dentry, const char *name,
			void *buffer, size_t size, int type)
{
	int retval;
	char *full_name;
	size_t name_len;
	size_t prefix_len = XATTR_SECURITY_PREFIX_LEN;

	if (name == NULL)
		return -EINVAL;

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

	name_len = strlen(name);
	full_name = kmalloc(prefix_len + name_len + 1 , GFP_KERNEL);
	if (!full_name)
		return -ENOMEM;
	memcpy(full_name, XATTR_SECURITY_PREFIX, prefix_len);
	memcpy(full_name+prefix_len, name, name_len);
	full_name[prefix_len + name_len] = '\0';

	retval = v9fs_xattr_get(dentry, full_name, buffer, size);
	kfree(full_name);
	return retval;
}

static int v9fs_xattr_security_set(struct dentry *dentry, const char *name,
			const void *value, size_t size, int flags, int type)
{
	int retval;
	char *full_name;
	size_t name_len;
	size_t prefix_len = XATTR_SECURITY_PREFIX_LEN;

	if (name == NULL)
		return -EINVAL;

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

	name_len = strlen(name);
	full_name = kmalloc(prefix_len + name_len + 1 , GFP_KERNEL);
	if (!full_name)
		return -ENOMEM;
	memcpy(full_name, XATTR_SECURITY_PREFIX, prefix_len);
	memcpy(full_name + prefix_len, name, name_len);
	full_name[prefix_len + name_len] = '\0';

	retval = v9fs_xattr_set(dentry, full_name, value, size, flags);
	kfree(full_name);
	return retval;
}

struct xattr_handler v9fs_xattr_security_handler = {
	.prefix	= XATTR_SECURITY_PREFIX,
	.get	= v9fs_xattr_security_get,
	.set	= v9fs_xattr_security_set,
};
Loading