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