CRED: Allow kernel services to override LSM settings for task actions
Allow kernel services to override LSM settings appropriate to the actions performed by a task by duplicating a set of credentials, modifying it and then using task_struct::cred to point to it when performing operations on behalf of a task. This is used, for example, by CacheFiles which has to transparently access the cache on behalf of a process that thinks it is doing, say, NFS accesses with a potentially inappropriate (with respect to accessing the cache) set of credentials. This patch provides two LSM hooks for modifying a task security record: (*) security_kernel_act_as() which allows modification of the security datum with which a task acts on other objects (most notably files). (*) security_kernel_create_files_as() which allows modification of the security datum that is used to initialise the security data on a file that a task creates. The patch also provides four new credentials handling functions, which wrap the LSM functions: (1) prepare_kernel_cred() Prepare a set of credentials for a kernel service to use, based either on a daemon's credentials or on init_cred. All the keyrings are cleared. (2) set_security_override() Set the LSM security ID in a set of credentials to a specific security context, assuming permission from the LSM policy. (3) set_security_override_from_ctx() As (2), but takes the security context as a string. (4) set_create_files_as() Set the file creation LSM security ID in a set of credentials to be the same as that on a particular inode. Signed-off-by: Casey Schaufler <casey@schaufler-ca.com> [Smack changes] Signed-off-by:David Howells <dhowells@redhat.com> Signed-off-by:
James Morris <jmorris@namei.org>
Showing
- include/linux/cred.h 6 additions, 0 deletionsinclude/linux/cred.h
- include/linux/security.h 28 additions, 0 deletionsinclude/linux/security.h
- kernel/cred.c 113 additions, 0 deletionskernel/cred.c
- security/capability.c 12 additions, 0 deletionssecurity/capability.c
- security/security.c 10 additions, 0 deletionssecurity/security.c
- security/selinux/hooks.c 46 additions, 0 deletionssecurity/selinux/hooks.c
- security/smack/smack_lsm.c 37 additions, 0 deletionssecurity/smack/smack_lsm.c
Loading
Please register or sign in to comment