aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorJames Morris <jmorris@namei.org>2005-10-30 17:59:22 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-30 20:37:11 -0500
commitd381d8a9a08cac9824096213069159be17fd2e2f (patch)
tree0c19722b8f67c29b7c08c6ab8776a9c146395d03 /include/linux
parent89d155ef62e5e0c10e4b37aaa5056f0beafe10e6 (diff)
[PATCH] SELinux: canonicalize getxattr()
This patch allows SELinux to canonicalize the value returned from getxattr() via the security_inode_getsecurity() hook, which is called after the fs level getxattr() function. The purpose of this is to allow the in-core security context for an inode to override the on-disk value. This could happen in cases such as upgrading a system to a different labeling form (e.g. standard SELinux to MLS) without needing to do a full relabel of the filesystem. In such cases, we want getxattr() to return the canonical security context that the kernel is using rather than what is stored on disk. The implementation hooks into the inode_getsecurity(), adding another parameter to indicate the result of the preceding fs-level getxattr() call, so that SELinux knows whether to compare a value obtained from disk with the kernel value. We also now allow getxattr() to work for mountpoint labeled filesystems (i.e. mount with option context=foo_t), as we are able to return the kernel value to the user. Signed-off-by: James Morris <jmorris@namei.org> Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/security.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/include/linux/security.h b/include/linux/security.h
index dac956ed98f0..607ee209ea3b 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -385,6 +385,9 @@ struct swap_info_struct;
385 * NULL to request the size of the buffer required. @size indicates 385 * NULL to request the size of the buffer required. @size indicates
386 * the size of @buffer in bytes. Note that @name is the remainder 386 * the size of @buffer in bytes. Note that @name is the remainder
387 * of the attribute name after the security. prefix has been removed. 387 * of the attribute name after the security. prefix has been removed.
388 * @err is the return value from the preceding fs getxattr call,
389 * and can be used by the security module to determine whether it
390 * should try and canonicalize the attribute value.
388 * Return number of bytes used/required on success. 391 * Return number of bytes used/required on success.
389 * @inode_setsecurity: 392 * @inode_setsecurity:
390 * Set the security label associated with @name for @inode from the 393 * Set the security label associated with @name for @inode from the
@@ -1091,7 +1094,7 @@ struct security_operations {
1091 int (*inode_getxattr) (struct dentry *dentry, char *name); 1094 int (*inode_getxattr) (struct dentry *dentry, char *name);
1092 int (*inode_listxattr) (struct dentry *dentry); 1095 int (*inode_listxattr) (struct dentry *dentry);
1093 int (*inode_removexattr) (struct dentry *dentry, char *name); 1096 int (*inode_removexattr) (struct dentry *dentry, char *name);
1094 int (*inode_getsecurity)(struct inode *inode, const char *name, void *buffer, size_t size); 1097 int (*inode_getsecurity)(struct inode *inode, const char *name, void *buffer, size_t size, int err);
1095 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags); 1098 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1096 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size); 1099 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1097 1100
@@ -1580,11 +1583,11 @@ static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1580 return security_ops->inode_removexattr (dentry, name); 1583 return security_ops->inode_removexattr (dentry, name);
1581} 1584}
1582 1585
1583static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size) 1586static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size, int err)
1584{ 1587{
1585 if (unlikely (IS_PRIVATE (inode))) 1588 if (unlikely (IS_PRIVATE (inode)))
1586 return 0; 1589 return 0;
1587 return security_ops->inode_getsecurity(inode, name, buffer, size); 1590 return security_ops->inode_getsecurity(inode, name, buffer, size, err);
1588} 1591}
1589 1592
1590static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags) 1593static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
@@ -2222,7 +2225,7 @@ static inline int security_inode_removexattr (struct dentry *dentry, char *name)
2222 return cap_inode_removexattr(dentry, name); 2225 return cap_inode_removexattr(dentry, name);
2223} 2226}
2224 2227
2225static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size) 2228static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size, int err)
2226{ 2229{
2227 return -EOPNOTSUPP; 2230 return -EOPNOTSUPP;
2228} 2231}