aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/lsm_hooks.h
diff options
context:
space:
mode:
authorOndrej Mosnacek <omosnace@redhat.com>2019-02-22 09:57:16 -0500
committerPaul Moore <paul@paul-moore.com>2019-03-20 22:01:02 -0400
commitb230d5aba2d1a7b0636408889a75bf9eae6b8bc7 (patch)
tree57bacbcb8d8114c376cef0d23110a236af5e985a /include/linux/lsm_hooks.h
parent0ac6075a32fc05bc7fa025965914e8dcd448a668 (diff)
LSM: add new hook for kernfs node initialization
This patch introduces a new security hook that is intended for initializing the security data for newly created kernfs nodes, which provide a way of storing a non-default security context, but need to operate independently from mounts (and therefore may not have an associated inode at the moment of creation). The main motivation is to allow kernfs nodes to inherit the context of the parent under SELinux, similar to the behavior of security_inode_init_security(). Other LSMs may implement their own logic for handling the creation of new nodes. This patch also adds helper functions to <linux/kernfs.h> for getting/setting security xattrs of a kernfs node so that LSMs hooks are able to do their job. Other important attributes should be accessible direcly in the kernfs_node fields (in case there is need for more, then new helpers should be added to kernfs.h along with the patch that needs them). Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> Acked-by: Casey Schaufler <casey@schaufler-ca.com> [PM: more manual merge fixes] Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'include/linux/lsm_hooks.h')
-rw-r--r--include/linux/lsm_hooks.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
index a9b8ff578b6b..0dd5bda719e6 100644
--- a/include/linux/lsm_hooks.h
+++ b/include/linux/lsm_hooks.h
@@ -445,6 +445,15 @@
445 * to abort the copy up. Note that the caller is responsible for reading 445 * to abort the copy up. Note that the caller is responsible for reading
446 * and writing the xattrs as this hook is merely a filter. 446 * and writing the xattrs as this hook is merely a filter.
447 * 447 *
448 * Security hooks for kernfs node operations
449 *
450 * @kernfs_init_security
451 * Initialize the security context of a newly created kernfs node based
452 * on its own and its parent's attributes.
453 *
454 * @kn_dir the parent kernfs node
455 * @kn the new child kernfs node
456 *
448 * Security hooks for file operations 457 * Security hooks for file operations
449 * 458 *
450 * @file_permission: 459 * @file_permission:
@@ -1578,6 +1587,9 @@ union security_list_options {
1578 int (*inode_copy_up)(struct dentry *src, struct cred **new); 1587 int (*inode_copy_up)(struct dentry *src, struct cred **new);
1579 int (*inode_copy_up_xattr)(const char *name); 1588 int (*inode_copy_up_xattr)(const char *name);
1580 1589
1590 int (*kernfs_init_security)(struct kernfs_node *kn_dir,
1591 struct kernfs_node *kn);
1592
1581 int (*file_permission)(struct file *file, int mask); 1593 int (*file_permission)(struct file *file, int mask);
1582 int (*file_alloc_security)(struct file *file); 1594 int (*file_alloc_security)(struct file *file);
1583 void (*file_free_security)(struct file *file); 1595 void (*file_free_security)(struct file *file);
@@ -1879,6 +1891,7 @@ struct security_hook_heads {
1879 struct hlist_head inode_getsecid; 1891 struct hlist_head inode_getsecid;
1880 struct hlist_head inode_copy_up; 1892 struct hlist_head inode_copy_up;
1881 struct hlist_head inode_copy_up_xattr; 1893 struct hlist_head inode_copy_up_xattr;
1894 struct hlist_head kernfs_init_security;
1882 struct hlist_head file_permission; 1895 struct hlist_head file_permission;
1883 struct hlist_head file_alloc_security; 1896 struct hlist_head file_alloc_security;
1884 struct hlist_head file_free_security; 1897 struct hlist_head file_free_security;