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