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/mm.h>
32#include <linux/msg.h>
33#include <linux/sched.h>
34#include <linux/key.h>
35#include <linux/xfrm.h>
36#include <linux/gfp.h>
37#include <net/flow.h>
38
39
40#define SECURITY_NAME_MAX 10
41
42
43#define SECURITY_CAP_NOAUDIT 0
44#define SECURITY_CAP_AUDIT 1
45
46struct ctl_table;
47struct audit_krule;
48
49
50
51
52
53extern int cap_capable(struct task_struct *tsk, const struct cred *cred,
54 int cap, int audit);
55extern int cap_settime(struct timespec *ts, struct timezone *tz);
56extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
57extern int cap_ptrace_traceme(struct task_struct *parent);
58extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
59extern int cap_capset(struct cred *new, const struct cred *old,
60 const kernel_cap_t *effective,
61 const kernel_cap_t *inheritable,
62 const kernel_cap_t *permitted);
63extern int cap_bprm_set_creds(struct linux_binprm *bprm);
64extern int cap_bprm_secureexec(struct linux_binprm *bprm);
65extern int cap_inode_setxattr(struct dentry *dentry, const char *name,
66 const void *value, size_t size, int flags);
67extern int cap_inode_removexattr(struct dentry *dentry, const char *name);
68extern int cap_inode_need_killpriv(struct dentry *dentry);
69extern int cap_inode_killpriv(struct dentry *dentry);
70extern int cap_file_mmap(struct file *file, unsigned long reqprot,
71 unsigned long prot, unsigned long flags,
72 unsigned long addr, unsigned long addr_only);
73extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
74extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
75 unsigned long arg4, unsigned long arg5);
76extern int cap_task_setscheduler(struct task_struct *p, int policy, struct sched_param *lp);
77extern int cap_task_setioprio(struct task_struct *p, int ioprio);
78extern int cap_task_setnice(struct task_struct *p, int nice);
79extern int cap_syslog(int type);
80extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
81
82struct msghdr;
83struct sk_buff;
84struct sock;
85struct sockaddr;
86struct socket;
87struct flowi;
88struct dst_entry;
89struct xfrm_selector;
90struct xfrm_policy;
91struct xfrm_state;
92struct xfrm_user_sec_ctx;
93struct seq_file;
94
95extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
96extern int cap_netlink_recv(struct sk_buff *skb, int cap);
97
98#ifdef CONFIG_MMU
99extern unsigned long mmap_min_addr;
100extern unsigned long dac_mmap_min_addr;
101#else
102#define dac_mmap_min_addr 0UL
103#endif
104
105
106
107
108
109#define LSM_SETID_ID 1
110
111
112#define LSM_SETID_RE 2
113
114
115#define LSM_SETID_RES 4
116
117
118#define LSM_SETID_FS 8
119
120
121struct sched_param;
122struct request_sock;
123
124
125#define LSM_UNSAFE_SHARE 1
126#define LSM_UNSAFE_PTRACE 2
127#define LSM_UNSAFE_PTRACE_CAP 4
128
129#ifdef CONFIG_MMU
130
131
132
133
134static inline unsigned long round_hint_to_min(unsigned long hint)
135{
136 hint &= PAGE_MASK;
137 if (((void *)hint != NULL) &&
138 (hint < mmap_min_addr))
139 return PAGE_ALIGN(mmap_min_addr);
140 return hint;
141}
142extern int mmap_min_addr_handler(struct ctl_table *table, int write,
143 void __user *buffer, size_t *lenp, loff_t *ppos);
144#endif
145
146#ifdef CONFIG_SECURITY
147
148struct security_mnt_opts {
149 char **mnt_opts;
150 int *mnt_opts_flags;
151 int num_mnt_opts;
152};
153
154static inline void security_init_mnt_opts(struct security_mnt_opts *opts)
155{
156 opts->mnt_opts = NULL;
157 opts->mnt_opts_flags = NULL;
158 opts->num_mnt_opts = 0;
159}
160
161static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
162{
163 int i;
164 if (opts->mnt_opts)
165 for (i = 0; i < opts->num_mnt_opts; i++)
166 kfree(opts->mnt_opts[i]);
167 kfree(opts->mnt_opts);
168 opts->mnt_opts = NULL;
169 kfree(opts->mnt_opts_flags);
170 opts->mnt_opts_flags = NULL;
171 opts->num_mnt_opts = 0;
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
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446struct security_operations {
1447 char name[SECURITY_NAME_MAX + 1];
1448
1449 int (*ptrace_access_check) (struct task_struct *child, unsigned int mode);
1450 int (*ptrace_traceme) (struct task_struct *parent);
1451 int (*capget) (struct task_struct *target,
1452 kernel_cap_t *effective,
1453 kernel_cap_t *inheritable, kernel_cap_t *permitted);
1454 int (*capset) (struct cred *new,
1455 const struct cred *old,
1456 const kernel_cap_t *effective,
1457 const kernel_cap_t *inheritable,
1458 const kernel_cap_t *permitted);
1459 int (*capable) (struct task_struct *tsk, const struct cred *cred,
1460 int cap, int audit);
1461 int (*acct) (struct file *file);
1462 int (*sysctl) (struct ctl_table *table, int op);
1463 int (*quotactl) (int cmds, int type, int id, struct super_block *sb);
1464 int (*quota_on) (struct dentry *dentry);
1465 int (*syslog) (int type);
1466 int (*settime) (struct timespec *ts, struct timezone *tz);
1467 int (*vm_enough_memory) (struct mm_struct *mm, long pages);
1468
1469 int (*bprm_set_creds) (struct linux_binprm *bprm);
1470 int (*bprm_check_security) (struct linux_binprm *bprm);
1471 int (*bprm_secureexec) (struct linux_binprm *bprm);
1472 void (*bprm_committing_creds) (struct linux_binprm *bprm);
1473 void (*bprm_committed_creds) (struct linux_binprm *bprm);
1474
1475 int (*sb_alloc_security) (struct super_block *sb);
1476 void (*sb_free_security) (struct super_block *sb);
1477 int (*sb_copy_data) (char *orig, char *copy);
1478 int (*sb_kern_mount) (struct super_block *sb, int flags, void *data);
1479 int (*sb_show_options) (struct seq_file *m, struct super_block *sb);
1480 int (*sb_statfs) (struct dentry *dentry);
1481 int (*sb_mount) (char *dev_name, struct path *path,
1482 char *type, unsigned long flags, void *data);
1483 int (*sb_check_sb) (struct vfsmount *mnt, struct path *path);
1484 int (*sb_umount) (struct vfsmount *mnt, int flags);
1485 void (*sb_umount_close) (struct vfsmount *mnt);
1486 void (*sb_umount_busy) (struct vfsmount *mnt);
1487 void (*sb_post_remount) (struct vfsmount *mnt,
1488 unsigned long flags, void *data);
1489 void (*sb_post_addmount) (struct vfsmount *mnt,
1490 struct path *mountpoint);
1491 int (*sb_pivotroot) (struct path *old_path,
1492 struct path *new_path);
1493 void (*sb_post_pivotroot) (struct path *old_path,
1494 struct path *new_path);
1495 int (*sb_set_mnt_opts) (struct super_block *sb,
1496 struct security_mnt_opts *opts);
1497 void (*sb_clone_mnt_opts) (const struct super_block *oldsb,
1498 struct super_block *newsb);
1499 int (*sb_parse_opts_str) (char *options, struct security_mnt_opts *opts);
1500
1501#ifdef CONFIG_SECURITY_PATH
1502 int (*path_unlink) (struct path *dir, struct dentry *dentry);
1503 int (*path_mkdir) (struct path *dir, struct dentry *dentry, int mode);
1504 int (*path_rmdir) (struct path *dir, struct dentry *dentry);
1505 int (*path_mknod) (struct path *dir, struct dentry *dentry, int mode,
1506 unsigned int dev);
1507 int (*path_truncate) (struct path *path, loff_t length,
1508 unsigned int time_attrs);
1509 int (*path_symlink) (struct path *dir, struct dentry *dentry,
1510 const char *old_name);
1511 int (*path_link) (struct dentry *old_dentry, struct path *new_dir,
1512 struct dentry *new_dentry);
1513 int (*path_rename) (struct path *old_dir, struct dentry *old_dentry,
1514 struct path *new_dir, struct dentry *new_dentry);
1515 int (*path_chmod) (struct dentry *dentry, struct vfsmount *mnt,
1516 mode_t mode);
1517 int (*path_chown) (struct path *path, uid_t uid, gid_t gid);
1518 int (*path_chroot) (struct path *path);
1519#endif
1520
1521 int (*inode_alloc_security) (struct inode *inode);
1522 void (*inode_free_security) (struct inode *inode);
1523 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1524 char **name, void **value, size_t *len);
1525 int (*inode_create) (struct inode *dir,
1526 struct dentry *dentry, int mode);
1527 int (*inode_link) (struct dentry *old_dentry,
1528 struct inode *dir, struct dentry *new_dentry);
1529 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1530 int (*inode_symlink) (struct inode *dir,
1531 struct dentry *dentry, const char *old_name);
1532 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
1533 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1534 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1535 int mode, dev_t dev);
1536 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1537 struct inode *new_dir, struct dentry *new_dentry);
1538 int (*inode_readlink) (struct dentry *dentry);
1539 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1540 int (*inode_permission) (struct inode *inode, int mask);
1541 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1542 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1543 void (*inode_delete) (struct inode *inode);
1544 int (*inode_setxattr) (struct dentry *dentry, const char *name,
1545 const void *value, size_t size, int flags);
1546 void (*inode_post_setxattr) (struct dentry *dentry, const char *name,
1547 const void *value, size_t size, int flags);
1548 int (*inode_getxattr) (struct dentry *dentry, const char *name);
1549 int (*inode_listxattr) (struct dentry *dentry);
1550 int (*inode_removexattr) (struct dentry *dentry, const char *name);
1551 int (*inode_need_killpriv) (struct dentry *dentry);
1552 int (*inode_killpriv) (struct dentry *dentry);
1553 int (*inode_getsecurity) (const struct inode *inode, const char *name, void **buffer, bool alloc);
1554 int (*inode_setsecurity) (struct inode *inode, const char *name, const void *value, size_t size, int flags);
1555 int (*inode_listsecurity) (struct inode *inode, char *buffer, size_t buffer_size);
1556 void (*inode_getsecid) (const struct inode *inode, u32 *secid);
1557
1558 int (*file_permission) (struct file *file, int mask);
1559 int (*file_alloc_security) (struct file *file);
1560 void (*file_free_security) (struct file *file);
1561 int (*file_ioctl) (struct file *file, unsigned int cmd,
1562 unsigned long arg);
1563 int (*file_mmap) (struct file *file,
1564 unsigned long reqprot, unsigned long prot,
1565 unsigned long flags, unsigned long addr,
1566 unsigned long addr_only);
1567 int (*file_mprotect) (struct vm_area_struct *vma,
1568 unsigned long reqprot,
1569 unsigned long prot);
1570 int (*file_lock) (struct file *file, unsigned int cmd);
1571 int (*file_fcntl) (struct file *file, unsigned int cmd,
1572 unsigned long arg);
1573 int (*file_set_fowner) (struct file *file);
1574 int (*file_send_sigiotask) (struct task_struct *tsk,
1575 struct fown_struct *fown, int sig);
1576 int (*file_receive) (struct file *file);
1577 int (*dentry_open) (struct file *file, const struct cred *cred);
1578
1579 int (*task_create) (unsigned long clone_flags);
1580 int (*cred_alloc_blank) (struct cred *cred, gfp_t gfp);
1581 void (*cred_free) (struct cred *cred);
1582 int (*cred_prepare)(struct cred *new, const struct cred *old,
1583 gfp_t gfp);
1584 void (*cred_commit)(struct cred *new, const struct cred *old);
1585 void (*cred_transfer)(struct cred *new, const struct cred *old);
1586 int (*kernel_act_as)(struct cred *new, u32 secid);
1587 int (*kernel_create_files_as)(struct cred *new, struct inode *inode);
1588 int (*kernel_module_request)(char *kmod_name);
1589 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1590 int (*task_fix_setuid) (struct cred *new, const struct cred *old,
1591 int flags);
1592 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1593 int (*task_setpgid) (struct task_struct *p, pid_t pgid);
1594 int (*task_getpgid) (struct task_struct *p);
1595 int (*task_getsid) (struct task_struct *p);
1596 void (*task_getsecid) (struct task_struct *p, u32 *secid);
1597 int (*task_setgroups) (struct group_info *group_info);
1598 int (*task_setnice) (struct task_struct *p, int nice);
1599 int (*task_setioprio) (struct task_struct *p, int ioprio);
1600 int (*task_getioprio) (struct task_struct *p);
1601 int (*task_setrlimit) (unsigned int resource, struct rlimit *new_rlim);
1602 int (*task_setscheduler) (struct task_struct *p, int policy,
1603 struct sched_param *lp);
1604 int (*task_getscheduler) (struct task_struct *p);
1605 int (*task_movememory) (struct task_struct *p);
1606 int (*task_kill) (struct task_struct *p,
1607 struct siginfo *info, int sig, u32 secid);
1608 int (*task_wait) (struct task_struct *p);
1609 int (*task_prctl) (int option, unsigned long arg2,
1610 unsigned long arg3, unsigned long arg4,
1611 unsigned long arg5);
1612 void (*task_to_inode) (struct task_struct *p, struct inode *inode);
1613
1614 int (*ipc_permission) (struct kern_ipc_perm *ipcp, short flag);
1615 void (*ipc_getsecid) (struct kern_ipc_perm *ipcp, u32 *secid);
1616
1617 int (*msg_msg_alloc_security) (struct msg_msg *msg);
1618 void (*msg_msg_free_security) (struct msg_msg *msg);
1619
1620 int (*msg_queue_alloc_security) (struct msg_queue *msq);
1621 void (*msg_queue_free_security) (struct msg_queue *msq);
1622 int (*msg_queue_associate) (struct msg_queue *msq, int msqflg);
1623 int (*msg_queue_msgctl) (struct msg_queue *msq, int cmd);
1624 int (*msg_queue_msgsnd) (struct msg_queue *msq,
1625 struct msg_msg *msg, int msqflg);
1626 int (*msg_queue_msgrcv) (struct msg_queue *msq,
1627 struct msg_msg *msg,
1628 struct task_struct *target,
1629 long type, int mode);
1630
1631 int (*shm_alloc_security) (struct shmid_kernel *shp);
1632 void (*shm_free_security) (struct shmid_kernel *shp);
1633 int (*shm_associate) (struct shmid_kernel *shp, int shmflg);
1634 int (*shm_shmctl) (struct shmid_kernel *shp, int cmd);
1635 int (*shm_shmat) (struct shmid_kernel *shp,
1636 char __user *shmaddr, int shmflg);
1637
1638 int (*sem_alloc_security) (struct sem_array *sma);
1639 void (*sem_free_security) (struct sem_array *sma);
1640 int (*sem_associate) (struct sem_array *sma, int semflg);
1641 int (*sem_semctl) (struct sem_array *sma, int cmd);
1642 int (*sem_semop) (struct sem_array *sma,
1643 struct sembuf *sops, unsigned nsops, int alter);
1644
1645 int (*netlink_send) (struct sock *sk, struct sk_buff *skb);
1646 int (*netlink_recv) (struct sk_buff *skb, int cap);
1647
1648 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1649
1650 int (*getprocattr) (struct task_struct *p, char *name, char **value);
1651 int (*setprocattr) (struct task_struct *p, char *name, void *value, size_t size);
1652 int (*secid_to_secctx) (u32 secid, char **secdata, u32 *seclen);
1653 int (*secctx_to_secid) (const char *secdata, u32 seclen, u32 *secid);
1654 void (*release_secctx) (char *secdata, u32 seclen);
1655
1656 int (*inode_notifysecctx)(struct inode *inode, void *ctx, u32 ctxlen);
1657 int (*inode_setsecctx)(struct dentry *dentry, void *ctx, u32 ctxlen);
1658 int (*inode_getsecctx)(struct inode *inode, void **ctx, u32 *ctxlen);
1659
1660#ifdef CONFIG_SECURITY_NETWORK
1661 int (*unix_stream_connect) (struct socket *sock,
1662 struct socket *other, struct sock *newsk);
1663 int (*unix_may_send) (struct socket *sock, struct socket *other);
1664
1665 int (*socket_create) (int family, int type, int protocol, int kern);
1666 int (*socket_post_create) (struct socket *sock, int family,
1667 int type, int protocol, int kern);
1668 int (*socket_bind) (struct socket *sock,
1669 struct sockaddr *address, int addrlen);
1670 int (*socket_connect) (struct socket *sock,
1671 struct sockaddr *address, int addrlen);
1672 int (*socket_listen) (struct socket *sock, int backlog);
1673 int (*socket_accept) (struct socket *sock, struct socket *newsock);
1674 int (*socket_sendmsg) (struct socket *sock,
1675 struct msghdr *msg, int size);
1676 int (*socket_recvmsg) (struct socket *sock,
1677 struct msghdr *msg, int size, int flags);
1678 int (*socket_getsockname) (struct socket *sock);
1679 int (*socket_getpeername) (struct socket *sock);
1680 int (*socket_getsockopt) (struct socket *sock, int level, int optname);
1681 int (*socket_setsockopt) (struct socket *sock, int level, int optname);
1682 int (*socket_shutdown) (struct socket *sock, int how);
1683 int (*socket_sock_rcv_skb) (struct sock *sk, struct sk_buff *skb);
1684 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1685 int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
1686 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
1687 void (*sk_free_security) (struct sock *sk);
1688 void (*sk_clone_security) (const struct sock *sk, struct sock *newsk);
1689 void (*sk_getsecid) (struct sock *sk, u32 *secid);
1690 void (*sock_graft) (struct sock *sk, struct socket *parent);
1691 int (*inet_conn_request) (struct sock *sk, struct sk_buff *skb,
1692 struct request_sock *req);
1693 void (*inet_csk_clone) (struct sock *newsk, const struct request_sock *req);
1694 void (*inet_conn_established) (struct sock *sk, struct sk_buff *skb);
1695 void (*req_classify_flow) (const struct request_sock *req, struct flowi *fl);
1696 int (*tun_dev_create)(void);
1697 void (*tun_dev_post_create)(struct sock *sk);
1698 int (*tun_dev_attach)(struct sock *sk);
1699#endif
1700
1701#ifdef CONFIG_SECURITY_NETWORK_XFRM
1702 int (*xfrm_policy_alloc_security) (struct xfrm_sec_ctx **ctxp,
1703 struct xfrm_user_sec_ctx *sec_ctx);
1704 int (*xfrm_policy_clone_security) (struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctx);
1705 void (*xfrm_policy_free_security) (struct xfrm_sec_ctx *ctx);
1706 int (*xfrm_policy_delete_security) (struct xfrm_sec_ctx *ctx);
1707 int (*xfrm_state_alloc_security) (struct xfrm_state *x,
1708 struct xfrm_user_sec_ctx *sec_ctx,
1709 u32 secid);
1710 void (*xfrm_state_free_security) (struct xfrm_state *x);
1711 int (*xfrm_state_delete_security) (struct xfrm_state *x);
1712 int (*xfrm_policy_lookup) (struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
1713 int (*xfrm_state_pol_flow_match) (struct xfrm_state *x,
1714 struct xfrm_policy *xp,
1715 struct flowi *fl);
1716 int (*xfrm_decode_session) (struct sk_buff *skb, u32 *secid, int ckall);
1717#endif
1718
1719
1720#ifdef CONFIG_KEYS
1721 int (*key_alloc) (struct key *key, const struct cred *cred, unsigned long flags);
1722 void (*key_free) (struct key *key);
1723 int (*key_permission) (key_ref_t key_ref,
1724 const struct cred *cred,
1725 key_perm_t perm);
1726 int (*key_getsecurity)(struct key *key, char **_buffer);
1727 int (*key_session_to_parent)(const struct cred *cred,
1728 const struct cred *parent_cred,
1729 struct key *key);
1730#endif
1731
1732#ifdef CONFIG_AUDIT
1733 int (*audit_rule_init) (u32 field, u32 op, char *rulestr, void **lsmrule);
1734 int (*audit_rule_known) (struct audit_krule *krule);
1735 int (*audit_rule_match) (u32 secid, u32 field, u32 op, void *lsmrule,
1736 struct audit_context *actx);
1737 void (*audit_rule_free) (void *lsmrule);
1738#endif
1739};
1740
1741
1742extern int security_init(void);
1743extern int security_module_enable(struct security_operations *ops);
1744extern int register_security(struct security_operations *ops);
1745
1746
1747int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
1748int security_ptrace_traceme(struct task_struct *parent);
1749int security_capget(struct task_struct *target,
1750 kernel_cap_t *effective,
1751 kernel_cap_t *inheritable,
1752 kernel_cap_t *permitted);
1753int security_capset(struct cred *new, const struct cred *old,
1754 const kernel_cap_t *effective,
1755 const kernel_cap_t *inheritable,
1756 const kernel_cap_t *permitted);
1757int security_capable(int cap);
1758int security_real_capable(struct task_struct *tsk, int cap);
1759int security_real_capable_noaudit(struct task_struct *tsk, int cap);
1760int security_acct(struct file *file);
1761int security_sysctl(struct ctl_table *table, int op);
1762int security_quotactl(int cmds, int type, int id, struct super_block *sb);
1763int security_quota_on(struct dentry *dentry);
1764int security_syslog(int type);
1765int security_settime(struct timespec *ts, struct timezone *tz);
1766int security_vm_enough_memory(long pages);
1767int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
1768int security_vm_enough_memory_kern(long pages);
1769int security_bprm_set_creds(struct linux_binprm *bprm);
1770int security_bprm_check(struct linux_binprm *bprm);
1771void security_bprm_committing_creds(struct linux_binprm *bprm);
1772void security_bprm_committed_creds(struct linux_binprm *bprm);
1773int security_bprm_secureexec(struct linux_binprm *bprm);
1774int security_sb_alloc(struct super_block *sb);
1775void security_sb_free(struct super_block *sb);
1776int security_sb_copy_data(char *orig, char *copy);
1777int security_sb_kern_mount(struct super_block *sb, int flags, void *data);
1778int security_sb_show_options(struct seq_file *m, struct super_block *sb);
1779int security_sb_statfs(struct dentry *dentry);
1780int security_sb_mount(char *dev_name, struct path *path,
1781 char *type, unsigned long flags, void *data);
1782int security_sb_check_sb(struct vfsmount *mnt, struct path *path);
1783int security_sb_umount(struct vfsmount *mnt, int flags);
1784void security_sb_umount_close(struct vfsmount *mnt);
1785void security_sb_umount_busy(struct vfsmount *mnt);
1786void security_sb_post_remount(struct vfsmount *mnt, unsigned long flags, void *data);
1787void security_sb_post_addmount(struct vfsmount *mnt, struct path *mountpoint);
1788int security_sb_pivotroot(struct path *old_path, struct path *new_path);
1789void security_sb_post_pivotroot(struct path *old_path, struct path *new_path);
1790int security_sb_set_mnt_opts(struct super_block *sb, struct security_mnt_opts *opts);
1791void security_sb_clone_mnt_opts(const struct super_block *oldsb,
1792 struct super_block *newsb);
1793int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts);
1794
1795int security_inode_alloc(struct inode *inode);
1796void security_inode_free(struct inode *inode);
1797int security_inode_init_security(struct inode *inode, struct inode *dir,
1798 char **name, void **value, size_t *len);
1799int security_inode_create(struct inode *dir, struct dentry *dentry, int mode);
1800int security_inode_link(struct dentry *old_dentry, struct inode *dir,
1801 struct dentry *new_dentry);
1802int security_inode_unlink(struct inode *dir, struct dentry *dentry);
1803int security_inode_symlink(struct inode *dir, struct dentry *dentry,
1804 const char *old_name);
1805int security_inode_mkdir(struct inode *dir, struct dentry *dentry, int mode);
1806int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
1807int security_inode_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev);
1808int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
1809 struct inode *new_dir, struct dentry *new_dentry);
1810int security_inode_readlink(struct dentry *dentry);
1811int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
1812int security_inode_permission(struct inode *inode, int mask);
1813int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
1814int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry);
1815void security_inode_delete(struct inode *inode);
1816int security_inode_setxattr(struct dentry *dentry, const char *name,
1817 const void *value, size_t size, int flags);
1818void security_inode_post_setxattr(struct dentry *dentry, const char *name,
1819 const void *value, size_t size, int flags);
1820int security_inode_getxattr(struct dentry *dentry, const char *name);
1821int security_inode_listxattr(struct dentry *dentry);
1822int security_inode_removexattr(struct dentry *dentry, const char *name);
1823int security_inode_need_killpriv(struct dentry *dentry);
1824int security_inode_killpriv(struct dentry *dentry);
1825int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc);
1826int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1827int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
1828void security_inode_getsecid(const struct inode *inode, u32 *secid);
1829int security_file_permission(struct file *file, int mask);
1830int security_file_alloc(struct file *file);
1831void security_file_free(struct file *file);
1832int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1833int security_file_mmap(struct file *file, unsigned long reqprot,
1834 unsigned long prot, unsigned long flags,
1835 unsigned long addr, unsigned long addr_only);
1836int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
1837 unsigned long prot);
1838int security_file_lock(struct file *file, unsigned int cmd);
1839int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
1840int security_file_set_fowner(struct file *file);
1841int security_file_send_sigiotask(struct task_struct *tsk,
1842 struct fown_struct *fown, int sig);
1843int security_file_receive(struct file *file);
1844int security_dentry_open(struct file *file, const struct cred *cred);
1845int security_task_create(unsigned long clone_flags);
1846int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
1847void security_cred_free(struct cred *cred);
1848int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
1849void security_commit_creds(struct cred *new, const struct cred *old);
1850void security_transfer_creds(struct cred *new, const struct cred *old);
1851int security_kernel_act_as(struct cred *new, u32 secid);
1852int security_kernel_create_files_as(struct cred *new, struct inode *inode);
1853int security_kernel_module_request(char *kmod_name);
1854int security_task_setuid(uid_t id0, uid_t id1, uid_t id2, int flags);
1855int security_task_fix_setuid(struct cred *new, const struct cred *old,
1856 int flags);
1857int security_task_setgid(gid_t id0, gid_t id1, gid_t id2, int flags);
1858int security_task_setpgid(struct task_struct *p, pid_t pgid);
1859int security_task_getpgid(struct task_struct *p);
1860int security_task_getsid(struct task_struct *p);
1861void security_task_getsecid(struct task_struct *p, u32 *secid);
1862int security_task_setgroups(struct group_info *group_info);
1863int security_task_setnice(struct task_struct *p, int nice);
1864int security_task_setioprio(struct task_struct *p, int ioprio);
1865int security_task_getioprio(struct task_struct *p);
1866int security_task_setrlimit(unsigned int resource, struct rlimit *new_rlim);
1867int security_task_setscheduler(struct task_struct *p,
1868 int policy, struct sched_param *lp);
1869int security_task_getscheduler(struct task_struct *p);
1870int security_task_movememory(struct task_struct *p);
1871int security_task_kill(struct task_struct *p, struct siginfo *info,
1872 int sig, u32 secid);
1873int security_task_wait(struct task_struct *p);
1874int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
1875 unsigned long arg4, unsigned long arg5);
1876void security_task_to_inode(struct task_struct *p, struct inode *inode);
1877int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
1878void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
1879int security_msg_msg_alloc(struct msg_msg *msg);
1880void security_msg_msg_free(struct msg_msg *msg);
1881int security_msg_queue_alloc(struct msg_queue *msq);
1882void security_msg_queue_free(struct msg_queue *msq);
1883int security_msg_queue_associate(struct msg_queue *msq, int msqflg);
1884int security_msg_queue_msgctl(struct msg_queue *msq, int cmd);
1885int security_msg_queue_msgsnd(struct msg_queue *msq,
1886 struct msg_msg *msg, int msqflg);
1887int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
1888 struct task_struct *target, long type, int mode);
1889int security_shm_alloc(struct shmid_kernel *shp);
1890void security_shm_free(struct shmid_kernel *shp);
1891int security_shm_associate(struct shmid_kernel *shp, int shmflg);
1892int security_shm_shmctl(struct shmid_kernel *shp, int cmd);
1893int security_shm_shmat(struct shmid_kernel *shp, char __user *shmaddr, int shmflg);
1894int security_sem_alloc(struct sem_array *sma);
1895void security_sem_free(struct sem_array *sma);
1896int security_sem_associate(struct sem_array *sma, int semflg);
1897int security_sem_semctl(struct sem_array *sma, int cmd);
1898int security_sem_semop(struct sem_array *sma, struct sembuf *sops,
1899 unsigned nsops, int alter);
1900void security_d_instantiate(struct dentry *dentry, struct inode *inode);
1901int security_getprocattr(struct task_struct *p, char *name, char **value);
1902int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size);
1903int security_netlink_send(struct sock *sk, struct sk_buff *skb);
1904int security_netlink_recv(struct sk_buff *skb, int cap);
1905int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
1906int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
1907void security_release_secctx(char *secdata, u32 seclen);
1908
1909int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
1910int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
1911int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
1912#else
1913struct security_mnt_opts {
1914};
1915
1916static inline void security_init_mnt_opts(struct security_mnt_opts *opts)
1917{
1918}
1919
1920static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
1921{
1922}
1923
1924
1925
1926
1927
1928
1929static inline int security_init(void)
1930{
1931 return 0;
1932}
1933
1934static inline int security_ptrace_access_check(struct task_struct *child,
1935 unsigned int mode)
1936{
1937 return cap_ptrace_access_check(child, mode);
1938}
1939
1940static inline int security_ptrace_traceme(struct task_struct *parent)
1941{
1942 return cap_ptrace_traceme(parent);
1943}
1944
1945static inline int security_capget(struct task_struct *target,
1946 kernel_cap_t *effective,
1947 kernel_cap_t *inheritable,
1948 kernel_cap_t *permitted)
1949{
1950 return cap_capget(target, effective, inheritable, permitted);
1951}
1952
1953static inline int security_capset(struct cred *new,
1954 const struct cred *old,
1955 const kernel_cap_t *effective,
1956 const kernel_cap_t *inheritable,
1957 const kernel_cap_t *permitted)
1958{
1959 return cap_capset(new, old, effective, inheritable, permitted);
1960}
1961
1962static inline int security_capable(int cap)
1963{
1964 return cap_capable(current, current_cred(), cap, SECURITY_CAP_AUDIT);
1965}
1966
1967static inline int security_real_capable(struct task_struct *tsk, int cap)
1968{
1969 int ret;
1970
1971 rcu_read_lock();
1972 ret = cap_capable(tsk, __task_cred(tsk), cap, SECURITY_CAP_AUDIT);
1973 rcu_read_unlock();
1974 return ret;
1975}
1976
1977static inline
1978int security_real_capable_noaudit(struct task_struct *tsk, int cap)
1979{
1980 int ret;
1981
1982 rcu_read_lock();
1983 ret = cap_capable(tsk, __task_cred(tsk), cap,
1984 SECURITY_CAP_NOAUDIT);
1985 rcu_read_unlock();
1986 return ret;
1987}
1988
1989static inline int security_acct(struct file *file)
1990{
1991 return 0;
1992}
1993
1994static inline int security_sysctl(struct ctl_table *table, int op)
1995{
1996 return 0;
1997}
1998
1999static inline int security_quotactl(int cmds, int type, int id,
2000 struct super_block *sb)
2001{
2002 return 0;
2003}
2004
2005static inline int security_quota_on(struct dentry *dentry)
2006{
2007 return 0;
2008}
2009
2010static inline int security_syslog(int type)
2011{
2012 return cap_syslog(type);
2013}
2014
2015static inline int security_settime(struct timespec *ts, struct timezone *tz)
2016{
2017 return cap_settime(ts, tz);
2018}
2019
2020static inline int security_vm_enough_memory(long pages)
2021{
2022 WARN_ON(current->mm == NULL);
2023 return cap_vm_enough_memory(current->mm, pages);
2024}
2025
2026static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
2027{
2028 WARN_ON(mm == NULL);
2029 return cap_vm_enough_memory(mm, pages);
2030}
2031
2032static inline int security_vm_enough_memory_kern(long pages)
2033{
2034
2035
2036 return cap_vm_enough_memory(current->mm, pages);
2037}
2038
2039static inline int security_bprm_set_creds(struct linux_binprm *bprm)
2040{
2041 return cap_bprm_set_creds(bprm);
2042}
2043
2044static inline int security_bprm_check(struct linux_binprm *bprm)
2045{
2046 return 0;
2047}
2048
2049static inline void security_bprm_committing_creds(struct linux_binprm *bprm)
2050{
2051}
2052
2053static inline void security_bprm_committed_creds(struct linux_binprm *bprm)
2054{
2055}
2056
2057static inline int security_bprm_secureexec(struct linux_binprm *bprm)
2058{
2059 return cap_bprm_secureexec(bprm);
2060}
2061
2062static inline int security_sb_alloc(struct super_block *sb)
2063{
2064 return 0;
2065}
2066
2067static inline void security_sb_free(struct super_block *sb)
2068{ }
2069
2070static inline int security_sb_copy_data(char *orig, char *copy)
2071{
2072 return 0;
2073}
2074
2075static inline int security_sb_kern_mount(struct super_block *sb, int flags, void *data)
2076{
2077 return 0;
2078}
2079
2080static inline int security_sb_show_options(struct seq_file *m,
2081 struct super_block *sb)
2082{
2083 return 0;
2084}
2085
2086static inline int security_sb_statfs(struct dentry *dentry)
2087{
2088 return 0;
2089}
2090
2091static inline int security_sb_mount(char *dev_name, struct path *path,
2092 char *type, unsigned long flags,
2093 void *data)
2094{
2095 return 0;
2096}
2097
2098static inline int security_sb_check_sb(struct vfsmount *mnt,
2099 struct path *path)
2100{
2101 return 0;
2102}
2103
2104static inline int security_sb_umount(struct vfsmount *mnt, int flags)
2105{
2106 return 0;
2107}
2108
2109static inline void security_sb_umount_close(struct vfsmount *mnt)
2110{ }
2111
2112static inline void security_sb_umount_busy(struct vfsmount *mnt)
2113{ }
2114
2115static inline void security_sb_post_remount(struct vfsmount *mnt,
2116 unsigned long flags, void *data)
2117{ }
2118
2119static inline void security_sb_post_addmount(struct vfsmount *mnt,
2120 struct path *mountpoint)
2121{ }
2122
2123static inline int security_sb_pivotroot(struct path *old_path,
2124 struct path *new_path)
2125{
2126 return 0;
2127}
2128
2129static inline void security_sb_post_pivotroot(struct path *old_path,
2130 struct path *new_path)
2131{ }
2132
2133static inline int security_sb_set_mnt_opts(struct super_block *sb,
2134 struct security_mnt_opts *opts)
2135{
2136 return 0;
2137}
2138
2139static inline void security_sb_clone_mnt_opts(const struct super_block *oldsb,
2140 struct super_block *newsb)
2141{ }
2142
2143static inline int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts)
2144{
2145 return 0;
2146}
2147
2148static inline int security_inode_alloc(struct inode *inode)
2149{
2150 return 0;
2151}
2152
2153static inline void security_inode_free(struct inode *inode)
2154{ }
2155
2156static inline int security_inode_init_security(struct inode *inode,
2157 struct inode *dir,
2158 char **name,
2159 void **value,
2160 size_t *len)
2161{
2162 return -EOPNOTSUPP;
2163}
2164
2165static inline int security_inode_create(struct inode *dir,
2166 struct dentry *dentry,
2167 int mode)
2168{
2169 return 0;
2170}
2171
2172static inline int security_inode_link(struct dentry *old_dentry,
2173 struct inode *dir,
2174 struct dentry *new_dentry)
2175{
2176 return 0;
2177}
2178
2179static inline int security_inode_unlink(struct inode *dir,
2180 struct dentry *dentry)
2181{
2182 return 0;
2183}
2184
2185static inline int security_inode_symlink(struct inode *dir,
2186 struct dentry *dentry,
2187 const char *old_name)
2188{
2189 return 0;
2190}
2191
2192static inline int security_inode_mkdir(struct inode *dir,
2193 struct dentry *dentry,
2194 int mode)
2195{
2196 return 0;
2197}
2198
2199static inline int security_inode_rmdir(struct inode *dir,
2200 struct dentry *dentry)
2201{
2202 return 0;
2203}
2204
2205static inline int security_inode_mknod(struct inode *dir,
2206 struct dentry *dentry,
2207 int mode, dev_t dev)
2208{
2209 return 0;
2210}
2211
2212static inline int security_inode_rename(struct inode *old_dir,
2213 struct dentry *old_dentry,
2214 struct inode *new_dir,
2215 struct dentry *new_dentry)
2216{
2217 return 0;
2218}
2219
2220static inline int security_inode_readlink(struct dentry *dentry)
2221{
2222 return 0;
2223}
2224
2225static inline int security_inode_follow_link(struct dentry *dentry,
2226 struct nameidata *nd)
2227{
2228 return 0;
2229}
2230
2231static inline int security_inode_permission(struct inode *inode, int mask)
2232{
2233 return 0;
2234}
2235
2236static inline int security_inode_setattr(struct dentry *dentry,
2237 struct iattr *attr)
2238{
2239 return 0;
2240}
2241
2242static inline int security_inode_getattr(struct vfsmount *mnt,
2243 struct dentry *dentry)
2244{
2245 return 0;
2246}
2247
2248static inline void security_inode_delete(struct inode *inode)
2249{ }
2250
2251static inline int security_inode_setxattr(struct dentry *dentry,
2252 const char *name, const void *value, size_t size, int flags)
2253{
2254 return cap_inode_setxattr(dentry, name, value, size, flags);
2255}
2256
2257static inline void security_inode_post_setxattr(struct dentry *dentry,
2258 const char *name, const void *value, size_t size, int flags)
2259{ }
2260
2261static inline int security_inode_getxattr(struct dentry *dentry,
2262 const char *name)
2263{
2264 return 0;
2265}
2266
2267static inline int security_inode_listxattr(struct dentry *dentry)
2268{
2269 return 0;
2270}
2271
2272static inline int security_inode_removexattr(struct dentry *dentry,
2273 const char *name)
2274{
2275 return cap_inode_removexattr(dentry, name);
2276}
2277
2278static inline int security_inode_need_killpriv(struct dentry *dentry)
2279{
2280 return cap_inode_need_killpriv(dentry);
2281}
2282
2283static inline int security_inode_killpriv(struct dentry *dentry)
2284{
2285 return cap_inode_killpriv(dentry);
2286}
2287
2288static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc)
2289{
2290 return -EOPNOTSUPP;
2291}
2292
2293static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2294{
2295 return -EOPNOTSUPP;
2296}
2297
2298static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2299{
2300 return 0;
2301}
2302
2303static inline void security_inode_getsecid(const struct inode *inode, u32 *secid)
2304{
2305 *secid = 0;
2306}
2307
2308static inline int security_file_permission(struct file *file, int mask)
2309{
2310 return 0;
2311}
2312
2313static inline int security_file_alloc(struct file *file)
2314{
2315 return 0;
2316}
2317
2318static inline void security_file_free(struct file *file)
2319{ }
2320
2321static inline int security_file_ioctl(struct file *file, unsigned int cmd,
2322 unsigned long arg)
2323{
2324 return 0;
2325}
2326
2327static inline int security_file_mmap(struct file *file, unsigned long reqprot,
2328 unsigned long prot,
2329 unsigned long flags,
2330 unsigned long addr,
2331 unsigned long addr_only)
2332{
2333 return cap_file_mmap(file, reqprot, prot, flags, addr, addr_only);
2334}
2335
2336static inline int security_file_mprotect(struct vm_area_struct *vma,
2337 unsigned long reqprot,
2338 unsigned long prot)
2339{
2340 return 0;
2341}
2342
2343static inline int security_file_lock(struct file *file, unsigned int cmd)
2344{
2345 return 0;
2346}
2347
2348static inline int security_file_fcntl(struct file *file, unsigned int cmd,
2349 unsigned long arg)
2350{
2351 return 0;
2352}
2353
2354static inline int security_file_set_fowner(struct file *file)
2355{
2356 return 0;
2357}
2358
2359static inline int security_file_send_sigiotask(struct task_struct *tsk,
2360 struct fown_struct *fown,
2361 int sig)
2362{
2363 return 0;
2364}
2365
2366static inline int security_file_receive(struct file *file)
2367{
2368 return 0;
2369}
2370
2371static inline int security_dentry_open(struct file *file,
2372 const struct cred *cred)
2373{
2374 return 0;
2375}
2376
2377static inline int security_task_create(unsigned long clone_flags)
2378{
2379 return 0;
2380}
2381
2382static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
2383{
2384 return 0;
2385}
2386
2387static inline void security_cred_free(struct cred *cred)
2388{ }
2389
2390static inline int security_prepare_creds(struct cred *new,
2391 const struct cred *old,
2392 gfp_t gfp)
2393{
2394 return 0;
2395}
2396
2397static inline void security_commit_creds(struct cred *new,
2398 const struct cred *old)
2399{
2400}
2401
2402static inline void security_transfer_creds(struct cred *new,
2403 const struct cred *old)
2404{
2405}
2406
2407static inline int security_kernel_act_as(struct cred *cred, u32 secid)
2408{
2409 return 0;
2410}
2411
2412static inline int security_kernel_create_files_as(struct cred *cred,
2413 struct inode *inode)
2414{
2415 return 0;
2416}
2417
2418static inline int security_kernel_module_request(char *kmod_name)
2419{
2420 return 0;
2421}
2422
2423static inline int security_task_setuid(uid_t id0, uid_t id1, uid_t id2,
2424 int flags)
2425{
2426 return 0;
2427}
2428
2429static inline int security_task_fix_setuid(struct cred *new,
2430 const struct cred *old,
2431 int flags)
2432{
2433 return cap_task_fix_setuid(new, old, flags);
2434}
2435
2436static inline int security_task_setgid(gid_t id0, gid_t id1, gid_t id2,
2437 int flags)
2438{
2439 return 0;
2440}
2441
2442static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
2443{
2444 return 0;
2445}
2446
2447static inline int security_task_getpgid(struct task_struct *p)
2448{
2449 return 0;
2450}
2451
2452static inline int security_task_getsid(struct task_struct *p)
2453{
2454 return 0;
2455}
2456
2457static inline void security_task_getsecid(struct task_struct *p, u32 *secid)
2458{
2459 *secid = 0;
2460}
2461
2462static inline int security_task_setgroups(struct group_info *group_info)
2463{
2464 return 0;
2465}
2466
2467static inline int security_task_setnice(struct task_struct *p, int nice)
2468{
2469 return cap_task_setnice(p, nice);
2470}
2471
2472static inline int security_task_setioprio(struct task_struct *p, int ioprio)
2473{
2474 return cap_task_setioprio(p, ioprio);
2475}
2476
2477static inline int security_task_getioprio(struct task_struct *p)
2478{
2479 return 0;
2480}
2481
2482static inline int security_task_setrlimit(unsigned int resource,
2483 struct rlimit *new_rlim)
2484{
2485 return 0;
2486}
2487
2488static inline int security_task_setscheduler(struct task_struct *p,
2489 int policy,
2490 struct sched_param *lp)
2491{
2492 return cap_task_setscheduler(p, policy, lp);
2493}
2494
2495static inline int security_task_getscheduler(struct task_struct *p)
2496{
2497 return 0;
2498}
2499
2500static inline int security_task_movememory(struct task_struct *p)
2501{
2502 return 0;
2503}
2504
2505static inline int security_task_kill(struct task_struct *p,
2506 struct siginfo *info, int sig,
2507 u32 secid)
2508{
2509 return 0;
2510}
2511
2512static inline int security_task_wait(struct task_struct *p)
2513{
2514 return 0;
2515}
2516
2517static inline int security_task_prctl(int option, unsigned long arg2,
2518 unsigned long arg3,
2519 unsigned long arg4,
2520 unsigned long arg5)
2521{
2522 return cap_task_prctl(option, arg2, arg3, arg3, arg5);
2523}
2524
2525static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2526{ }
2527
2528static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
2529 short flag)
2530{
2531 return 0;
2532}
2533
2534static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
2535{
2536 *secid = 0;
2537}
2538
2539static inline int security_msg_msg_alloc(struct msg_msg *msg)
2540{
2541 return 0;
2542}
2543
2544static inline void security_msg_msg_free(struct msg_msg *msg)
2545{ }
2546
2547static inline int security_msg_queue_alloc(struct msg_queue *msq)
2548{
2549 return 0;
2550}
2551
2552static inline void security_msg_queue_free(struct msg_queue *msq)
2553{ }
2554
2555static inline int security_msg_queue_associate(struct msg_queue *msq,
2556 int msqflg)
2557{
2558 return 0;
2559}
2560
2561static inline int security_msg_queue_msgctl(struct msg_queue *msq, int cmd)
2562{
2563 return 0;
2564}
2565
2566static inline int security_msg_queue_msgsnd(struct msg_queue *msq,
2567 struct msg_msg *msg, int msqflg)
2568{
2569 return 0;
2570}
2571
2572static inline int security_msg_queue_msgrcv(struct msg_queue *msq,
2573 struct msg_msg *msg,
2574 struct task_struct *target,
2575 long type, int mode)
2576{
2577 return 0;
2578}
2579
2580static inline int security_shm_alloc(struct shmid_kernel *shp)
2581{
2582 return 0;
2583}
2584
2585static inline void security_shm_free(struct shmid_kernel *shp)
2586{ }
2587
2588static inline int security_shm_associate(struct shmid_kernel *shp,
2589 int shmflg)
2590{
2591 return 0;
2592}
2593
2594static inline int security_shm_shmctl(struct shmid_kernel *shp, int cmd)
2595{
2596 return 0;
2597}
2598
2599static inline int security_shm_shmat(struct shmid_kernel *shp,
2600 char __user *shmaddr, int shmflg)
2601{
2602 return 0;
2603}
2604
2605static inline int security_sem_alloc(struct sem_array *sma)
2606{
2607 return 0;
2608}
2609
2610static inline void security_sem_free(struct sem_array *sma)
2611{ }
2612
2613static inline int security_sem_associate(struct sem_array *sma, int semflg)
2614{
2615 return 0;
2616}
2617
2618static inline int security_sem_semctl(struct sem_array *sma, int cmd)
2619{
2620 return 0;
2621}
2622
2623static inline int security_sem_semop(struct sem_array *sma,
2624 struct sembuf *sops, unsigned nsops,
2625 int alter)
2626{
2627 return 0;
2628}
2629
2630static inline void security_d_instantiate(struct dentry *dentry, struct inode *inode)
2631{ }
2632
2633static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
2634{
2635 return -EINVAL;
2636}
2637
2638static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2639{
2640 return -EINVAL;
2641}
2642
2643static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
2644{
2645 return cap_netlink_send(sk, skb);
2646}
2647
2648static inline int security_netlink_recv(struct sk_buff *skb, int cap)
2649{
2650 return cap_netlink_recv(skb, cap);
2651}
2652
2653static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2654{
2655 return -EOPNOTSUPP;
2656}
2657
2658static inline int security_secctx_to_secid(const char *secdata,
2659 u32 seclen,
2660 u32 *secid)
2661{
2662 return -EOPNOTSUPP;
2663}
2664
2665static inline void security_release_secctx(char *secdata, u32 seclen)
2666{
2667}
2668
2669static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
2670{
2671 return -EOPNOTSUPP;
2672}
2673static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
2674{
2675 return -EOPNOTSUPP;
2676}
2677static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
2678{
2679 return -EOPNOTSUPP;
2680}
2681#endif
2682
2683#ifdef CONFIG_SECURITY_NETWORK
2684
2685int security_unix_stream_connect(struct socket *sock, struct socket *other,
2686 struct sock *newsk);
2687int security_unix_may_send(struct socket *sock, struct socket *other);
2688int security_socket_create(int family, int type, int protocol, int kern);
2689int security_socket_post_create(struct socket *sock, int family,
2690 int type, int protocol, int kern);
2691int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
2692int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
2693int security_socket_listen(struct socket *sock, int backlog);
2694int security_socket_accept(struct socket *sock, struct socket *newsock);
2695int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
2696int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
2697 int size, int flags);
2698int security_socket_getsockname(struct socket *sock);
2699int security_socket_getpeername(struct socket *sock);
2700int security_socket_getsockopt(struct socket *sock, int level, int optname);
2701int security_socket_setsockopt(struct socket *sock, int level, int optname);
2702int security_socket_shutdown(struct socket *sock, int how);
2703int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
2704int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2705 int __user *optlen, unsigned len);
2706int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
2707int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
2708void security_sk_free(struct sock *sk);
2709void security_sk_clone(const struct sock *sk, struct sock *newsk);
2710void security_sk_classify_flow(struct sock *sk, struct flowi *fl);
2711void security_req_classify_flow(const struct request_sock *req, struct flowi *fl);
2712void security_sock_graft(struct sock*sk, struct socket *parent);
2713int security_inet_conn_request(struct sock *sk,
2714 struct sk_buff *skb, struct request_sock *req);
2715void security_inet_csk_clone(struct sock *newsk,
2716 const struct request_sock *req);
2717void security_inet_conn_established(struct sock *sk,
2718 struct sk_buff *skb);
2719int security_tun_dev_create(void);
2720void security_tun_dev_post_create(struct sock *sk);
2721int security_tun_dev_attach(struct sock *sk);
2722
2723#else
2724static inline int security_unix_stream_connect(struct socket *sock,
2725 struct socket *other,
2726 struct sock *newsk)
2727{
2728 return 0;
2729}
2730
2731static inline int security_unix_may_send(struct socket *sock,
2732 struct socket *other)
2733{
2734 return 0;
2735}
2736
2737static inline int security_socket_create(int family, int type,
2738 int protocol, int kern)
2739{
2740 return 0;
2741}
2742
2743static inline int security_socket_post_create(struct socket *sock,
2744 int family,
2745 int type,
2746 int protocol, int kern)
2747{
2748 return 0;
2749}
2750
2751static inline int security_socket_bind(struct socket *sock,
2752 struct sockaddr *address,
2753 int addrlen)
2754{
2755 return 0;
2756}
2757
2758static inline int security_socket_connect(struct socket *sock,
2759 struct sockaddr *address,
2760 int addrlen)
2761{
2762 return 0;
2763}
2764
2765static inline int security_socket_listen(struct socket *sock, int backlog)
2766{
2767 return 0;
2768}
2769
2770static inline int security_socket_accept(struct socket *sock,
2771 struct socket *newsock)
2772{
2773 return 0;
2774}
2775
2776static inline int security_socket_sendmsg(struct socket *sock,
2777 struct msghdr *msg, int size)
2778{
2779 return 0;
2780}
2781
2782static inline int security_socket_recvmsg(struct socket *sock,
2783 struct msghdr *msg, int size,
2784 int flags)
2785{
2786 return 0;
2787}
2788
2789static inline int security_socket_getsockname(struct socket *sock)
2790{
2791 return 0;
2792}
2793
2794static inline int security_socket_getpeername(struct socket *sock)
2795{
2796 return 0;
2797}
2798
2799static inline int security_socket_getsockopt(struct socket *sock,
2800 int level, int optname)
2801{
2802 return 0;
2803}
2804
2805static inline int security_socket_setsockopt(struct socket *sock,
2806 int level, int optname)
2807{
2808 return 0;
2809}
2810
2811static inline int security_socket_shutdown(struct socket *sock, int how)
2812{
2813 return 0;
2814}
2815static inline int security_sock_rcv_skb(struct sock *sk,
2816 struct sk_buff *skb)
2817{
2818 return 0;
2819}
2820
2821static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2822 int __user *optlen, unsigned len)
2823{
2824 return -ENOPROTOOPT;
2825}
2826
2827static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
2828{
2829 return -ENOPROTOOPT;
2830}
2831
2832static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
2833{
2834 return 0;
2835}
2836
2837static inline void security_sk_free(struct sock *sk)
2838{
2839}
2840
2841static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
2842{
2843}
2844
2845static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
2846{
2847}
2848
2849static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
2850{
2851}
2852
2853static inline void security_sock_graft(struct sock *sk, struct socket *parent)
2854{
2855}
2856
2857static inline int security_inet_conn_request(struct sock *sk,
2858 struct sk_buff *skb, struct request_sock *req)
2859{
2860 return 0;
2861}
2862
2863static inline void security_inet_csk_clone(struct sock *newsk,
2864 const struct request_sock *req)
2865{
2866}
2867
2868static inline void security_inet_conn_established(struct sock *sk,
2869 struct sk_buff *skb)
2870{
2871}
2872
2873static inline int security_tun_dev_create(void)
2874{
2875 return 0;
2876}
2877
2878static inline void security_tun_dev_post_create(struct sock *sk)
2879{
2880}
2881
2882static inline int security_tun_dev_attach(struct sock *sk)
2883{
2884 return 0;
2885}
2886#endif
2887
2888#ifdef CONFIG_SECURITY_NETWORK_XFRM
2889
2890int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, struct xfrm_user_sec_ctx *sec_ctx);
2891int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
2892void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
2893int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
2894int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
2895int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2896 struct xfrm_sec_ctx *polsec, u32 secid);
2897int security_xfrm_state_delete(struct xfrm_state *x);
2898void security_xfrm_state_free(struct xfrm_state *x);
2899int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
2900int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2901 struct xfrm_policy *xp, struct flowi *fl);
2902int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
2903void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl);
2904
2905#else
2906
2907static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp, struct xfrm_user_sec_ctx *sec_ctx)
2908{
2909 return 0;
2910}
2911
2912static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
2913{
2914 return 0;
2915}
2916
2917static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
2918{
2919}
2920
2921static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
2922{
2923 return 0;
2924}
2925
2926static inline int security_xfrm_state_alloc(struct xfrm_state *x,
2927 struct xfrm_user_sec_ctx *sec_ctx)
2928{
2929 return 0;
2930}
2931
2932static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
2933 struct xfrm_sec_ctx *polsec, u32 secid)
2934{
2935 return 0;
2936}
2937
2938static inline void security_xfrm_state_free(struct xfrm_state *x)
2939{
2940}
2941
2942static inline int security_xfrm_state_delete(struct xfrm_state *x)
2943{
2944 return 0;
2945}
2946
2947static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir)
2948{
2949 return 0;
2950}
2951
2952static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
2953 struct xfrm_policy *xp, struct flowi *fl)
2954{
2955 return 1;
2956}
2957
2958static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
2959{
2960 return 0;
2961}
2962
2963static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
2964{
2965}
2966
2967#endif
2968
2969#ifdef CONFIG_SECURITY_PATH
2970int security_path_unlink(struct path *dir, struct dentry *dentry);
2971int security_path_mkdir(struct path *dir, struct dentry *dentry, int mode);
2972int security_path_rmdir(struct path *dir, struct dentry *dentry);
2973int security_path_mknod(struct path *dir, struct dentry *dentry, int mode,
2974 unsigned int dev);
2975int security_path_truncate(struct path *path, loff_t length,
2976 unsigned int time_attrs);
2977int security_path_symlink(struct path *dir, struct dentry *dentry,
2978 const char *old_name);
2979int security_path_link(struct dentry *old_dentry, struct path *new_dir,
2980 struct dentry *new_dentry);
2981int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
2982 struct path *new_dir, struct dentry *new_dentry);
2983int security_path_chmod(struct dentry *dentry, struct vfsmount *mnt,
2984 mode_t mode);
2985int security_path_chown(struct path *path, uid_t uid, gid_t gid);
2986int security_path_chroot(struct path *path);
2987#else
2988static inline int security_path_unlink(struct path *dir, struct dentry *dentry)
2989{
2990 return 0;
2991}
2992
2993static inline int security_path_mkdir(struct path *dir, struct dentry *dentry,
2994 int mode)
2995{
2996 return 0;
2997}
2998
2999static inline int security_path_rmdir(struct path *dir, struct dentry *dentry)
3000{
3001 return 0;
3002}
3003
3004static inline int security_path_mknod(struct path *dir, struct dentry *dentry,
3005 int mode, unsigned int dev)
3006{
3007 return 0;
3008}
3009
3010static inline int security_path_truncate(struct path *path, loff_t length,
3011 unsigned int time_attrs)
3012{
3013 return 0;
3014}
3015
3016static inline int security_path_symlink(struct path *dir, struct dentry *dentry,
3017 const char *old_name)
3018{
3019 return 0;
3020}
3021
3022static inline int security_path_link(struct dentry *old_dentry,
3023 struct path *new_dir,
3024 struct dentry *new_dentry)
3025{
3026 return 0;
3027}
3028
3029static inline int security_path_rename(struct path *old_dir,
3030 struct dentry *old_dentry,
3031 struct path *new_dir,
3032 struct dentry *new_dentry)
3033{
3034 return 0;
3035}
3036
3037static inline int security_path_chmod(struct dentry *dentry,
3038 struct vfsmount *mnt,
3039 mode_t mode)
3040{
3041 return 0;
3042}
3043
3044static inline int security_path_chown(struct path *path, uid_t uid, gid_t gid)
3045{
3046 return 0;
3047}
3048
3049static inline int security_path_chroot(struct path *path)
3050{
3051 return 0;
3052}
3053#endif
3054
3055#ifdef CONFIG_KEYS
3056#ifdef CONFIG_SECURITY
3057
3058int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
3059void security_key_free(struct key *key);
3060int security_key_permission(key_ref_t key_ref,
3061 const struct cred *cred, key_perm_t perm);
3062int security_key_getsecurity(struct key *key, char **_buffer);
3063int security_key_session_to_parent(const struct cred *cred,
3064 const struct cred *parent_cred,
3065 struct key *key);
3066
3067#else
3068
3069static inline int security_key_alloc(struct key *key,
3070 const struct cred *cred,
3071 unsigned long flags)
3072{
3073 return 0;
3074}
3075
3076static inline void security_key_free(struct key *key)
3077{
3078}
3079
3080static inline int security_key_permission(key_ref_t key_ref,
3081 const struct cred *cred,
3082 key_perm_t perm)
3083{
3084 return 0;
3085}
3086
3087static inline int security_key_getsecurity(struct key *key, char **_buffer)
3088{
3089 *_buffer = NULL;
3090 return 0;
3091}
3092
3093static inline int security_key_session_to_parent(const struct cred *cred,
3094 const struct cred *parent_cred,
3095 struct key *key)
3096{
3097 return 0;
3098}
3099
3100#endif
3101#endif
3102
3103#ifdef CONFIG_AUDIT
3104#ifdef CONFIG_SECURITY
3105int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
3106int security_audit_rule_known(struct audit_krule *krule);
3107int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule,
3108 struct audit_context *actx);
3109void security_audit_rule_free(void *lsmrule);
3110
3111#else
3112
3113static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
3114 void **lsmrule)
3115{
3116 return 0;
3117}
3118
3119static inline int security_audit_rule_known(struct audit_krule *krule)
3120{
3121 return 0;
3122}
3123
3124static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
3125 void *lsmrule, struct audit_context *actx)
3126{
3127 return 0;
3128}
3129
3130static inline void security_audit_rule_free(void *lsmrule)
3131{ }
3132
3133#endif
3134#endif
3135
3136#ifdef CONFIG_SECURITYFS
3137
3138extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
3139 struct dentry *parent, void *data,
3140 const struct file_operations *fops);
3141extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
3142extern void securityfs_remove(struct dentry *dentry);
3143
3144#else
3145
3146static inline struct dentry *securityfs_create_dir(const char *name,
3147 struct dentry *parent)
3148{
3149 return ERR_PTR(-ENODEV);
3150}
3151
3152static inline struct dentry *securityfs_create_file(const char *name,
3153 mode_t mode,
3154 struct dentry *parent,
3155 void *data,
3156 const struct file_operations *fops)
3157{
3158 return ERR_PTR(-ENODEV);
3159}
3160
3161static inline void securityfs_remove(struct dentry *dentry)
3162{}
3163
3164#endif
3165
3166#ifdef CONFIG_SECURITY
3167
3168static inline char *alloc_secdata(void)
3169{
3170 return (char *)get_zeroed_page(GFP_KERNEL);
3171}
3172
3173static inline void free_secdata(void *secdata)
3174{
3175 free_page((unsigned long)secdata);
3176}
3177
3178#else
3179
3180static inline char *alloc_secdata(void)
3181{
3182 return (char *)1;
3183}
3184
3185static inline void free_secdata(void *secdata)
3186{ }
3187#endif
3188
3189#endif
3190
3191