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