]> git.baikalelectronics.ru Git - kernel.git/commit
LSM: add new hook for kernfs node initialization
authorOndrej Mosnacek <omosnace@redhat.com>
Fri, 22 Feb 2019 14:57:16 +0000 (15:57 +0100)
committerPaul Moore <paul@paul-moore.com>
Thu, 21 Mar 2019 02:01:02 +0000 (22:01 -0400)
commitf10163f7302c4d987539db8a074fccc0aaf26f50
tree57bacbcb8d8114c376cef0d23110a236af5e985a
parentbeb3620701c2eafeec5a9397779aacc64da6776f
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>
fs/kernfs/inode.c
include/linux/kernfs.h
include/linux/lsm_hooks.h
include/linux/security.h
security/security.c