]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - security/landlock/cred.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Landlock LSM - Credential hooks
5 * Copyright © 2019-2020 Mickaël Salaün <mic@digikod.net>
6 * Copyright © 2019-2020 ANSSI
9 #ifndef _SECURITY_LANDLOCK_CRED_H
10 #define _SECURITY_LANDLOCK_CRED_H
12 #include <linux/cred.h>
13 #include <linux/init.h>
14 #include <linux/rcupdate.h>
19 struct landlock_cred_security
{
20 struct landlock_ruleset
*domain
;
23 static inline struct landlock_cred_security
*landlock_cred(
24 const struct cred
*cred
)
26 return cred
->security
+ landlock_blob_sizes
.lbs_cred
;
29 static inline const struct landlock_ruleset
*landlock_get_current_domain(void)
31 return landlock_cred(current_cred())->domain
;
35 * The call needs to come from an RCU read-side critical section.
37 static inline const struct landlock_ruleset
*landlock_get_task_domain(
38 const struct task_struct
*const task
)
40 return landlock_cred(__task_cred(task
))->domain
;
43 static inline bool landlocked(const struct task_struct
*const task
)
48 return !!landlock_get_current_domain();
51 has_dom
= !!landlock_get_task_domain(task
);
56 __init
void landlock_add_cred_hooks(void);
58 #endif /* _SECURITY_LANDLOCK_CRED_H */