xref: /linux/tools/testing/selftests/lsm/common.h (revision 4b132aacb0768ac1e652cf517097ea6f237214b9)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Linux Security Module infrastructure tests
4  *
5  * Copyright © 2023 Casey Schaufler <casey@schaufler-ca.com>
6  */
7 
8 #ifndef lsm_get_self_attr
9 static inline int lsm_get_self_attr(unsigned int attr, struct lsm_ctx *ctx,
10 				    __u32 *size, __u32 flags)
11 {
12 	return syscall(__NR_lsm_get_self_attr, attr, ctx, size, flags);
13 }
14 #endif
15 
16 #ifndef lsm_set_self_attr
17 static inline int lsm_set_self_attr(unsigned int attr, struct lsm_ctx *ctx,
18 				    __u32 size, __u32 flags)
19 {
20 	return syscall(__NR_lsm_set_self_attr, attr, ctx, size, flags);
21 }
22 #endif
23 
24 #ifndef lsm_list_modules
25 static inline int lsm_list_modules(__u64 *ids, __u32 *size, __u32 flags)
26 {
27 	return syscall(__NR_lsm_list_modules, ids, size, flags);
28 }
29 #endif
30 
31 extern int read_proc_attr(const char *attr, char *value, size_t size);
32 extern int read_sysfs_lsms(char *lsms, size_t size);
33 int attr_lsm_count(void);
34