Commit 65199af6 authored by James Morris's avatar James Morris Committed by Linus Torvalds

[PATCH] xattr consolidation v3 - LSM

This patch replaces the dentry parameter with an inode in the LSM
inode_{set|get|list}security hooks, in keeping with the ext2/ext3 code. 
dentries are not needed here.
Signed-off-by: default avatarJames Morris <jmorris@redhat.com>
Signed-off-by: default avatarStephen Smalley <sds@epoch.ncsc.mil>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent dbcd7a5f
...@@ -396,13 +396,13 @@ struct swap_info_struct; ...@@ -396,13 +396,13 @@ struct swap_info_struct;
* Return 0 if permission is granted. * Return 0 if permission is granted.
* @inode_getsecurity: * @inode_getsecurity:
* Copy the extended attribute representation of the security label * Copy the extended attribute representation of the security label
* associated with @name for @dentry into @buffer. @buffer may be * associated with @name for @inode into @buffer. @buffer may be
* NULL to request the size of the buffer required. @size indicates * NULL to request the size of the buffer required. @size indicates
* the size of @buffer in bytes. Note that @name is the remainder * the size of @buffer in bytes. Note that @name is the remainder
* of the attribute name after the security. prefix has been removed. * of the attribute name after the security. prefix has been removed.
* Return number of bytes used/required on success. * Return number of bytes used/required on success.
* @inode_setsecurity: * @inode_setsecurity:
* Set the security label associated with @name for @dentry from the * Set the security label associated with @name for @inode from the
* extended attribute value @value. @size indicates the size of the * extended attribute value @value. @size indicates the size of the
* @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0. * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
* Note that @name is the remainder of the attribute name after the * Note that @name is the remainder of the attribute name after the
...@@ -410,8 +410,9 @@ struct swap_info_struct; ...@@ -410,8 +410,9 @@ struct swap_info_struct;
* Return 0 on success. * Return 0 on success.
* @inode_listsecurity: * @inode_listsecurity:
* Copy the extended attribute names for the security labels * Copy the extended attribute names for the security labels
* associated with @dentry into @buffer. @buffer may be NULL to * associated with @inode into @buffer. The maximum size of @buffer
* request the size of the buffer required. * is specified by @buffer_size. @buffer may be NULL to request
* the size of the buffer required.
* Returns number of bytes used/required on success. * Returns number of bytes used/required on success.
* *
* Security hooks for file operations * Security hooks for file operations
...@@ -1109,9 +1110,9 @@ struct security_operations { ...@@ -1109,9 +1110,9 @@ struct security_operations {
int (*inode_getxattr) (struct dentry *dentry, char *name); int (*inode_getxattr) (struct dentry *dentry, char *name);
int (*inode_listxattr) (struct dentry *dentry); int (*inode_listxattr) (struct dentry *dentry);
int (*inode_removexattr) (struct dentry *dentry, char *name); int (*inode_removexattr) (struct dentry *dentry, char *name);
int (*inode_getsecurity)(struct dentry *dentry, const char *name, void *buffer, size_t size); int (*inode_getsecurity)(struct inode *inode, const char *name, void *buffer, size_t size);
int (*inode_setsecurity)(struct dentry *dentry, const char *name, const void *value, size_t size, int flags); int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
int (*inode_listsecurity)(struct dentry *dentry, char *buffer); int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
int (*file_permission) (struct file * file, int mask); int (*file_permission) (struct file * file, int mask);
int (*file_alloc_security) (struct file * file); int (*file_alloc_security) (struct file * file);
...@@ -1576,19 +1577,19 @@ static inline int security_inode_removexattr (struct dentry *dentry, char *name) ...@@ -1576,19 +1577,19 @@ static inline int security_inode_removexattr (struct dentry *dentry, char *name)
return security_ops->inode_removexattr (dentry, name); return security_ops->inode_removexattr (dentry, name);
} }
static inline int security_inode_getsecurity(struct dentry *dentry, const char *name, void *buffer, size_t size) static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size)
{ {
return security_ops->inode_getsecurity(dentry, name, buffer, size); return security_ops->inode_getsecurity(inode, name, buffer, size);
} }
static inline int security_inode_setsecurity(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
{ {
return security_ops->inode_setsecurity(dentry, name, value, size, flags); return security_ops->inode_setsecurity(inode, name, value, size, flags);
} }
static inline int security_inode_listsecurity(struct dentry *dentry, char *buffer) static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
{ {
return security_ops->inode_listsecurity(dentry, buffer); return security_ops->inode_listsecurity(inode, buffer, buffer_size);
} }
static inline int security_file_permission (struct file *file, int mask) static inline int security_file_permission (struct file *file, int mask)
...@@ -2215,17 +2216,17 @@ static inline int security_inode_removexattr (struct dentry *dentry, char *name) ...@@ -2215,17 +2216,17 @@ static inline int security_inode_removexattr (struct dentry *dentry, char *name)
return cap_inode_removexattr(dentry, name); return cap_inode_removexattr(dentry, name);
} }
static inline int security_inode_getsecurity(struct dentry *dentry, const char *name, void *buffer, size_t size) static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size)
{ {
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static inline int security_inode_setsecurity(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
{ {
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static inline int security_inode_listsecurity(struct dentry *dentry, char *buffer) static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
{ {
return 0; return 0;
} }
......
...@@ -447,17 +447,17 @@ static int dummy_inode_removexattr (struct dentry *dentry, char *name) ...@@ -447,17 +447,17 @@ static int dummy_inode_removexattr (struct dentry *dentry, char *name)
return 0; return 0;
} }
static int dummy_inode_getsecurity(struct dentry *dentry, const char *name, void *buffer, size_t size) static int dummy_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size)
{ {
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static int dummy_inode_setsecurity(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) static int dummy_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
{ {
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static int dummy_inode_listsecurity(struct dentry *dentry, char *buffer) static int dummy_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
{ {
return 0; return 0;
} }
......
...@@ -2332,9 +2332,8 @@ static int selinux_inode_removexattr (struct dentry *dentry, char *name) ...@@ -2332,9 +2332,8 @@ static int selinux_inode_removexattr (struct dentry *dentry, char *name)
return -EACCES; return -EACCES;
} }
static int selinux_inode_getsecurity(struct dentry *dentry, const char *name, void *buffer, size_t size) static int selinux_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size)
{ {
struct inode *inode = dentry->d_inode;
struct inode_security_struct *isec = inode->i_security; struct inode_security_struct *isec = inode->i_security;
char *context; char *context;
unsigned len; unsigned len;
...@@ -2362,10 +2361,9 @@ static int selinux_inode_getsecurity(struct dentry *dentry, const char *name, vo ...@@ -2362,10 +2361,9 @@ static int selinux_inode_getsecurity(struct dentry *dentry, const char *name, vo
return len; return len;
} }
static int selinux_inode_setsecurity(struct dentry *dentry, const char *name, static int selinux_inode_setsecurity(struct inode *inode, const char *name,
const void *value, size_t size, int flags) const void *value, size_t size, int flags)
{ {
struct inode *inode = dentry->d_inode;
struct inode_security_struct *isec = inode->i_security; struct inode_security_struct *isec = inode->i_security;
u32 newsid; u32 newsid;
int rc; int rc;
...@@ -2384,10 +2382,10 @@ static int selinux_inode_setsecurity(struct dentry *dentry, const char *name, ...@@ -2384,10 +2382,10 @@ static int selinux_inode_setsecurity(struct dentry *dentry, const char *name,
return 0; return 0;
} }
static int selinux_inode_listsecurity(struct dentry *dentry, char *buffer) static int selinux_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
{ {
const int len = sizeof(XATTR_NAME_SELINUX); const int len = sizeof(XATTR_NAME_SELINUX);
if (buffer) if (buffer && len <= buffer_size)
memcpy(buffer, XATTR_NAME_SELINUX, len); memcpy(buffer, XATTR_NAME_SELINUX, len);
return len; return len;
} }
......
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