Commit 647c60b9 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] reiserfs: selinux support

From: Chris Mason <mason@suse.com>

From: jeffm@suse.com

reiserfs support for selinux
parent a4a4ddc5
...@@ -266,6 +266,18 @@ config REISERFS_FS_POSIX_ACL ...@@ -266,6 +266,18 @@ config REISERFS_FS_POSIX_ACL
If you don't know what Access Control Lists are, say N If you don't know what Access Control Lists are, say N
config REISERFS_FS_SECURITY
bool "ReiserFS Security Labels"
depends on REISERFS_FS_XATTR
help
Security labels support alternative access control models
implemented by security modules like SELinux. This option
enables an extended attribute handler for file security
labels in the ReiserFS filesystem.
If you are not using a security module that requires using
extended attributes for file security labels, say N.
config JFS_FS config JFS_FS
tristate "JFS filesystem support" tristate "JFS filesystem support"
select NLS select NLS
......
...@@ -13,6 +13,10 @@ ifeq ($(CONFIG_REISERFS_FS_XATTR),y) ...@@ -13,6 +13,10 @@ ifeq ($(CONFIG_REISERFS_FS_XATTR),y)
reiserfs-objs += xattr.o xattr_user.o xattr_trusted.o reiserfs-objs += xattr.o xattr_user.o xattr_trusted.o
endif endif
ifeq ($(CONFIG_REISERFS_FS_SECURITY),y)
reiserfs-objs += xattr_security.o
endif
ifeq ($(CONFIG_REISERFS_FS_POSIX_ACL),y) ifeq ($(CONFIG_REISERFS_FS_POSIX_ACL),y)
reiserfs-objs += xattr_acl.o reiserfs-objs += xattr_acl.o
endif endif
......
...@@ -1177,6 +1177,9 @@ reiserfs_xattr_register_handlers (void) ...@@ -1177,6 +1177,9 @@ reiserfs_xattr_register_handlers (void)
/* Add the handlers */ /* Add the handlers */
list_add_tail (&user_handler.handlers, &xattr_handlers); list_add_tail (&user_handler.handlers, &xattr_handlers);
list_add_tail (&trusted_handler.handlers, &xattr_handlers); list_add_tail (&trusted_handler.handlers, &xattr_handlers);
#ifdef CONFIG_REISERFS_FS_SECURITY
list_add_tail (&security_handler.handlers, &xattr_handlers);
#endif
#ifdef CONFIG_REISERFS_FS_POSIX_ACL #ifdef CONFIG_REISERFS_FS_POSIX_ACL
list_add_tail (&posix_acl_access_handler.handlers, &xattr_handlers); list_add_tail (&posix_acl_access_handler.handlers, &xattr_handlers);
list_add_tail (&posix_acl_default_handler.handlers, &xattr_handlers); list_add_tail (&posix_acl_default_handler.handlers, &xattr_handlers);
......
#include <linux/reiserfs_fs.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/pagemap.h>
#include <linux/xattr.h>
#include <linux/reiserfs_xattr.h>
#include <asm/uaccess.h>
#define XATTR_SECURITY_PREFIX "security."
static int
security_get (struct inode *inode, const char *name, void *buffer, size_t size)
{
if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
return -EINVAL;
if (is_reiserfs_priv_object(inode))
return -EPERM;
return reiserfs_xattr_get (inode, name, buffer, size);
}
static int
security_set (struct inode *inode, const char *name, const void *buffer,
size_t size, int flags)
{
if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
return -EINVAL;
if (is_reiserfs_priv_object(inode))
return -EPERM;
return reiserfs_xattr_set (inode, name, buffer, size, flags);
}
static int
security_del (struct inode *inode, const char *name)
{
if (strlen(name) < sizeof(XATTR_SECURITY_PREFIX))
return -EINVAL;
if (is_reiserfs_priv_object(inode))
return -EPERM;
return 0;
}
static int
security_list (struct inode *inode, const char *name, int namelen, char *out)
{
int len = namelen;
if (is_reiserfs_priv_object(inode))
return 0;
if (out)
memcpy (out, name, len);
return len;
}
struct reiserfs_xattr_handler security_handler = {
prefix: XATTR_SECURITY_PREFIX,
get: security_get,
set: security_set,
del: security_del,
list: security_list,
};
...@@ -51,6 +51,9 @@ int reiserfs_xattr_set (struct inode *, const char *, const void *, ...@@ -51,6 +51,9 @@ int reiserfs_xattr_set (struct inode *, const char *, const void *,
extern struct reiserfs_xattr_handler user_handler; extern struct reiserfs_xattr_handler user_handler;
extern struct reiserfs_xattr_handler trusted_handler; extern struct reiserfs_xattr_handler trusted_handler;
#ifdef CONFIG_REISERFS_FS_SECURITY
extern struct reiserfs_xattr_handler security_handler;
#endif
int reiserfs_xattr_register_handlers (void) __init; int reiserfs_xattr_register_handlers (void) __init;
void reiserfs_xattr_unregister_handlers (void); void reiserfs_xattr_unregister_handlers (void);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment