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