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