1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#ifndef __LINUX_SECURITY_H
23#define __LINUX_SECURITY_H
24
25#include <linux/fs.h>
26#include <linux/binfmts.h>
27#include <linux/signal.h>
28#include <linux/resource.h>
29#include <linux/sem.h>
30#include <linux/shm.h>
31#include <linux/msg.h>
32#include <linux/sched.h>
33#include <linux/key.h>
34#include <linux/xfrm.h>
35#include <net/flow.h>
36
37
38#define SECURITY_NAME_MAX 10
39
40struct ctl_table;
41struct audit_krule;
42
43
44
45
46
47extern int cap_capable(struct task_struct *tsk, int cap);
48extern int cap_settime(struct timespec *ts, struct timezone *tz);
49extern int cap_ptrace(struct task_struct *parent, struct task_struct *child);
50extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
51extern int cap_capset_check(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
52extern void cap_capset_set(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
53extern int cap_bprm_set_security(struct linux_binprm *bprm);
54extern void cap_bprm_apply_creds(struct linux_binprm *bprm, int unsafe);
55extern int cap_bprm_secureexec(struct linux_binprm *bprm);
56extern int cap_inode_setxattr(struct dentry *dentry, const char *name,
57 const void *value, size_t size, int flags);
58extern int cap_inode_removexattr(struct dentry *dentry, const char *name);
59extern int cap_inode_need_killpriv(struct dentry *dentry);
60extern int cap_inode_killpriv(struct dentry *dentry);
61extern int cap_task_post_setuid(uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
62extern void cap_task_reparent_to_init(struct task_struct *p);
63extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
64 unsigned long arg4, unsigned long arg5, long *rc_p);
65extern int cap_task_setscheduler(struct task_struct *p, int policy, struct sched_param *lp);
66extern int cap_task_setioprio(struct task_struct *p, int ioprio);
67extern int cap_task_setnice(struct task_struct *p, int nice);
68extern int cap_syslog(int type);
69extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
70
71struct msghdr;
72struct sk_buff;
73struct sock;
74struct sockaddr;
75struct socket;
76struct flowi;
77struct dst_entry;
78struct xfrm_selector;
79struct xfrm_policy;
80struct xfrm_state;
81struct xfrm_user_sec_ctx;
82
83extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
84extern int cap_netlink_recv(struct sk_buff *skb, int cap);
85
86extern unsigned long mmap_min_addr;
87
88
89
90
91#define LSM_SETID_ID 1
92
93
94#define LSM_SETID_RE 2
95
96
97#define LSM_SETID_RES 4
98
99
100#define LSM_SETID_FS 8
101
102
103struct nfsctl_arg;
104struct sched_param;
105struct swap_info_struct;
106struct request_sock;
107
108
109#define LSM_UNSAFE_SHARE 1
110#define LSM_UNSAFE_PTRACE 2
111#define LSM_UNSAFE_PTRACE_CAP 4
112
113#ifdef CONFIG_SECURITY
114
115struct security_mnt_opts {
116 char **mnt_opts;
117 int *mnt_opts_flags;
118 int num_mnt_opts;
119};
120
121static inline void security_init_mnt_opts(struct security_mnt_opts *opts)
122{
123 opts->mnt_opts = NULL;
124 opts->mnt_opts_flags = NULL;
125 opts->num_mnt_opts = 0;
126}
127
128static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
129{
130 int i;
131 if (opts->mnt_opts)
132 for (i = 0; i < opts->num_mnt_opts; i++)
133 kfree(opts->mnt_opts[i]);
134 kfree(opts->mnt_opts);
135 opts->mnt_opts = NULL;
136 kfree(opts->mnt_opts_flags);
137 opts->mnt_opts_flags = NULL;
138 opts->num_mnt_opts = 0;
139}
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295struct security_operations {
1296 char name[SECURITY_NAME_MAX + 1];
1297
1298 int (*ptrace) (struct task_struct *parent, struct task_struct *child);
1299 int (*capget) (struct task_struct *target,
1300 kernel_cap_t *effective,
1301 kernel_cap_t *inheritable, kernel_cap_t *permitted);
1302 int (*capset_check) (struct task_struct *target,
1303 kernel_cap_t *effective,
1304 kernel_cap_t *inheritable,
1305 kernel_cap_t *permitted);
1306 void (*capset_set) (struct task_struct *target,
1307 kernel_cap_t *effective,
1308 kernel_cap_t *inheritable,
1309 kernel_cap_t *permitted);
1310 int (*capable) (struct task_struct *tsk, int cap);
1311 int (*acct) (struct file *file);
1312 int (*sysctl) (struct ctl_table *table, int op);
1313 int (*quotactl) (int cmds, int type, int id, struct super_block *sb);
1314 int (*quota_on) (struct dentry *dentry);
1315 int (*syslog) (int type);
1316 int (*settime) (struct timespec *ts, struct timezone *tz);
1317 int (*vm_enough_memory) (struct mm_struct *mm, long pages);
1318
1319 int (*bprm_alloc_security) (struct linux_binprm *bprm);
1320 void (*bprm_free_security) (struct linux_binprm *bprm);
1321 void (*bprm_apply_creds) (struct linux_binprm *bprm, int unsafe);
1322 void (*bprm_post_apply_creds) (struct linux_binprm *bprm);
1323 int (*bprm_set_security) (struct linux_binprm *bprm);
1324 int (*bprm_check_security) (struct linux_binprm *bprm);
1325 int (*bprm_secureexec) (struct linux_binprm *bprm);
1326
1327 int (*sb_alloc_security) (struct super_block *sb);
1328 void (*sb_free_security) (struct super_block *sb);
1329 int (*sb_copy_data) (char *orig, char *copy);
1330 int (*sb_kern_mount) (struct super_block *sb, void *data);
1331 int (*sb_statfs) (struct dentry *dentry);
1332 int (*sb_mount) (char *dev_name, struct path *path,
1333 char *type, unsigned long flags, void *data);
1334 int (*sb_check_sb) (struct vfsmount *mnt, struct path *path);
1335 int (*sb_umount) (struct vfsmount *mnt, int flags);
1336 void (*sb_umount_close) (struct vfsmount *mnt);
1337 void (*sb_umount_busy) (struct vfsmount *mnt);
1338 void (*sb_post_remount) (struct vfsmount *mnt,
1339 unsigned long flags, void *data);
1340 void (*sb_post_addmount) (struct vfsmount *mnt,
1341 struct path *mountpoint);
1342 int (*sb_pivotroot) (struct path *old_path,
1343 struct path *new_path);
1344 void (*sb_post_pivotroot) (struct path *old_path,
1345 struct path *new_path);
1346 int (*sb_get_mnt_opts) (const struct super_block *sb,
1347 struct security_mnt_opts *opts);
1348 int (*sb_set_mnt_opts) (struct super_block *sb,
1349 struct security_mnt_opts *opts);
1350 void (*sb_clone_mnt_opts) (const struct super_block *oldsb,
1351 struct super_block *newsb);
1352 int (*sb_parse_opts_str) (char *options, struct security_mnt_opts *opts);
1353
1354 int (*inode_alloc_security) (struct inode *inode);
1355 void (*inode_free_security) (struct inode *inode);
1356 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1357 char **name, void **value, size_t *len);
1358 int (*inode_create) (struct inode *dir,
1359 struct dentry *dentry, int mode);
1360 int (*inode_link) (struct dentry *old_dentry,
1361 struct inode *dir, struct dentry *new_dentry);
1362 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1363 int (*inode_symlink) (struct inode *dir,
1364 struct dentry *dentry, const char *old_name);
1365 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
1366 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1367 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1368 int mode, dev_t dev);
1369 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1370 struct inode *new_dir, struct dentry *new_dentry);
1371 int (*inode_readlink) (struct dentry *dentry);
1372 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1373 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1374 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1375 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1376 void (*inode_delete) (struct inode *inode);
1377 int (*inode_setxattr) (struct dentry *dentry, const char *name,
1378 const void *value, size_t size, int flags);
1379 void (*inode_post_setxattr) (struct dentry *dentry, const char *name,
1380 const void *value, size_t size, int flags);
1381 int (*inode_getxattr) (struct dentry *dentry, const char *name);
1382 int (*inode_listxattr) (struct dentry *dentry);
1383 int (*inode_removexattr) (struct dentry *dentry, const char *name);
1384 int (*inode_need_killpriv) (struct dentry *dentry);
1385 int (*inode_killpriv) (struct dentry *dentry);
1386 int (*inode_getsecurity) (const struct inode *inode, const char *name, void **buffer, bool alloc);
1387 int (*inode_setsecurity) (struct inode *inode, const char *name, const void *value, size_t size, int flags);
1388 int (*inode_listsecurity) (struct inode *inode, char *buffer, size_t buffer_size);
1389 void (*inode_getsecid) (const struct inode *inode, u32 *secid);
1390
1391 int (*file_permission) (struct file *file, int mask);
1392 int (*file_alloc_security) (struct file *file);
1393 void (*file_free_security) (struct file *file);
1394 int (*file_ioctl) (struct file *file, unsigned int cmd,
1395 unsigned long arg);
1396 int (*file_mmap) (struct file *file,
1397 unsigned long reqprot, unsigned long prot,
1398 unsigned long flags, unsigned long addr,
1399 unsigned long addr_only);
1400 int (*file_mprotect) (struct vm_area_struct *vma,
1401 unsigned long reqprot,
1402 unsigned long prot);
1403 int (*file_lock) (struct file *file, unsigned int cmd);
1404 int (*file_fcntl) (struct file *file, unsigned int cmd,
1405 unsigned long arg);
1406 int (*file_set_fowner) (struct file *file);
1407 int (*file_send_sigiotask) (struct task_struct *tsk,
1408 struct fown_struct *fown, int sig);
1409 int (*file_receive) (struct file *file);
1410 int (*dentry_open) (struct file *file);
1411
1412 int (*task_create) (unsigned long clone_flags);
1413 int (*task_alloc_security) (struct task_struct *p);
1414 void (*task_free_security) (struct task_struct *p);
1415 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1416 int (*task_post_setuid) (uid_t old_ruid ,
1417 uid_t old_euid, uid_t old_suid, int flags);
1418 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1419 int (*task_setpgid) (struct task_struct *p, pid_t pgid);
1420 int (*task_getpgid) (struct task_struct *p);
1421 int (*task_getsid) (struct task_struct *p);
1422 void (*task_getsecid) (struct task_struct *p, u32 *secid);
1423 int (*task_setgroups) (struct group_info *group_info);
1424 int (*task_setnice) (struct task_struct *p, int nice);
1425 int (*task_setioprio) (struct task_struct *p, int ioprio);
1426 int (*task_getioprio) (struct task_struct *p);
1427 int (*task_setrlimit) (unsigned int resource, struct rlimit *new_rlim);
1428 int (*task_setscheduler) (struct task_struct *p, int policy,
1429 struct sched_param *lp);
1430 int (*task_getscheduler) (struct task_struct *p);
1431 int (*task_movememory) (struct task_struct *p);
1432 int (*task_kill) (struct task_struct *p,
1433 struct siginfo *info, int sig, u32 secid);
1434 int (*task_wait) (struct task_struct *p);
1435 int (*task_prctl) (int option, unsigned long arg2,
1436 unsigned long arg3, unsigned long arg4,
1437 unsigned long arg5, long *rc_p);
1438 void (*task_reparent_to_init) (struct task_struct *p);
1439 void (*task_to_inode) (struct task_struct *p, struct inode *inode);
1440
1441 int (*ipc_permission) (struct kern_ipc_perm *ipcp, short flag);
1442 void (*ipc_getsecid) (struct kern_ipc_perm *ipcp, u32 *secid);
1443
1444 int (*msg_msg_alloc_security) (struct msg_msg *msg);
1445 void (*msg_msg_free_security) (struct msg_msg *msg);
1446
1447 int (*msg_queue_alloc_security) (struct msg_queue *msq);
1448 void (*msg_queue_free_security) (struct msg_queue *msq);
1449 int (*msg_queue_associate) (struct msg_queue *msq, int msqflg);
1450 int (*msg_queue_msgctl) (struct msg_queue *msq, int cmd);
1451 int (*msg_queue_msgsnd) (struct msg_queue *msq,
1452 struct msg_msg *msg, int msqflg);
1453 int (*msg_queue_msgrcv) (struct msg_queue *msq,
1454 struct msg_msg *msg,
1455 struct task_struct *target,
1456 long type, int mode);
1457
1458 int (*shm_alloc_security) (struct shmid_kernel *shp);
1459 void (*shm_free_security) (struct shmid_kernel *shp);
1460 int (*shm_associate) (struct shmid_kernel *shp, int shmflg);
1461 int (*shm_shmctl) (struct shmid_kernel *shp, int cmd);
1462 int (*shm_shmat) (struct shmid_kernel *shp,
1463 char __user *shmaddr, int shmflg);
1464
1465 int (*sem_alloc_security) (struct sem_array *sma);
1466 void (*sem_free_security) (struct sem_array *sma);
1467 int (*sem_associate) (struct sem_array *sma, int semflg);
1468 int (*sem_semctl) (struct sem_array *sma, int cmd);
1469 int (*sem_semop) (struct sem_array *sma,
1470 struct sembuf *sops, unsigned nsops, int alter);
1471
1472 int (*netlink_send) (struct sock *sk, struct sk_buff *skb);
1473 int (*netlink_recv) (struct sk_buff *skb, int cap);
1474
1475
1476 int (*register_security) (const char *name,
1477 struct security_operations *ops);
1478
1479 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1480
1481 int (*getprocattr) (struct task_struct *p, char *name, char **value);
1482 int (*setprocattr) (struct task_struct *p, char *name, void *value, size_t size);
1483 int (*secid_to_secctx) (u32 secid, char **secdata, u32 *seclen);
1484 int (*secctx_to_secid) (const char *secdata, u32 seclen, u32 *secid);
1485 void (*release_secctx) (char *secdata, u32 seclen);
1486
1487#ifdef CONFIG_SECURITY_NETWORK
1488 int (*unix_stream_connect) (struct socket *sock,
1489 struct socket *other, struct sock *newsk);
1490 int (*unix_may_send) (struct socket *sock, struct socket *other);
1491
1492 int (*socket_create) (int family, int type, int protocol, int kern);
1493 int (*socket_post_create) (struct socket *sock, int family,
1494 int type, int protocol, int kern);
1495 int (*socket_bind) (struct socket *sock,
1496 struct sockaddr *address, int addrlen);
1497 int (*socket_connect) (struct socket *sock,
1498 struct sockaddr *address, int addrlen);
1499 int (*socket_listen) (struct socket *sock, int backlog);
1500 int (*socket_accept) (struct socket *sock, struct socket *newsock);
1501 void (*socket_post_accept) (struct socket *sock,
1502 struct socket *newsock);
1503 int (*socket_sendmsg) (struct socket *sock,
1504 struct msghdr *msg, int size);
1505 int (*socket_recvmsg) (struct socket *sock,
1506 struct msghdr *msg, int size, int flags);
1507 int (*socket_getsockname) (struct socket *sock);
1508 int (*socket_getpeername) (struct socket *sock);
1509 int (*socket_getsockopt) (struct socket *sock, int level, int optname);
1510 int (*socket_setsockopt) (struct socket *sock, int level, int optname);
1511 int (*socket_shutdown) (struct socket *sock, int how);
1512 int (*socket_sock_rcv_skb) (struct sock *sk, struct sk_buff *skb);
1513 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1514 int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
1515 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
1516 void (*sk_free_security) (struct sock *sk);
1517 void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
1518 void (*sk_getsecid) (struct sock *sk, u32 *secid);
1519 void (*sock_graft) (struct sock *sk, struct socket *parent);
1520 int (*inet_conn_request) (struct sock *sk, struct sk_buff *skb,
1521 struct request_sock *req);
1522 void (*inet_csk_clone) (struct sock *newsk, const struct request_sock *req);
1523 void (*inet_conn_established) (struct sock *sk, struct sk_buff *skb);
1524 void (*req_classify_flow) (const struct request_sock *req, struct flowi *fl);
1525#endif
1526
1527#ifdef CONFIG_SECURITY_NETWORK_XFRM
1528 int (*xfrm_policy_alloc_security) (struct xfrm_sec_ctx **ctxp,
1529 struct xfrm_user_sec_ctx *sec_ctx);
1530 int (*xfrm_policy_clone_security) (struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctx);
1531 void (*xfrm_policy_free_security) (struct xfrm_sec_ctx *ctx);
1532 int (*xfrm_policy_delete_security) (struct xfrm_sec_ctx *ctx);
1533 int (*xfrm_state_alloc_security) (struct xfrm_state *x,
1534 struct xfrm_user_sec_ctx *sec_ctx,
1535 u32 secid);
1536 void (*xfrm_state_free_security) (struct xfrm_state *x);
1537 int (*xfrm_state_delete_security) (struct xfrm_state *x);
1538 int (*xfrm_policy_lookup) (struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
1539 int (*xfrm_state_pol_flow_match) (struct xfrm_state *x,
1540 struct xfrm_policy *xp,
1541 struct flowi *fl);
1542 int (*xfrm_decode_session) (struct sk_buff *skb, u32 *secid, int ckall);
1543#endif
1544
1545
1546#ifdef CONFIG_KEYS
1547 int (*key_alloc) (struct key *key, struct task_struct *tsk, unsigned long flags);
1548 void (*key_free) (struct key *key);
1549 int (*key_permission) (key_ref_t key_ref,
1550 struct task_struct *context,
1551 key_perm_t perm);
1552 int (*key_getsecurity)(struct key *key, char **_buffer);
1553#endif
1554
1555#ifdef CONFIG_AUDIT
1556 int (*audit_rule_init) (u32 field, u32 op, char *rulestr, void **lsmrule);
1557 int (*audit_rule_known) (struct audit_krule *krule);
1558 int (*audit_rule_match) (u32 secid, u32 field, u32 op, void *lsmrule,
1559 struct audit_context *actx);
1560 void (*audit_rule_free) (void *lsmrule);
1561#endif
1562};
1563
1564
1565extern int security_init(void);
1566extern int security_module_enable(struct security_operations *ops);
1567extern int register_security(struct security_operations *ops);
1568extern int mod_reg_security(const char *name, struct security_operations *ops);
1569extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
1570 struct dentry *parent, void *data,
1571 const struct file_operations *fops);
1572extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
1573extern void securityfs_remove(struct dentry *dentry);
1574
1575
1576int security_ptrace(struct task_struct *parent, struct task_struct *child);
1577int security_capget(struct task_struct *target,
1578 kernel_cap_t *effective,
1579 kernel_cap_t *inheritable,
1580 kernel_cap_t *permitted);
1581int security_capset_check(struct task_struct *target,
1582 kernel_cap_t *effective,
1583 kernel_cap_t *inheritable,
1584 kernel_cap_t *permitted);
1585void security_capset_set(struct task_struct *target,
1586 kernel_cap_t *effective,
1587 kernel_cap_t *inheritable,
1588 kernel_cap_t *permitted);
1589int security_capable(struct task_struct *tsk, int cap);
1590int security_acct(struct file *file);
1591int security_sysctl(struct ctl_table *table, int op);
1592int security_quotactl(int cmds, int type, int id, struct super_block *sb);
1593int security_quota_on(struct dentry *dentry);
1594int security_syslog(int type);
1595int security_settime(struct timespec *ts, struct timezone *tz);
1596int security_vm_enough_memory(long pages);
1597int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
1598int security_bprm_alloc(struct linux_binprm *bprm);
1599void security_bprm_free(struct linux_binprm *bprm);
1600void security_bprm_apply_creds(struct linux_binprm *bprm, int unsafe);
1601void security_bprm_post_apply_creds(struct linux_binprm *bprm);
1602int security_bprm_set(struct linux_binprm *bprm);
1603int security_bprm_check(struct linux_binprm *bprm);
1604int security_bprm_secureexec(struct linux_binprm *bprm);
1605int security_sb_alloc(struct super_block *sb);
1606void security_sb_free(struct super_block *sb);
1607int security_sb_copy_data(char *orig, char *copy);
1608int security_sb_kern_mount(struct super_block *sb, void *data);
1609int security_sb_statfs(struct dentry *dentry);
1610int security_sb_mount(char *dev_name, struct path *path,
1611 char *type, unsigned long flags, void *data);
1612int security_sb_check_sb(struct vfsmount *mnt, struct path *path);
1613int security_sb_umount(struct vfsmount *mnt, int flags);
1614void security_sb_umount_close(struct vfsmount *mnt);
1615void security_sb_umount_busy(struct vfsmount *mnt);
1616void security_sb_post_remount(struct vfsmount *mnt, unsigned long flags, void *data);
1617void security_sb_post_addmount(struct vfsmount *mnt, struct path *mountpoint);
1618int security_sb_pivotroot(struct path *old_path, struct path *new_path);
1619void security_sb_post_pivotroot(struct path *old_path, struct path *new_path);
1620int security_sb_get_mnt_opts(const struct super_block *sb,
1621 struct security_mnt_opts *opts);
1622int security_sb_set_mnt_opts(struct super_block *sb, struct security_mnt_opts *opts);
1623void security_sb_clone_mnt_opts(const struct super_block *oldsb,
1624 struct super_block *newsb);
1625int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts);
1626
1627int security_inode_alloc(struct inode *inode);
1628void security_inode_free(struct inode *inode);
1629int security_inode_init_security(struct inode *inode, struct inode *dir,
1630 char **name, void **value, size_t *len);
1631int security_inode_create(struct inode *dir, struct dentry *dentry, int mode);
1632int security_inode_link(struct dentry *old_dentry, struct inode *dir,
1633 struct dentry *new_dentry);
1634int security_inode_unlink(struct inode *dir, struct dentry *dentry);
1635int security_inode_symlink(struct inode *dir, struct dentry *dentry,
1636 const char *old_name);
1637int security_inode_mkdir(struct inode *dir, struct dentry *dentry, int mode);
1638int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
1639int security_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev);
1640int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
1641 struct inode *new_dir, struct dentry *new_dentry);
1642int security_inode_readlink(struct dentry *dentry);
1643int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
1644int security_inode_permission(struct inode *inode, int mask, struct nameidata *nd);
1645int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
1646int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
1647void security_inode_delete(struct inode *inode);
1648int security_inode_setxattr(struct dentry *dentry, const char *name,
1649 const void *value, size_t size, int flags);
1650void security_inode_post_setxattr(struct dentry *dentry, const char *name,
1651 const void *value, size_t size, int flags);
1652int security_inode_getxattr(struct dentry *dentry, const char *name);
1653int security_inode_listxattr(struct dentry *dentry);
1654int security_inode_removexattr(struct dentry *dentry, const char *name);
1655int security_inode_need_killpriv(struct dentry *dentry);
1656int security_inode_killpriv(struct dentry *dentry);
1657int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc);
1658int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1659int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
1660void security_inode_getsecid(const struct inode *inode, u32 *secid);
1661int security_file_permission(struct file *file, int mask);
1662int security_file_alloc(struct file *file);
1663void security_file_free(struct file *file);
1664int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1665int security_file_mmap(struct file *file, unsigned long reqprot,
1666 unsigned long prot, unsigned long flags,
1667 unsigned long addr, unsigned long addr_only);
1668int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
1669 unsigned long prot);
1670int security_file_lock(struct file *file, unsigned int cmd);
1671int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
1672int security_file_set_fowner(struct file *file);
1673int security_file_send_sigiotask(struct task_struct *tsk,
1674 struct fown_struct *fown, int sig);
1675int security_file_receive(struct file *file);
1676int security_dentry_open(struct file *file);
1677int security_task_create(unsigned long clone_flags);
1678int security_task_alloc(struct task_struct *p);
1679void security_task_free(struct task_struct *p);
1680int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags);
1681int security_task_post_setuid(uid_t old_ruid, uid_t old_euid,
1682 uid_t old_suid, int flags);
1683int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags);
1684int security_task_setpgid(struct task_struct *p, pid_t pgid);
1685int security_task_getpgid(struct task_struct *p);
1686int security_task_getsid(struct task_struct *p);
1687void security_task_getsecid(struct task_struct *p, u32 *secid);
1688int security_task_setgroups(struct group_info *group_info);
1689int security_task_setnice(struct task_struct *p, int nice);
1690int security_task_setioprio(struct task_struct *p, int ioprio);
1691int security_task_getioprio(struct task_struct *p);
1692int security_task_setrlimit(unsigned int resource, struct rlimit *new_rlim);
1693int security_task_setscheduler(struct task_struct *p,
1694 int policy, struct sched_param *lp);
1695int security_task_getscheduler(struct task_struct *p);
1696int security_task_movememory(struct task_struct *p);
1697int security_task_kill(struct task_struct *p, struct siginfo *info,
1698 int sig, u32 secid);
1699int security_task_wait(struct task_struct *p);
1700int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
1701 unsigned long arg4, unsigned long arg5, long *rc_p);
1702void security_task_reparent_to_init(struct task_struct *p);
1703void security_task_to_inode(struct task_struct *p, struct inode *inode);
1704int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
1705void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
1706int security_msg_msg_alloc(struct msg_msg *msg);
1707void security_msg_msg_free(struct msg_msg *msg);
1708int security_msg_queue_alloc(struct msg_queue *msq);
1709void security_msg_queue_free(struct msg_queue *msq);
1710int security_msg_queue_associate(struct msg_queue *msq, int msqflg);
1711int security_msg_queue_msgctl(struct msg_queue *msq, int cmd);
1712int security_msg_queue_msgsnd(struct msg_queue *msq,
1713 struct msg_msg *msg, int msqflg);
1714int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
1715 struct task_struct *target, long type, int mode);
1716int security_shm_alloc(struct shmid_kernel *shp);
1717void security_shm_free(struct shmid_kernel *shp);
1718int security_shm_associate(struct shmid_kernel *shp, int shmflg);
1719int security_shm_shmctl(struct shmid_kernel *shp, int cmd);
1720int security_shm_shmat(struct shmid_kernel *shp, char __user *shmaddr, int shmflg);
1721int security_sem_alloc(struct sem_array *sma);
1722void security_sem_free(struct sem_array *sma);
1723int security_sem_associate(struct sem_array *sma, int semflg);
1724int security_sem_semctl(struct sem_array *sma, int cmd);
1725int security_sem_semop(struct sem_array *sma, struct sembuf *sops,
1726 unsigned nsops, int alter);
1727void security_d_instantiate(struct dentry *dentry, struct inode *inode);
1728int security_getprocattr(struct task_struct *p, char *name, char **value);
1729int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size);
1730int security_netlink_send(struct sock *sk, struct sk_buff *skb);
1731int security_netlink_recv(struct sk_buff *skb, int cap);
1732int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
1733int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
1734void security_release_secctx(char *secdata, u32 seclen);
1735
1736#else
1737struct security_mnt_opts {
1738};
1739
1740static inline void security_init_mnt_opts(struct security_mnt_opts *opts)
1741{
1742}
1743
1744static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1745{
1746}
1747
1748
1749
1750
1751
1752
1753static inline int security_init(void)
1754{
1755 return 0;
1756}
1757
1758static inline int security_ptrace(struct task_struct *parent, struct task_struct *child)
1759{
1760 return cap_ptrace(parent, child);
1761}
1762
1763static inline int security_capget(struct task_struct *target,
1764 kernel_cap_t *effective,
1765 kernel_cap_t *inheritable,
1766 kernel_cap_t *permitted)
1767{
1768 return cap_capget(target, effective, inheritable, permitted);
1769}
1770
1771static inline int security_capset_check(struct task_struct *target,
1772 kernel_cap_t *effective,
1773 kernel_cap_t *inheritable,
1774 kernel_cap_t *permitted)
1775{
1776 return cap_capset_check(target, effective, inheritable, permitted);
1777}
1778
1779static inline void security_capset_set(struct task_struct *target,
1780 kernel_cap_t *effective,
1781 kernel_cap_t *inheritable,
1782 kernel_cap_t *permitted)
1783{
1784 cap_capset_set(target, effective, inheritable, permitted);
1785}
1786
1787static inline int security_capable(struct task_struct *tsk, int cap)
1788{
1789 return cap_capable(tsk, cap);
1790}
1791
1792static inline int security_acct(struct file *file)
1793{
1794 return 0;
1795}
1796
1797static inline int security_sysctl(struct ctl_table *table, int op)
1798{
1799 return 0;
1800}
1801
1802static inline int security_quotactl(int cmds, int type, int id,
1803 struct super_block *sb)
1804{
1805 return 0;
1806}
1807
1808static inline int security_quota_on(struct dentry *dentry)
1809{
1810 return 0;
1811}
1812
1813static inline int security_syslog(int type)
1814{
1815 return cap_syslog(type);
1816}
1817
1818static inline int security_settime(struct timespec *ts, struct timezone *tz)
1819{
1820 return cap_settime(ts, tz);
1821}
1822
1823static inline int security_vm_enough_memory(long pages)
1824{
1825 return cap_vm_enough_memory(current->mm, pages);
1826}
1827
1828static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
1829{
1830 return cap_vm_enough_memory(mm, pages);
1831}
1832
1833static inline int security_bprm_alloc(struct linux_binprm *bprm)
1834{
1835 return 0;
1836}
1837
1838static inline void security_bprm_free(struct linux_binprm *bprm)
1839{ }
1840
1841static inline void security_bprm_apply_creds(struct linux_binprm *bprm, int unsafe)
1842{
1843 cap_bprm_apply_creds(bprm, unsafe);
1844}
1845
1846static inline void security_bprm_post_apply_creds(struct linux_binprm *bprm)
1847{
1848 return;
1849}
1850
1851static inline int security_bprm_set(struct linux_binprm *bprm)
1852{
1853 return cap_bprm_set_security(bprm);
1854}
1855
1856static inline int security_bprm_check(struct linux_binprm *bprm)
1857{
1858 return 0;
1859}
1860
1861static inline int security_bprm_secureexec(struct linux_binprm *bprm)
1862{
1863 return cap_bprm_secureexec(bprm);
1864}
1865
1866static inline int security_sb_alloc(struct super_block *sb)
1867{
1868 return 0;
1869}
1870
1871static inline void security_sb_free(struct super_block *sb)
1872{ }
1873
1874static inline int security_sb_copy_data(char *orig, char *copy)
1875{
1876 return 0;
1877}
1878
1879static inline int security_sb_kern_mount(struct super_block *sb, void *data)
1880{
1881 return 0;
1882}
1883
1884static inline int security_sb_statfs(struct dentry *dentry)
1885{
1886 return 0;
1887}
1888
1889static inline int security_sb_mount(char *dev_name, struct path *path,
1890 char *type, unsigned long flags,
1891 void *data)
1892{
1893 return 0;
1894}
1895
1896static inline int security_sb_check_sb(struct vfsmount *mnt,
1897 struct path *path)
1898{
1899 return 0;
1900}
1901
1902static inline int security_sb_umount(struct vfsmount *mnt, int flags)
1903{
1904 return 0;
1905}
1906
1907static inline void security_sb_umount_close(struct vfsmount *mnt)
1908{ }
1909
1910static inline void security_sb_umount_busy(struct vfsmount *mnt)
1911{ }
1912
1913static inline void security_sb_post_remount(struct vfsmount *mnt,
1914 unsigned long flags, void *data)
1915{ }
1916
1917static inline void security_sb_post_addmount(struct vfsmount *mnt,
1918 struct path *mountpoint)
1919{ }
1920
1921static inline int security_sb_pivotroot(struct path *old_path,
1922 struct path *new_path)
1923{
1924 return 0;
1925}
1926
1927static inline void security_sb_post_pivotroot(struct path *old_path,
1928 struct path *new_path)
1929{ }
1930static inline int security_sb_get_mnt_opts(const struct super_block *sb,
1931 struct security_mnt_opts *opts)
1932{
1933 security_init_mnt_opts(opts);
1934 return 0;
1935}
1936
1937static inline int security_sb_set_mnt_opts(struct super_block *sb,
1938 struct security_mnt_opts *opts)
1939{
1940 return 0;
1941}
1942
1943static inline void security_sb_clone_mnt_opts(const struct super_block *oldsb,
1944 struct super_block *newsb)
1945{ }
1946
1947static inline int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts)
1948{
1949 return 0;
1950}
1951
1952static inline int security_inode_alloc(struct inode *inode)
1953{
1954 return 0;
1955}
1956
1957static inline void security_inode_free(struct inode *inode)
1958{ }
1959
1960static inline int security_inode_init_security(struct inode *inode,
1961 struct inode *dir,
1962 char **name,
1963 void **value,
1964 size_t *len)
1965{
1966 return -EOPNOTSUPP;
1967}
1968
1969static inline int security_inode_create(struct inode *dir,
1970 struct dentry *dentry,
1971 int mode)
1972{
1973 return 0;
1974}
1975
1976static inline int security_inode_link(struct dentry *old_dentry,
1977 struct inode *dir,
1978 struct dentry *new_dentry)
1979{
1980 return 0;
1981}
1982
1983static inline int security_inode_unlink(struct inode *dir,
1984 struct dentry *dentry)
1985{
1986 return 0;
1987}
1988
1989static inline int security_inode_symlink(struct inode *dir,
1990 struct dentry *dentry,
1991 const char *old_name)
1992{
1993 return 0;
1994}
1995
1996static inline int security_inode_mkdir(struct inode *dir,
1997 struct dentry *dentry,
1998 int mode)
1999{
2000 return 0;
2001}
2002
2003static inline int security_inode_rmdir(struct inode *dir,
2004 struct dentry *dentry)
2005{
2006 return 0;
2007}
2008
2009static inline int security_inode_mknod(struct inode *dir,
2010 struct dentry *dentry,
2011 int mode, dev_t dev)
2012{
2013 return 0;
2014}
2015
2016static inline int security_inode_rename(struct inode *old_dir,
2017 struct dentry *old_dentry,
2018 struct inode *new_dir,
2019 struct dentry *new_dentry)
2020{
2021 return 0;
2022}
2023
2024static inline int security_inode_readlink(struct dentry *dentry)
2025{
2026 return 0;
2027}
2028
2029static inline int security_inode_follow_link(struct dentry *dentry,
2030 struct nameidata *nd)
2031{
2032 return 0;
2033}
2034
2035static inline int security_inode_permission(struct inode *inode, int mask,
2036 struct nameidata *nd)
2037{
2038 return 0;
2039}
2040
2041static inline int security_inode_setattr(struct dentry *dentry,
2042 struct iattr *attr)
2043{
2044 return 0;
2045}
2046
2047static inline int security_inode_getattr(struct vfsmount *mnt,
2048 struct dentry *dentry)
2049{
2050 return 0;
2051}
2052
2053static inline void security_inode_delete(struct inode *inode)
2054{ }
2055
2056static inline int security_inode_setxattr(struct dentry *dentry,
2057 const char *name, const void *value, size_t size, int flags)
2058{
2059 return cap_inode_setxattr(dentry, name, value, size, flags);
2060}
2061
2062static inline void security_inode_post_setxattr(struct dentry *dentry,
2063 const char *name, const void *value, size_t size, int flags)
2064{ }
2065
2066static inline int security_inode_getxattr(struct dentry *dentry,
2067 const char *name)
2068{
2069 return 0;
2070}
2071
2072static inline int security_inode_listxattr(struct dentry *dentry)
2073{
2074 return 0;
2075}
2076
2077static inline int security_inode_removexattr(struct dentry *dentry,
2078 const char *name)
2079{
2080 return cap_inode_removexattr(dentry, name);
2081}
2082
2083static inline int security_inode_need_killpriv(struct dentry *dentry)
2084{
2085 return cap_inode_need_killpriv(dentry);
2086}
2087
2088static inline int security_inode_killpriv(struct dentry *dentry)
2089{
2090 return cap_inode_killpriv(dentry);
2091}
2092
2093static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc)
2094{
2095 return -EOPNOTSUPP;
2096}
2097
2098static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2099{
2100 return -EOPNOTSUPP;
2101}
2102
2103static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2104{
2105 return 0;
2106}
2107
2108static inline void security_inode_getsecid(const struct inode *inode, u32 *secid)
2109{
2110 *secid = 0;
2111}
2112
2113static inline int security_file_permission(struct file *file, int mask)
2114{
2115 return 0;
2116}
2117
2118static inline int security_file_alloc(struct file *file)
2119{
2120 return 0;
2121}
2122
2123static inline void security_file_free(struct file *file)
2124{ }
2125
2126static inline int security_file_ioctl(struct file *file, unsigned int cmd,
2127 unsigned long arg)
2128{
2129 return 0;
2130}
2131
2132static inline int security_file_mmap(struct file *file, unsigned long reqprot,
2133 unsigned long prot,
2134 unsigned long flags,
2135 unsigned long addr,
2136 unsigned long addr_only)
2137{
2138 return 0;
2139}
2140
2141static inline int security_file_mprotect(struct vm_area_struct *vma,
2142 unsigned long reqprot,
2143 unsigned long prot)
2144{
2145 return 0;
2146}
2147
2148static inline int security_file_lock(struct file *file, unsigned int cmd)
2149{
2150 return 0;
2151}
2152
2153static inline int security_file_fcntl(struct file *file, unsigned int cmd,
2154 unsigned long arg)
2155{
2156 return 0;
2157}
2158
2159static inline int security_file_set_fowner(struct file *file)
2160{
2161 return 0;
2162}
2163
2164static inline int security_file_send_sigiotask(struct task_struct *tsk,
2165 struct fown_struct *fown,
2166 int sig)
2167{
2168 return 0;
2169}
2170
2171static inline int security_file_receive(struct file *file)
2172{
2173 return 0;
2174}
2175
2176static inline int security_dentry_open(struct file *file)
2177{
2178 return 0;
2179}
2180
2181static inline int security_task_create(unsigned long clone_flags)
2182{
2183 return 0;
2184}
2185
2186static inline int security_task_alloc(struct task_struct *p)
2187{
2188 return 0;
2189}
2190
2191static inline void security_task_free(struct task_struct *p)
2192{ }
2193
2194static inline int security_task_setuid(uid_t id0, uid_t id1, uid_t id2,
2195 int flags)
2196{
2197 return 0;
2198}
2199
2200static inline int security_task_post_setuid(uid_t old_ruid, uid_t old_euid,
2201 uid_t old_suid, int flags)
2202{
2203 return cap_task_post_setuid(old_ruid, old_euid, old_suid, flags);
2204}
2205
2206static inline int security_task_setgid(gid_t id0, gid_t id1, gid_t id2,
2207 int flags)
2208{
2209 return 0;
2210}
2211
2212static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
2213{
2214 return 0;
2215}
2216
2217static inline int security_task_getpgid(struct task_struct *p)
2218{
2219 return 0;
2220}
2221
2222static inline int security_task_getsid(struct task_struct *p)
2223{
2224 return 0;
2225}
2226
2227static inline void security_task_getsecid(struct task_struct *p, u32 *secid)
2228{
2229 *secid = 0;
2230}
2231
2232static inline int security_task_setgroups(struct group_info *group_info)
2233{
2234 return 0;
2235}
2236
2237static inline int security_task_setnice(struct task_struct *p, int nice)
2238{
2239 return cap_task_setnice(p, nice);
2240}
2241
2242static inline int security_task_setioprio(struct task_struct *p, int ioprio)
2243{
2244 return cap_task_setioprio(p, ioprio);
2245}
2246
2247static inline int security_task_getioprio(struct task_struct *p)
2248{
2249 return 0;
2250}
2251
2252static inline int security_task_setrlimit(unsigned int resource,
2253 struct rlimit *new_rlim)
2254{
2255 return 0;
2256}
2257
2258static inline int security_task_setscheduler(struct task_struct *p,
2259 int policy,
2260 struct sched_param *lp)
2261{
2262 return cap_task_setscheduler(p, policy, lp);
2263}
2264
2265static inline int security_task_getscheduler(struct task_struct *p)
2266{
2267 return 0;
2268}
2269
2270static inline int security_task_movememory(struct task_struct *p)
2271{
2272 return 0;
2273}
2274
2275static inline int security_task_kill(struct task_struct *p,
2276 struct siginfo *info, int sig,
2277 u32 secid)
2278{
2279 return 0;
2280}
2281
2282static inline int security_task_wait(struct task_struct *p)
2283{
2284 return 0;
2285}
2286
2287static inline int security_task_prctl(int option, unsigned long arg2,
2288 unsigned long arg3,
2289 unsigned long arg4,
2290 unsigned long arg5, long *rc_p)
2291{
2292 return cap_task_prctl(option, arg2, arg3, arg3, arg5, rc_p);
2293}
2294
2295static inline void security_task_reparent_to_init(struct task_struct *p)
2296{
2297 cap_task_reparent_to_init(p);
2298}
2299
2300static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2301{ }
2302
2303static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
2304 short flag)
2305{
2306 return 0;
2307}
2308
2309static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
2310{
2311 *secid = 0;
2312}
2313
2314static inline int security_msg_msg_alloc(struct msg_msg *msg)
2315{
2316 return 0;
2317}
2318
2319static inline void security_msg_msg_free(struct msg_msg *msg)
2320{ }
2321
2322static inline int security_msg_queue_alloc(struct msg_queue *msq)
2323{
2324 return 0;
2325}
2326
2327static inline void security_msg_queue_free(struct msg_queue *msq)
2328{ }
2329
2330static inline int security_msg_queue_associate(struct msg_queue *msq,
2331 int msqflg)
2332{
2333 return 0;
2334}
2335
2336static inline int security_msg_queue_msgctl(struct msg_queue *msq, int cmd)
2337{
2338 return 0;
2339}
2340
2341static inline int security_msg_queue_msgsnd(struct msg_queue *msq,
2342 struct msg_msg *msg, int msqflg)
2343{
2344 return 0;
2345}
2346
2347static inline int security_msg_queue_msgrcv(struct msg_queue *msq,
2348 struct msg_msg *msg,
2349 struct task_struct *target,
2350 long type, int mode)
2351{
2352 return 0;
2353}
2354
2355static inline int security_shm_alloc(struct shmid_kernel *shp)
2356{
2357 return 0;
2358}
2359
2360static inline void security_shm_free(struct shmid_kernel *shp)
2361{ }
2362
2363static inline int security_shm_associate(struct shmid_kernel *shp,
2364 int shmflg)
2365{
2366 return 0;
2367}
2368
2369static inline int security_shm_shmctl(struct shmid_kernel *shp, int cmd)
2370{
2371 return 0;
2372}
2373
2374static inline int security_shm_shmat(struct shmid_kernel *shp,
2375 char __user *shmaddr, int shmflg)
2376{
2377 return 0;
2378}
2379
2380static inline int security_sem_alloc(struct sem_array *sma)
2381{
2382 return 0;
2383}
2384
2385static inline void security_sem_free(struct sem_array *sma)
2386{ }
2387
2388static inline int security_sem_associate(struct sem_array *sma, int semflg)
2389{
2390 return 0;
2391}
2392
2393static inline int security_sem_semctl(struct sem_array *sma, int cmd)
2394{
2395 return 0;
2396}
2397
2398static inline int security_sem_semop(struct sem_array *sma,
2399 struct sembuf *sops, unsigned nsops,
2400 int alter)
2401{
2402 return 0;
2403}
2404
2405static inline void security_d_instantiate(struct dentry *dentry, struct inode *inode)
2406{ }
2407
2408static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
2409{
2410 return -EINVAL;
2411}
2412
2413static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2414{
2415 return -EINVAL;
2416}
2417
2418static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
2419{
2420 return cap_netlink_send(sk, skb);
2421}
2422
2423static inline int security_netlink_recv(struct sk_buff *skb, int cap)
2424{
2425 return cap_netlink_recv(skb, cap);
2426}
2427
2428static inline struct dentry *securityfs_create_dir(const char *name,
2429 struct dentry *parent)
2430{
2431 return ERR_PTR(-ENODEV);
2432}
2433
2434static inline struct dentry *securityfs_create_file(const char *name,
2435 mode_t mode,
2436 struct dentry *parent,
2437 void *data,
2438 const struct file_operations *fops)
2439{
2440 return ERR_PTR(-ENODEV);
2441}
2442
2443static inline void securityfs_remove(struct dentry *dentry)
2444{
2445}
2446
2447static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2448{
2449 return -EOPNOTSUPP;
2450}
2451
2452static inline int security_secctx_to_secid(const char *secdata,
2453 u32 seclen,
2454 u32 *secid)
2455{
2456 return -EOPNOTSUPP;
2457}
2458
2459static inline void security_release_secctx(char *secdata, u32 seclen)
2460{
2461}
2462#endif
2463
2464#ifdef CONFIG_SECURITY_NETWORK
2465
2466int security_unix_stream_connect(struct socket *sock, struct socket *other,
2467 struct sock *newsk);
2468int security_unix_may_send(struct socket *sock, struct socket *other);
2469int security_socket_create(int family, int type, int protocol, int kern);
2470int security_socket_post_create(struct socket *sock, int family,
2471 int type, int protocol, int kern);
2472int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
2473int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
2474int security_socket_listen(struct socket *sock, int backlog);
2475int security_socket_accept(struct socket *sock, struct socket *newsock);
2476void security_socket_post_accept(struct socket *sock, struct socket *newsock);
2477int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
2478int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
2479 int size, int flags);
2480int security_socket_getsockname(struct socket *sock);
2481int security_socket_getpeername(struct socket *sock);
2482int security_socket_getsockopt(struct socket *sock, int level, int optname);
2483int security_socket_setsockopt(struct socket *sock, int level, int optname);
2484int security_socket_shutdown(struct socket *sock, int how);
2485int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
2486int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2487 int __user *optlen, unsigned len);
2488int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
2489int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
2490void security_sk_free(struct sock *sk);
2491void security_sk_clone(const struct sock *sk, struct sock *newsk);
2492void security_sk_classify_flow(struct sock *sk, struct flowi *fl);
2493void security_req_classify_flow(const struct request_sock *req, struct flowi *fl);
2494void security_sock_graft(struct sock*sk, struct socket *parent);
2495int security_inet_conn_request(struct sock *sk,
2496 struct sk_buff *skb, struct request_sock *req);
2497void security_inet_csk_clone(struct sock *newsk,
2498 const struct request_sock *req);
2499void security_inet_conn_established(struct sock *sk,
2500 struct sk_buff *skb);
2501
2502#else
2503static inline int security_unix_stream_connect(struct socket *sock,
2504 struct socket *other,
2505 struct sock *newsk)
2506{
2507 return 0;
2508}
2509
2510static inline int security_unix_may_send(struct socket *sock,
2511 struct socket *other)
2512{
2513 return 0;
2514}
2515
2516static inline int security_socket_create(int family, int type,
2517 int protocol, int kern)
2518{
2519 return 0;
2520}
2521
2522static inline int security_socket_post_create(struct socket *sock,
2523 int family,
2524 int type,
2525 int protocol, int kern)
2526{
2527 return 0;
2528}
2529
2530static inline int security_socket_bind(struct socket *sock,
2531 struct sockaddr *address,
2532 int addrlen)
2533{
2534 return 0;
2535}
2536
2537static inline int security_socket_connect(struct socket *sock,
2538 struct sockaddr *address,
2539 int addrlen)
2540{
2541 return 0;
2542}
2543
2544static inline int security_socket_listen(struct socket *sock, int backlog)
2545{
2546 return 0;
2547}
2548
2549static inline int security_socket_accept(struct socket *sock,
2550 struct socket *newsock)
2551{
2552 return 0;
2553}
2554
2555static inline void security_socket_post_accept(struct socket *sock,
2556 struct socket *newsock)
2557{
2558}
2559
2560static inline int security_socket_sendmsg(struct socket *sock,
2561 struct msghdr *msg, int size)
2562{
2563 return 0;
2564}
2565
2566static inline int security_socket_recvmsg(struct socket *sock,
2567 struct msghdr *msg, int size,
2568 int flags)
2569{
2570 return 0;
2571}
2572
2573static inline int security_socket_getsockname(struct socket *sock)
2574{
2575 return 0;
2576}
2577
2578static inline int security_socket_getpeername(struct socket *sock)
2579{
2580 return 0;
2581}
2582
2583static inline int security_socket_getsockopt(struct socket *sock,
2584 int level, int optname)
2585{
2586 return 0;
2587}
2588
2589static inline int security_socket_setsockopt(struct socket *sock,
2590 int level, int optname)
2591{
2592 return 0;
2593}
2594
2595static inline int security_socket_shutdown(struct socket *sock, int how)
2596{
2597 return 0;
2598}
2599static inline int security_sock_rcv_skb(struct sock *sk,
2600 struct sk_buff *skb)
2601{
2602 return 0;
2603}
2604
2605static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2606 int __user *optlen, unsigned len)
2607{
2608 return -ENOPROTOOPT;
2609}
2610
2611static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
2612{
2613 return -ENOPROTOOPT;
2614}
2615
2616static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
2617{
2618 return 0;
2619}
2620
2621static inline void security_sk_free(struct sock *sk)
2622{
2623}
2624
2625static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
2626{
2627}
2628
2629static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
2630{
2631}
2632
2633static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
2634{
2635}
2636
2637static inline void security_sock_graft(struct sock *sk, struct socket *parent)
2638{
2639}
2640
2641static inline int security_inet_conn_request(struct sock *sk,
2642 struct sk_buff *skb, struct request_sock *req)
2643{
2644 return 0;
2645}
2646
2647static inline void security_inet_csk_clone(struct sock *newsk,
2648 const struct request_sock *req)
2649{
2650}
2651
2652static inline void security_inet_conn_established(struct sock *sk,
2653 struct sk_buff *skb)
2654{
2655}
2656#endif
2657
2658#ifdef CONFIG_SECURITY_NETWORK_XFRM
2659
2660int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, struct xfrm_user_sec_ctx *sec_ctx);
2661int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
2662void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
2663int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
2664int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
2665int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2666 struct xfrm_sec_ctx *polsec, u32 secid);
2667int security_xfrm_state_delete(struct xfrm_state *x);
2668void security_xfrm_state_free(struct xfrm_state *x);
2669int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
2670int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2671 struct xfrm_policy *xp, struct flowi *fl);
2672int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
2673void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl);
2674
2675#else
2676
2677static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, struct xfrm_user_sec_ctx *sec_ctx)
2678{
2679 return 0;
2680}
2681
2682static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
2683{
2684 return 0;
2685}
2686
2687static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
2688{
2689}
2690
2691static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
2692{
2693 return 0;
2694}
2695
2696static inline int security_xfrm_state_alloc(struct xfrm_state *x,
2697 struct xfrm_user_sec_ctx *sec_ctx)
2698{
2699 return 0;
2700}
2701
2702static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2703 struct xfrm_sec_ctx *polsec, u32 secid)
2704{
2705 return 0;
2706}
2707
2708static inline void security_xfrm_state_free(struct xfrm_state *x)
2709{
2710}
2711
2712static inline int security_xfrm_state_delete(struct xfrm_state *x)
2713{
2714 return 0;
2715}
2716
2717static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir)
2718{
2719 return 0;
2720}
2721
2722static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2723 struct xfrm_policy *xp, struct flowi *fl)
2724{
2725 return 1;
2726}
2727
2728static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
2729{
2730 return 0;
2731}
2732
2733static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
2734{
2735}
2736
2737#endif
2738
2739#ifdef CONFIG_KEYS
2740#ifdef CONFIG_SECURITY
2741
2742int security_key_alloc(struct key *key, struct task_struct *tsk, unsigned long flags);
2743void security_key_free(struct key *key);
2744int security_key_permission(key_ref_t key_ref,
2745 struct task_struct *context, key_perm_t perm);
2746int security_key_getsecurity(struct key *key, char **_buffer);
2747
2748#else
2749
2750static inline int security_key_alloc(struct key *key,
2751 struct task_struct *tsk,
2752 unsigned long flags)
2753{
2754 return 0;
2755}
2756
2757static inline void security_key_free(struct key *key)
2758{
2759}
2760
2761static inline int security_key_permission(key_ref_t key_ref,
2762 struct task_struct *context,
2763 key_perm_t perm)
2764{
2765 return 0;
2766}
2767
2768static inline int security_key_getsecurity(struct key *key, char **_buffer)
2769{
2770 *_buffer = NULL;
2771 return 0;
2772}
2773
2774#endif
2775#endif
2776
2777#ifdef CONFIG_AUDIT
2778#ifdef CONFIG_SECURITY
2779int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
2780int security_audit_rule_known(struct audit_krule *krule);
2781int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule,
2782 struct audit_context *actx);
2783void security_audit_rule_free(void *lsmrule);
2784
2785#else
2786
2787static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
2788 void **lsmrule)
2789{
2790 return 0;
2791}
2792
2793static inline int security_audit_rule_known(struct audit_krule *krule)
2794{
2795 return 0;
2796}
2797
2798static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
2799 void *lsmrule, struct audit_context *actx)
2800{
2801 return 0;
2802}
2803
2804static inline void security_audit_rule_free(void *lsmrule)
2805{ }
2806
2807#endif
2808#endif
2809
2810#endif
2811
2812