34
34
#include <linux/sockptr.h>
35
35
#include <linux/bpf.h>
36
36
#include <uapi/linux/lsm.h>
37
+ #include <linux/lsm/selinux.h>
38
+ #include <linux/lsm/smack.h>
39
+ #include <linux/lsm/apparmor.h>
40
+ #include <linux/lsm/bpf.h>
37
41
38
42
struct linux_binprm ;
39
43
struct cred ;
@@ -152,6 +156,16 @@ enum lockdown_reason {
152
156
LOCKDOWN_CONFIDENTIALITY_MAX ,
153
157
};
154
158
159
+ /*
160
+ * Data exported by the security modules
161
+ */
162
+ struct lsm_prop {
163
+ struct lsm_prop_selinux selinux ;
164
+ struct lsm_prop_smack smack ;
165
+ struct lsm_prop_apparmor apparmor ;
166
+ struct lsm_prop_bpf bpf ;
167
+ };
168
+
155
169
extern const char * const lockdown_reasons [LOCKDOWN_CONFIDENTIALITY_MAX + 1 ];
156
170
extern u32 lsm_active_cnt ;
157
171
extern const struct lsm_id * lsm_idlist [];
@@ -269,8 +283,32 @@ static inline const char *kernel_load_data_id_str(enum kernel_load_data_id id)
269
283
return kernel_load_data_str [id ];
270
284
}
271
285
286
+ /**
287
+ * lsmprop_init - initialize a lsm_prop structure
288
+ * @prop: Pointer to the data to initialize
289
+ *
290
+ * Set all secid for all modules to the specified value.
291
+ */
292
+ static inline void lsmprop_init (struct lsm_prop * prop )
293
+ {
294
+ memset (prop , 0 , sizeof (* prop ));
295
+ }
296
+
272
297
#ifdef CONFIG_SECURITY
273
298
299
+ /**
300
+ * lsmprop_is_set - report if there is a value in the lsm_prop
301
+ * @prop: Pointer to the exported LSM data
302
+ *
303
+ * Returns true if there is a value set, false otherwise
304
+ */
305
+ static inline bool lsmprop_is_set (struct lsm_prop * prop )
306
+ {
307
+ const struct lsm_prop empty = {};
308
+
309
+ return !!memcmp (prop , & empty , sizeof (* prop ));
310
+ }
311
+
274
312
int call_blocking_lsm_notifier (enum lsm_event event , void * data );
275
313
int register_blocking_lsm_notifier (struct notifier_block * nb );
276
314
int unregister_blocking_lsm_notifier (struct notifier_block * nb );
@@ -408,7 +446,7 @@ int security_inode_getsecurity(struct mnt_idmap *idmap,
408
446
void * * buffer , bool alloc );
409
447
int security_inode_setsecurity (struct inode * inode , const char * name , const void * value , size_t size , int flags );
410
448
int security_inode_listsecurity (struct inode * inode , char * buffer , size_t buffer_size );
411
- void security_inode_getsecid (struct inode * inode , u32 * secid );
449
+ void security_inode_getlsmprop (struct inode * inode , struct lsm_prop * prop );
412
450
int security_inode_copy_up (struct dentry * src , struct cred * * new );
413
451
int security_inode_copy_up_xattr (struct dentry * src , const char * name );
414
452
int security_inode_setintegrity (const struct inode * inode ,
@@ -444,6 +482,7 @@ void security_cred_free(struct cred *cred);
444
482
int security_prepare_creds (struct cred * new , const struct cred * old , gfp_t gfp );
445
483
void security_transfer_creds (struct cred * new , const struct cred * old );
446
484
void security_cred_getsecid (const struct cred * c , u32 * secid );
485
+ void security_cred_getlsmprop (const struct cred * c , struct lsm_prop * prop );
447
486
int security_kernel_act_as (struct cred * new , u32 secid );
448
487
int security_kernel_create_files_as (struct cred * new , struct inode * inode );
449
488
int security_kernel_module_request (char * kmod_name );
@@ -463,8 +502,8 @@ int security_task_fix_setgroups(struct cred *new, const struct cred *old);
463
502
int security_task_setpgid (struct task_struct * p , pid_t pgid );
464
503
int security_task_getpgid (struct task_struct * p );
465
504
int security_task_getsid (struct task_struct * p );
466
- void security_current_getsecid_subj ( u32 * secid );
467
- void security_task_getsecid_obj (struct task_struct * p , u32 * secid );
505
+ void security_current_getlsmprop_subj ( struct lsm_prop * prop );
506
+ void security_task_getlsmprop_obj (struct task_struct * p , struct lsm_prop * prop );
468
507
int security_task_setnice (struct task_struct * p , int nice );
469
508
int security_task_setioprio (struct task_struct * p , int ioprio );
470
509
int security_task_getioprio (struct task_struct * p );
@@ -482,7 +521,7 @@ int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
482
521
void security_task_to_inode (struct task_struct * p , struct inode * inode );
483
522
int security_create_user_ns (const struct cred * cred );
484
523
int security_ipc_permission (struct kern_ipc_perm * ipcp , short flag );
485
- void security_ipc_getsecid (struct kern_ipc_perm * ipcp , u32 * secid );
524
+ void security_ipc_getlsmprop (struct kern_ipc_perm * ipcp , struct lsm_prop * prop );
486
525
int security_msg_msg_alloc (struct msg_msg * msg );
487
526
void security_msg_msg_free (struct msg_msg * msg );
488
527
int security_msg_queue_alloc (struct kern_ipc_perm * msq );
@@ -515,6 +554,7 @@ int security_setprocattr(int lsmid, const char *name, void *value, size_t size);
515
554
int security_netlink_send (struct sock * sk , struct sk_buff * skb );
516
555
int security_ismaclabel (const char * name );
517
556
int security_secid_to_secctx (u32 secid , char * * secdata , u32 * seclen );
557
+ int security_lsmprop_to_secctx (struct lsm_prop * prop , char * * secdata , u32 * seclen );
518
558
int security_secctx_to_secid (const char * secdata , u32 seclen , u32 * secid );
519
559
void security_release_secctx (char * secdata , u32 seclen );
520
560
void security_inode_invalidate_secctx (struct inode * inode );
@@ -531,6 +571,17 @@ int security_bdev_setintegrity(struct block_device *bdev,
531
571
size_t size );
532
572
#else /* CONFIG_SECURITY */
533
573
574
+ /**
575
+ * lsmprop_is_set - report if there is a value in the lsm_prop
576
+ * @prop: Pointer to the exported LSM data
577
+ *
578
+ * Returns true if there is a value set, false otherwise
579
+ */
580
+ static inline bool lsmprop_is_set (struct lsm_prop * prop )
581
+ {
582
+ return false;
583
+ }
584
+
534
585
static inline int call_blocking_lsm_notifier (enum lsm_event event , void * data )
535
586
{
536
587
return 0 ;
@@ -1020,9 +1071,10 @@ static inline int security_inode_listsecurity(struct inode *inode, char *buffer,
1020
1071
return 0 ;
1021
1072
}
1022
1073
1023
- static inline void security_inode_getsecid (struct inode * inode , u32 * secid )
1074
+ static inline void security_inode_getlsmprop (struct inode * inode ,
1075
+ struct lsm_prop * prop )
1024
1076
{
1025
- * secid = 0 ;
1077
+ lsmprop_init ( prop ) ;
1026
1078
}
1027
1079
1028
1080
static inline int security_inode_copy_up (struct dentry * src , struct cred * * new )
@@ -1172,6 +1224,10 @@ static inline void security_cred_getsecid(const struct cred *c, u32 *secid)
1172
1224
* secid = 0 ;
1173
1225
}
1174
1226
1227
+ static inline void security_cred_getlsmprop (const struct cred * c ,
1228
+ struct lsm_prop * prop )
1229
+ { }
1230
+
1175
1231
static inline int security_kernel_act_as (struct cred * cred , u32 secid )
1176
1232
{
1177
1233
return 0 ;
@@ -1249,14 +1305,15 @@ static inline int security_task_getsid(struct task_struct *p)
1249
1305
return 0 ;
1250
1306
}
1251
1307
1252
- static inline void security_current_getsecid_subj ( u32 * secid )
1308
+ static inline void security_current_getlsmprop_subj ( struct lsm_prop * prop )
1253
1309
{
1254
- * secid = 0 ;
1310
+ lsmprop_init ( prop ) ;
1255
1311
}
1256
1312
1257
- static inline void security_task_getsecid_obj (struct task_struct * p , u32 * secid )
1313
+ static inline void security_task_getlsmprop_obj (struct task_struct * p ,
1314
+ struct lsm_prop * prop )
1258
1315
{
1259
- * secid = 0 ;
1316
+ lsmprop_init ( prop ) ;
1260
1317
}
1261
1318
1262
1319
static inline int security_task_setnice (struct task_struct * p , int nice )
@@ -1332,9 +1389,10 @@ static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
1332
1389
return 0 ;
1333
1390
}
1334
1391
1335
- static inline void security_ipc_getsecid (struct kern_ipc_perm * ipcp , u32 * secid )
1392
+ static inline void security_ipc_getlsmprop (struct kern_ipc_perm * ipcp ,
1393
+ struct lsm_prop * prop )
1336
1394
{
1337
- * secid = 0 ;
1395
+ lsmprop_init ( prop ) ;
1338
1396
}
1339
1397
1340
1398
static inline int security_msg_msg_alloc (struct msg_msg * msg )
@@ -1468,7 +1526,14 @@ static inline int security_ismaclabel(const char *name)
1468
1526
return 0 ;
1469
1527
}
1470
1528
1471
- static inline int security_secid_to_secctx (u32 secid , char * * secdata , u32 * seclen )
1529
+ static inline int security_secid_to_secctx (u32 secid , char * * secdata ,
1530
+ u32 * seclen )
1531
+ {
1532
+ return - EOPNOTSUPP ;
1533
+ }
1534
+
1535
+ static inline int security_lsmprop_to_secctx (struct lsm_prop * prop ,
1536
+ char * * secdata , u32 * seclen )
1472
1537
{
1473
1538
return - EOPNOTSUPP ;
1474
1539
}
@@ -2095,7 +2160,8 @@ static inline void security_key_post_create_or_update(struct key *keyring,
2095
2160
int security_audit_rule_init (u32 field , u32 op , char * rulestr , void * * lsmrule ,
2096
2161
gfp_t gfp );
2097
2162
int security_audit_rule_known (struct audit_krule * krule );
2098
- int security_audit_rule_match (u32 secid , u32 field , u32 op , void * lsmrule );
2163
+ int security_audit_rule_match (struct lsm_prop * prop , u32 field , u32 op ,
2164
+ void * lsmrule );
2099
2165
void security_audit_rule_free (void * lsmrule );
2100
2166
2101
2167
#else
@@ -2111,8 +2177,8 @@ static inline int security_audit_rule_known(struct audit_krule *krule)
2111
2177
return 0 ;
2112
2178
}
2113
2179
2114
- static inline int security_audit_rule_match (u32 secid , u32 field , u32 op ,
2115
- void * lsmrule )
2180
+ static inline int security_audit_rule_match (struct lsm_prop * prop , u32 field ,
2181
+ u32 op , void * lsmrule )
2116
2182
{
2117
2183
return 0 ;
2118
2184
}
0 commit comments