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
35struct ctl_table;
36
37
38
39
40
41extern int cap_capable (struct task_struct *tsk, int cap);
42extern int cap_settime (struct timespec *ts, struct timezone *tz);
43extern int cap_ptrace (struct task_struct *parent, struct task_struct *child);
44extern int cap_capget (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
45extern int cap_capset_check (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
46extern void cap_capset_set (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
47extern int cap_bprm_set_security (struct linux_binprm *bprm);
48extern void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe);
49extern int cap_bprm_secureexec(struct linux_binprm *bprm);
50extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags);
51extern int cap_inode_removexattr(struct dentry *dentry, char *name);
52extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
53extern void cap_task_reparent_to_init (struct task_struct *p);
54extern int cap_syslog (int type);
55extern int cap_vm_enough_memory (long pages);
56
57struct msghdr;
58struct sk_buff;
59struct sock;
60struct sockaddr;
61struct socket;
62struct flowi;
63struct dst_entry;
64struct xfrm_selector;
65struct xfrm_policy;
66struct xfrm_state;
67struct xfrm_user_sec_ctx;
68
69extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
70extern int cap_netlink_recv(struct sk_buff *skb, int cap);
71
72
73
74
75
76#define LSM_SETID_ID 1
77
78
79#define LSM_SETID_RE 2
80
81
82#define LSM_SETID_RES 4
83
84
85#define LSM_SETID_FS 8
86
87
88struct nfsctl_arg;
89struct sched_param;
90struct swap_info_struct;
91
92
93#define LSM_UNSAFE_SHARE 1
94#define LSM_UNSAFE_PTRACE 2
95#define LSM_UNSAFE_PTRACE_CAP 4
96
97#ifdef CONFIG_SECURITY
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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
1124struct security_operations {
1125 int (*ptrace) (struct task_struct * parent, struct task_struct * child);
1126 int (*capget) (struct task_struct * target,
1127 kernel_cap_t * effective,
1128 kernel_cap_t * inheritable, kernel_cap_t * permitted);
1129 int (*capset_check) (struct task_struct * target,
1130 kernel_cap_t * effective,
1131 kernel_cap_t * inheritable,
1132 kernel_cap_t * permitted);
1133 void (*capset_set) (struct task_struct * target,
1134 kernel_cap_t * effective,
1135 kernel_cap_t * inheritable,
1136 kernel_cap_t * permitted);
1137 int (*capable) (struct task_struct * tsk, int cap);
1138 int (*acct) (struct file * file);
1139 int (*sysctl) (struct ctl_table * table, int op);
1140 int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
1141 int (*quota_on) (struct dentry * dentry);
1142 int (*syslog) (int type);
1143 int (*settime) (struct timespec *ts, struct timezone *tz);
1144 int (*vm_enough_memory) (long pages);
1145
1146 int (*bprm_alloc_security) (struct linux_binprm * bprm);
1147 void (*bprm_free_security) (struct linux_binprm * bprm);
1148 void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
1149 void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
1150 int (*bprm_set_security) (struct linux_binprm * bprm);
1151 int (*bprm_check_security) (struct linux_binprm * bprm);
1152 int (*bprm_secureexec) (struct linux_binprm * bprm);
1153
1154 int (*sb_alloc_security) (struct super_block * sb);
1155 void (*sb_free_security) (struct super_block * sb);
1156 int (*sb_copy_data)(struct file_system_type *type,
1157 void *orig, void *copy);
1158 int (*sb_kern_mount) (struct super_block *sb, void *data);
1159 int (*sb_statfs) (struct dentry *dentry);
1160 int (*sb_mount) (char *dev_name, struct nameidata * nd,
1161 char *type, unsigned long flags, void *data);
1162 int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
1163 int (*sb_umount) (struct vfsmount * mnt, int flags);
1164 void (*sb_umount_close) (struct vfsmount * mnt);
1165 void (*sb_umount_busy) (struct vfsmount * mnt);
1166 void (*sb_post_remount) (struct vfsmount * mnt,
1167 unsigned long flags, void *data);
1168 void (*sb_post_mountroot) (void);
1169 void (*sb_post_addmount) (struct vfsmount * mnt,
1170 struct nameidata * mountpoint_nd);
1171 int (*sb_pivotroot) (struct nameidata * old_nd,
1172 struct nameidata * new_nd);
1173 void (*sb_post_pivotroot) (struct nameidata * old_nd,
1174 struct nameidata * new_nd);
1175
1176 int (*inode_alloc_security) (struct inode *inode);
1177 void (*inode_free_security) (struct inode *inode);
1178 int (*inode_init_security) (struct inode *inode, struct inode *dir,
1179 char **name, void **value, size_t *len);
1180 int (*inode_create) (struct inode *dir,
1181 struct dentry *dentry, int mode);
1182 int (*inode_link) (struct dentry *old_dentry,
1183 struct inode *dir, struct dentry *new_dentry);
1184 int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
1185 int (*inode_symlink) (struct inode *dir,
1186 struct dentry *dentry, const char *old_name);
1187 int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
1188 int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
1189 int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
1190 int mode, dev_t dev);
1191 int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
1192 struct inode *new_dir, struct dentry *new_dentry);
1193 int (*inode_readlink) (struct dentry *dentry);
1194 int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
1195 int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
1196 int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
1197 int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
1198 void (*inode_delete) (struct inode *inode);
1199 int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
1200 size_t size, int flags);
1201 void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
1202 size_t size, int flags);
1203 int (*inode_getxattr) (struct dentry *dentry, char *name);
1204 int (*inode_listxattr) (struct dentry *dentry);
1205 int (*inode_removexattr) (struct dentry *dentry, char *name);
1206 const char *(*inode_xattr_getsuffix) (void);
1207 int (*inode_getsecurity)(const struct inode *inode, const char *name, void *buffer, size_t size, int err);
1208 int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
1209 int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
1210
1211 int (*file_permission) (struct file * file, int mask);
1212 int (*file_alloc_security) (struct file * file);
1213 void (*file_free_security) (struct file * file);
1214 int (*file_ioctl) (struct file * file, unsigned int cmd,
1215 unsigned long arg);
1216 int (*file_mmap) (struct file * file,
1217 unsigned long reqprot,
1218 unsigned long prot, unsigned long flags);
1219 int (*file_mprotect) (struct vm_area_struct * vma,
1220 unsigned long reqprot,
1221 unsigned long prot);
1222 int (*file_lock) (struct file * file, unsigned int cmd);
1223 int (*file_fcntl) (struct file * file, unsigned int cmd,
1224 unsigned long arg);
1225 int (*file_set_fowner) (struct file * file);
1226 int (*file_send_sigiotask) (struct task_struct * tsk,
1227 struct fown_struct * fown, int sig);
1228 int (*file_receive) (struct file * file);
1229
1230 int (*task_create) (unsigned long clone_flags);
1231 int (*task_alloc_security) (struct task_struct * p);
1232 void (*task_free_security) (struct task_struct * p);
1233 int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
1234 int (*task_post_setuid) (uid_t old_ruid ,
1235 uid_t old_euid, uid_t old_suid, int flags);
1236 int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
1237 int (*task_setpgid) (struct task_struct * p, pid_t pgid);
1238 int (*task_getpgid) (struct task_struct * p);
1239 int (*task_getsid) (struct task_struct * p);
1240 void (*task_getsecid) (struct task_struct * p, u32 * secid);
1241 int (*task_setgroups) (struct group_info *group_info);
1242 int (*task_setnice) (struct task_struct * p, int nice);
1243 int (*task_setioprio) (struct task_struct * p, int ioprio);
1244 int (*task_getioprio) (struct task_struct * p);
1245 int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
1246 int (*task_setscheduler) (struct task_struct * p, int policy,
1247 struct sched_param * lp);
1248 int (*task_getscheduler) (struct task_struct * p);
1249 int (*task_movememory) (struct task_struct * p);
1250 int (*task_kill) (struct task_struct * p,
1251 struct siginfo * info, int sig, u32 secid);
1252 int (*task_wait) (struct task_struct * p);
1253 int (*task_prctl) (int option, unsigned long arg2,
1254 unsigned long arg3, unsigned long arg4,
1255 unsigned long arg5);
1256 void (*task_reparent_to_init) (struct task_struct * p);
1257 void (*task_to_inode)(struct task_struct *p, struct inode *inode);
1258
1259 int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
1260
1261 int (*msg_msg_alloc_security) (struct msg_msg * msg);
1262 void (*msg_msg_free_security) (struct msg_msg * msg);
1263
1264 int (*msg_queue_alloc_security) (struct msg_queue * msq);
1265 void (*msg_queue_free_security) (struct msg_queue * msq);
1266 int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
1267 int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
1268 int (*msg_queue_msgsnd) (struct msg_queue * msq,
1269 struct msg_msg * msg, int msqflg);
1270 int (*msg_queue_msgrcv) (struct msg_queue * msq,
1271 struct msg_msg * msg,
1272 struct task_struct * target,
1273 long type, int mode);
1274
1275 int (*shm_alloc_security) (struct shmid_kernel * shp);
1276 void (*shm_free_security) (struct shmid_kernel * shp);
1277 int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
1278 int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
1279 int (*shm_shmat) (struct shmid_kernel * shp,
1280 char __user *shmaddr, int shmflg);
1281
1282 int (*sem_alloc_security) (struct sem_array * sma);
1283 void (*sem_free_security) (struct sem_array * sma);
1284 int (*sem_associate) (struct sem_array * sma, int semflg);
1285 int (*sem_semctl) (struct sem_array * sma, int cmd);
1286 int (*sem_semop) (struct sem_array * sma,
1287 struct sembuf * sops, unsigned nsops, int alter);
1288
1289 int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
1290 int (*netlink_recv) (struct sk_buff * skb, int cap);
1291
1292
1293 int (*register_security) (const char *name,
1294 struct security_operations *ops);
1295 int (*unregister_security) (const char *name,
1296 struct security_operations *ops);
1297
1298 void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
1299
1300 int (*getprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1301 int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
1302 int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
1303 void (*release_secctx)(char *secdata, u32 seclen);
1304
1305#ifdef CONFIG_SECURITY_NETWORK
1306 int (*unix_stream_connect) (struct socket * sock,
1307 struct socket * other, struct sock * newsk);
1308 int (*unix_may_send) (struct socket * sock, struct socket * other);
1309
1310 int (*socket_create) (int family, int type, int protocol, int kern);
1311 void (*socket_post_create) (struct socket * sock, int family,
1312 int type, int protocol, int kern);
1313 int (*socket_bind) (struct socket * sock,
1314 struct sockaddr * address, int addrlen);
1315 int (*socket_connect) (struct socket * sock,
1316 struct sockaddr * address, int addrlen);
1317 int (*socket_listen) (struct socket * sock, int backlog);
1318 int (*socket_accept) (struct socket * sock, struct socket * newsock);
1319 void (*socket_post_accept) (struct socket * sock,
1320 struct socket * newsock);
1321 int (*socket_sendmsg) (struct socket * sock,
1322 struct msghdr * msg, int size);
1323 int (*socket_recvmsg) (struct socket * sock,
1324 struct msghdr * msg, int size, int flags);
1325 int (*socket_getsockname) (struct socket * sock);
1326 int (*socket_getpeername) (struct socket * sock);
1327 int (*socket_getsockopt) (struct socket * sock, int level, int optname);
1328 int (*socket_setsockopt) (struct socket * sock, int level, int optname);
1329 int (*socket_shutdown) (struct socket * sock, int how);
1330 int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
1331 int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
1332 int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
1333 int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
1334 void (*sk_free_security) (struct sock *sk);
1335 unsigned int (*sk_getsid) (struct sock *sk, struct flowi *fl, u8 dir);
1336#endif
1337
1338#ifdef CONFIG_SECURITY_NETWORK_XFRM
1339 int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx);
1340 int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
1341 void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
1342 int (*xfrm_policy_delete_security) (struct xfrm_policy *xp);
1343 int (*xfrm_state_alloc_security) (struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
1344 void (*xfrm_state_free_security) (struct xfrm_state *x);
1345 int (*xfrm_state_delete_security) (struct xfrm_state *x);
1346 int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 sk_sid, u8 dir);
1347#endif
1348
1349
1350#ifdef CONFIG_KEYS
1351 int (*key_alloc)(struct key *key, struct task_struct *tsk, unsigned long flags);
1352 void (*key_free)(struct key *key);
1353 int (*key_permission)(key_ref_t key_ref,
1354 struct task_struct *context,
1355 key_perm_t perm);
1356
1357#endif
1358
1359};
1360
1361
1362extern struct security_operations *security_ops;
1363
1364
1365static inline int security_ptrace (struct task_struct * parent, struct task_struct * child)
1366{
1367 return security_ops->ptrace (parent, child);
1368}
1369
1370static inline int security_capget (struct task_struct *target,
1371 kernel_cap_t *effective,
1372 kernel_cap_t *inheritable,
1373 kernel_cap_t *permitted)
1374{
1375 return security_ops->capget (target, effective, inheritable, permitted);
1376}
1377
1378static inline int security_capset_check (struct task_struct *target,
1379 kernel_cap_t *effective,
1380 kernel_cap_t *inheritable,
1381 kernel_cap_t *permitted)
1382{
1383 return security_ops->capset_check (target, effective, inheritable, permitted);
1384}
1385
1386static inline void security_capset_set (struct task_struct *target,
1387 kernel_cap_t *effective,
1388 kernel_cap_t *inheritable,
1389 kernel_cap_t *permitted)
1390{
1391 security_ops->capset_set (target, effective, inheritable, permitted);
1392}
1393
1394static inline int security_capable(struct task_struct *tsk, int cap)
1395{
1396 return security_ops->capable(tsk, cap);
1397}
1398
1399static inline int security_acct (struct file *file)
1400{
1401 return security_ops->acct (file);
1402}
1403
1404static inline int security_sysctl(struct ctl_table *table, int op)
1405{
1406 return security_ops->sysctl(table, op);
1407}
1408
1409static inline int security_quotactl (int cmds, int type, int id,
1410 struct super_block *sb)
1411{
1412 return security_ops->quotactl (cmds, type, id, sb);
1413}
1414
1415static inline int security_quota_on (struct dentry * dentry)
1416{
1417 return security_ops->quota_on (dentry);
1418}
1419
1420static inline int security_syslog(int type)
1421{
1422 return security_ops->syslog(type);
1423}
1424
1425static inline int security_settime(struct timespec *ts, struct timezone *tz)
1426{
1427 return security_ops->settime(ts, tz);
1428}
1429
1430
1431static inline int security_vm_enough_memory(long pages)
1432{
1433 return security_ops->vm_enough_memory(pages);
1434}
1435
1436static inline int security_bprm_alloc (struct linux_binprm *bprm)
1437{
1438 return security_ops->bprm_alloc_security (bprm);
1439}
1440static inline void security_bprm_free (struct linux_binprm *bprm)
1441{
1442 security_ops->bprm_free_security (bprm);
1443}
1444static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
1445{
1446 security_ops->bprm_apply_creds (bprm, unsafe);
1447}
1448static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
1449{
1450 security_ops->bprm_post_apply_creds (bprm);
1451}
1452static inline int security_bprm_set (struct linux_binprm *bprm)
1453{
1454 return security_ops->bprm_set_security (bprm);
1455}
1456
1457static inline int security_bprm_check (struct linux_binprm *bprm)
1458{
1459 return security_ops->bprm_check_security (bprm);
1460}
1461
1462static inline int security_bprm_secureexec (struct linux_binprm *bprm)
1463{
1464 return security_ops->bprm_secureexec (bprm);
1465}
1466
1467static inline int security_sb_alloc (struct super_block *sb)
1468{
1469 return security_ops->sb_alloc_security (sb);
1470}
1471
1472static inline void security_sb_free (struct super_block *sb)
1473{
1474 security_ops->sb_free_security (sb);
1475}
1476
1477static inline int security_sb_copy_data (struct file_system_type *type,
1478 void *orig, void *copy)
1479{
1480 return security_ops->sb_copy_data (type, orig, copy);
1481}
1482
1483static inline int security_sb_kern_mount (struct super_block *sb, void *data)
1484{
1485 return security_ops->sb_kern_mount (sb, data);
1486}
1487
1488static inline int security_sb_statfs (struct dentry *dentry)
1489{
1490 return security_ops->sb_statfs (dentry);
1491}
1492
1493static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
1494 char *type, unsigned long flags,
1495 void *data)
1496{
1497 return security_ops->sb_mount (dev_name, nd, type, flags, data);
1498}
1499
1500static inline int security_sb_check_sb (struct vfsmount *mnt,
1501 struct nameidata *nd)
1502{
1503 return security_ops->sb_check_sb (mnt, nd);
1504}
1505
1506static inline int security_sb_umount (struct vfsmount *mnt, int flags)
1507{
1508 return security_ops->sb_umount (mnt, flags);
1509}
1510
1511static inline void security_sb_umount_close (struct vfsmount *mnt)
1512{
1513 security_ops->sb_umount_close (mnt);
1514}
1515
1516static inline void security_sb_umount_busy (struct vfsmount *mnt)
1517{
1518 security_ops->sb_umount_busy (mnt);
1519}
1520
1521static inline void security_sb_post_remount (struct vfsmount *mnt,
1522 unsigned long flags, void *data)
1523{
1524 security_ops->sb_post_remount (mnt, flags, data);
1525}
1526
1527static inline void security_sb_post_mountroot (void)
1528{
1529 security_ops->sb_post_mountroot ();
1530}
1531
1532static inline void security_sb_post_addmount (struct vfsmount *mnt,
1533 struct nameidata *mountpoint_nd)
1534{
1535 security_ops->sb_post_addmount (mnt, mountpoint_nd);
1536}
1537
1538static inline int security_sb_pivotroot (struct nameidata *old_nd,
1539 struct nameidata *new_nd)
1540{
1541 return security_ops->sb_pivotroot (old_nd, new_nd);
1542}
1543
1544static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
1545 struct nameidata *new_nd)
1546{
1547 security_ops->sb_post_pivotroot (old_nd, new_nd);
1548}
1549
1550static inline int security_inode_alloc (struct inode *inode)
1551{
1552 return security_ops->inode_alloc_security (inode);
1553}
1554
1555static inline void security_inode_free (struct inode *inode)
1556{
1557 security_ops->inode_free_security (inode);
1558}
1559
1560static inline int security_inode_init_security (struct inode *inode,
1561 struct inode *dir,
1562 char **name,
1563 void **value,
1564 size_t *len)
1565{
1566 if (unlikely (IS_PRIVATE (inode)))
1567 return -EOPNOTSUPP;
1568 return security_ops->inode_init_security (inode, dir, name, value, len);
1569}
1570
1571static inline int security_inode_create (struct inode *dir,
1572 struct dentry *dentry,
1573 int mode)
1574{
1575 if (unlikely (IS_PRIVATE (dir)))
1576 return 0;
1577 return security_ops->inode_create (dir, dentry, mode);
1578}
1579
1580static inline int security_inode_link (struct dentry *old_dentry,
1581 struct inode *dir,
1582 struct dentry *new_dentry)
1583{
1584 if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
1585 return 0;
1586 return security_ops->inode_link (old_dentry, dir, new_dentry);
1587}
1588
1589static inline int security_inode_unlink (struct inode *dir,
1590 struct dentry *dentry)
1591{
1592 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1593 return 0;
1594 return security_ops->inode_unlink (dir, dentry);
1595}
1596
1597static inline int security_inode_symlink (struct inode *dir,
1598 struct dentry *dentry,
1599 const char *old_name)
1600{
1601 if (unlikely (IS_PRIVATE (dir)))
1602 return 0;
1603 return security_ops->inode_symlink (dir, dentry, old_name);
1604}
1605
1606static inline int security_inode_mkdir (struct inode *dir,
1607 struct dentry *dentry,
1608 int mode)
1609{
1610 if (unlikely (IS_PRIVATE (dir)))
1611 return 0;
1612 return security_ops->inode_mkdir (dir, dentry, mode);
1613}
1614
1615static inline int security_inode_rmdir (struct inode *dir,
1616 struct dentry *dentry)
1617{
1618 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1619 return 0;
1620 return security_ops->inode_rmdir (dir, dentry);
1621}
1622
1623static inline int security_inode_mknod (struct inode *dir,
1624 struct dentry *dentry,
1625 int mode, dev_t dev)
1626{
1627 if (unlikely (IS_PRIVATE (dir)))
1628 return 0;
1629 return security_ops->inode_mknod (dir, dentry, mode, dev);
1630}
1631
1632static inline int security_inode_rename (struct inode *old_dir,
1633 struct dentry *old_dentry,
1634 struct inode *new_dir,
1635 struct dentry *new_dentry)
1636{
1637 if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
1638 (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
1639 return 0;
1640 return security_ops->inode_rename (old_dir, old_dentry,
1641 new_dir, new_dentry);
1642}
1643
1644static inline int security_inode_readlink (struct dentry *dentry)
1645{
1646 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1647 return 0;
1648 return security_ops->inode_readlink (dentry);
1649}
1650
1651static inline int security_inode_follow_link (struct dentry *dentry,
1652 struct nameidata *nd)
1653{
1654 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1655 return 0;
1656 return security_ops->inode_follow_link (dentry, nd);
1657}
1658
1659static inline int security_inode_permission (struct inode *inode, int mask,
1660 struct nameidata *nd)
1661{
1662 if (unlikely (IS_PRIVATE (inode)))
1663 return 0;
1664 return security_ops->inode_permission (inode, mask, nd);
1665}
1666
1667static inline int security_inode_setattr (struct dentry *dentry,
1668 struct iattr *attr)
1669{
1670 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1671 return 0;
1672 return security_ops->inode_setattr (dentry, attr);
1673}
1674
1675static inline int security_inode_getattr (struct vfsmount *mnt,
1676 struct dentry *dentry)
1677{
1678 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1679 return 0;
1680 return security_ops->inode_getattr (mnt, dentry);
1681}
1682
1683static inline void security_inode_delete (struct inode *inode)
1684{
1685 if (unlikely (IS_PRIVATE (inode)))
1686 return;
1687 security_ops->inode_delete (inode);
1688}
1689
1690static inline int security_inode_setxattr (struct dentry *dentry, char *name,
1691 void *value, size_t size, int flags)
1692{
1693 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1694 return 0;
1695 return security_ops->inode_setxattr (dentry, name, value, size, flags);
1696}
1697
1698static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
1699 void *value, size_t size, int flags)
1700{
1701 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1702 return;
1703 security_ops->inode_post_setxattr (dentry, name, value, size, flags);
1704}
1705
1706static inline int security_inode_getxattr (struct dentry *dentry, char *name)
1707{
1708 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1709 return 0;
1710 return security_ops->inode_getxattr (dentry, name);
1711}
1712
1713static inline int security_inode_listxattr (struct dentry *dentry)
1714{
1715 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1716 return 0;
1717 return security_ops->inode_listxattr (dentry);
1718}
1719
1720static inline int security_inode_removexattr (struct dentry *dentry, char *name)
1721{
1722 if (unlikely (IS_PRIVATE (dentry->d_inode)))
1723 return 0;
1724 return security_ops->inode_removexattr (dentry, name);
1725}
1726
1727static inline const char *security_inode_xattr_getsuffix(void)
1728{
1729 return security_ops->inode_xattr_getsuffix();
1730}
1731
1732static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
1733{
1734 if (unlikely (IS_PRIVATE (inode)))
1735 return 0;
1736 return security_ops->inode_getsecurity(inode, name, buffer, size, err);
1737}
1738
1739static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
1740{
1741 if (unlikely (IS_PRIVATE (inode)))
1742 return 0;
1743 return security_ops->inode_setsecurity(inode, name, value, size, flags);
1744}
1745
1746static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
1747{
1748 if (unlikely (IS_PRIVATE (inode)))
1749 return 0;
1750 return security_ops->inode_listsecurity(inode, buffer, buffer_size);
1751}
1752
1753static inline int security_file_permission (struct file *file, int mask)
1754{
1755 return security_ops->file_permission (file, mask);
1756}
1757
1758static inline int security_file_alloc (struct file *file)
1759{
1760 return security_ops->file_alloc_security (file);
1761}
1762
1763static inline void security_file_free (struct file *file)
1764{
1765 security_ops->file_free_security (file);
1766}
1767
1768static inline int security_file_ioctl (struct file *file, unsigned int cmd,
1769 unsigned long arg)
1770{
1771 return security_ops->file_ioctl (file, cmd, arg);
1772}
1773
1774static inline int security_file_mmap (struct file *file, unsigned long reqprot,
1775 unsigned long prot,
1776 unsigned long flags)
1777{
1778 return security_ops->file_mmap (file, reqprot, prot, flags);
1779}
1780
1781static inline int security_file_mprotect (struct vm_area_struct *vma,
1782 unsigned long reqprot,
1783 unsigned long prot)
1784{
1785 return security_ops->file_mprotect (vma, reqprot, prot);
1786}
1787
1788static inline int security_file_lock (struct file *file, unsigned int cmd)
1789{
1790 return security_ops->file_lock (file, cmd);
1791}
1792
1793static inline int security_file_fcntl (struct file *file, unsigned int cmd,
1794 unsigned long arg)
1795{
1796 return security_ops->file_fcntl (file, cmd, arg);
1797}
1798
1799static inline int security_file_set_fowner (struct file *file)
1800{
1801 return security_ops->file_set_fowner (file);
1802}
1803
1804static inline int security_file_send_sigiotask (struct task_struct *tsk,
1805 struct fown_struct *fown,
1806 int sig)
1807{
1808 return security_ops->file_send_sigiotask (tsk, fown, sig);
1809}
1810
1811static inline int security_file_receive (struct file *file)
1812{
1813 return security_ops->file_receive (file);
1814}
1815
1816static inline int security_task_create (unsigned long clone_flags)
1817{
1818 return security_ops->task_create (clone_flags);
1819}
1820
1821static inline int security_task_alloc (struct task_struct *p)
1822{
1823 return security_ops->task_alloc_security (p);
1824}
1825
1826static inline void security_task_free (struct task_struct *p)
1827{
1828 security_ops->task_free_security (p);
1829}
1830
1831static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
1832 int flags)
1833{
1834 return security_ops->task_setuid (id0, id1, id2, flags);
1835}
1836
1837static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
1838 uid_t old_suid, int flags)
1839{
1840 return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags);
1841}
1842
1843static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
1844 int flags)
1845{
1846 return security_ops->task_setgid (id0, id1, id2, flags);
1847}
1848
1849static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
1850{
1851 return security_ops->task_setpgid (p, pgid);
1852}
1853
1854static inline int security_task_getpgid (struct task_struct *p)
1855{
1856 return security_ops->task_getpgid (p);
1857}
1858
1859static inline int security_task_getsid (struct task_struct *p)
1860{
1861 return security_ops->task_getsid (p);
1862}
1863
1864static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
1865{
1866 security_ops->task_getsecid (p, secid);
1867}
1868
1869static inline int security_task_setgroups (struct group_info *group_info)
1870{
1871 return security_ops->task_setgroups (group_info);
1872}
1873
1874static inline int security_task_setnice (struct task_struct *p, int nice)
1875{
1876 return security_ops->task_setnice (p, nice);
1877}
1878
1879static inline int security_task_setioprio (struct task_struct *p, int ioprio)
1880{
1881 return security_ops->task_setioprio (p, ioprio);
1882}
1883
1884static inline int security_task_getioprio (struct task_struct *p)
1885{
1886 return security_ops->task_getioprio (p);
1887}
1888
1889static inline int security_task_setrlimit (unsigned int resource,
1890 struct rlimit *new_rlim)
1891{
1892 return security_ops->task_setrlimit (resource, new_rlim);
1893}
1894
1895static inline int security_task_setscheduler (struct task_struct *p,
1896 int policy,
1897 struct sched_param *lp)
1898{
1899 return security_ops->task_setscheduler (p, policy, lp);
1900}
1901
1902static inline int security_task_getscheduler (struct task_struct *p)
1903{
1904 return security_ops->task_getscheduler (p);
1905}
1906
1907static inline int security_task_movememory (struct task_struct *p)
1908{
1909 return security_ops->task_movememory (p);
1910}
1911
1912static inline int security_task_kill (struct task_struct *p,
1913 struct siginfo *info, int sig,
1914 u32 secid)
1915{
1916 return security_ops->task_kill (p, info, sig, secid);
1917}
1918
1919static inline int security_task_wait (struct task_struct *p)
1920{
1921 return security_ops->task_wait (p);
1922}
1923
1924static inline int security_task_prctl (int option, unsigned long arg2,
1925 unsigned long arg3,
1926 unsigned long arg4,
1927 unsigned long arg5)
1928{
1929 return security_ops->task_prctl (option, arg2, arg3, arg4, arg5);
1930}
1931
1932static inline void security_task_reparent_to_init (struct task_struct *p)
1933{
1934 security_ops->task_reparent_to_init (p);
1935}
1936
1937static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
1938{
1939 security_ops->task_to_inode(p, inode);
1940}
1941
1942static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
1943 short flag)
1944{
1945 return security_ops->ipc_permission (ipcp, flag);
1946}
1947
1948static inline int security_msg_msg_alloc (struct msg_msg * msg)
1949{
1950 return security_ops->msg_msg_alloc_security (msg);
1951}
1952
1953static inline void security_msg_msg_free (struct msg_msg * msg)
1954{
1955 security_ops->msg_msg_free_security(msg);
1956}
1957
1958static inline int security_msg_queue_alloc (struct msg_queue *msq)
1959{
1960 return security_ops->msg_queue_alloc_security (msq);
1961}
1962
1963static inline void security_msg_queue_free (struct msg_queue *msq)
1964{
1965 security_ops->msg_queue_free_security (msq);
1966}
1967
1968static inline int security_msg_queue_associate (struct msg_queue * msq,
1969 int msqflg)
1970{
1971 return security_ops->msg_queue_associate (msq, msqflg);
1972}
1973
1974static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
1975{
1976 return security_ops->msg_queue_msgctl (msq, cmd);
1977}
1978
1979static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
1980 struct msg_msg * msg, int msqflg)
1981{
1982 return security_ops->msg_queue_msgsnd (msq, msg, msqflg);
1983}
1984
1985static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
1986 struct msg_msg * msg,
1987 struct task_struct * target,
1988 long type, int mode)
1989{
1990 return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode);
1991}
1992
1993static inline int security_shm_alloc (struct shmid_kernel *shp)
1994{
1995 return security_ops->shm_alloc_security (shp);
1996}
1997
1998static inline void security_shm_free (struct shmid_kernel *shp)
1999{
2000 security_ops->shm_free_security (shp);
2001}
2002
2003static inline int security_shm_associate (struct shmid_kernel * shp,
2004 int shmflg)
2005{
2006 return security_ops->shm_associate(shp, shmflg);
2007}
2008
2009static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2010{
2011 return security_ops->shm_shmctl (shp, cmd);
2012}
2013
2014static inline int security_shm_shmat (struct shmid_kernel * shp,
2015 char __user *shmaddr, int shmflg)
2016{
2017 return security_ops->shm_shmat(shp, shmaddr, shmflg);
2018}
2019
2020static inline int security_sem_alloc (struct sem_array *sma)
2021{
2022 return security_ops->sem_alloc_security (sma);
2023}
2024
2025static inline void security_sem_free (struct sem_array *sma)
2026{
2027 security_ops->sem_free_security (sma);
2028}
2029
2030static inline int security_sem_associate (struct sem_array * sma, int semflg)
2031{
2032 return security_ops->sem_associate (sma, semflg);
2033}
2034
2035static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2036{
2037 return security_ops->sem_semctl(sma, cmd);
2038}
2039
2040static inline int security_sem_semop (struct sem_array * sma,
2041 struct sembuf * sops, unsigned nsops,
2042 int alter)
2043{
2044 return security_ops->sem_semop(sma, sops, nsops, alter);
2045}
2046
2047static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2048{
2049 if (unlikely (inode && IS_PRIVATE (inode)))
2050 return;
2051 security_ops->d_instantiate (dentry, inode);
2052}
2053
2054static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
2055{
2056 return security_ops->getprocattr(p, name, value, size);
2057}
2058
2059static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2060{
2061 return security_ops->setprocattr(p, name, value, size);
2062}
2063
2064static inline int security_netlink_send(struct sock *sk, struct sk_buff * skb)
2065{
2066 return security_ops->netlink_send(sk, skb);
2067}
2068
2069static inline int security_netlink_recv(struct sk_buff * skb, int cap)
2070{
2071 return security_ops->netlink_recv(skb, cap);
2072}
2073
2074static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2075{
2076 return security_ops->secid_to_secctx(secid, secdata, seclen);
2077}
2078
2079static inline void security_release_secctx(char *secdata, u32 seclen)
2080{
2081 return security_ops->release_secctx(secdata, seclen);
2082}
2083
2084
2085extern int security_init (void);
2086extern int register_security (struct security_operations *ops);
2087extern int unregister_security (struct security_operations *ops);
2088extern int mod_reg_security (const char *name, struct security_operations *ops);
2089extern int mod_unreg_security (const char *name, struct security_operations *ops);
2090extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
2091 struct dentry *parent, void *data,
2092 struct file_operations *fops);
2093extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
2094extern void securityfs_remove(struct dentry *dentry);
2095
2096
2097#else
2098
2099
2100
2101
2102
2103
2104static inline int security_init(void)
2105{
2106 return 0;
2107}
2108
2109static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
2110{
2111 return cap_ptrace (parent, child);
2112}
2113
2114static inline int security_capget (struct task_struct *target,
2115 kernel_cap_t *effective,
2116 kernel_cap_t *inheritable,
2117 kernel_cap_t *permitted)
2118{
2119 return cap_capget (target, effective, inheritable, permitted);
2120}
2121
2122static inline int security_capset_check (struct task_struct *target,
2123 kernel_cap_t *effective,
2124 kernel_cap_t *inheritable,
2125 kernel_cap_t *permitted)
2126{
2127 return cap_capset_check (target, effective, inheritable, permitted);
2128}
2129
2130static inline void security_capset_set (struct task_struct *target,
2131 kernel_cap_t *effective,
2132 kernel_cap_t *inheritable,
2133 kernel_cap_t *permitted)
2134{
2135 cap_capset_set (target, effective, inheritable, permitted);
2136}
2137
2138static inline int security_capable(struct task_struct *tsk, int cap)
2139{
2140 return cap_capable(tsk, cap);
2141}
2142
2143static inline int security_acct (struct file *file)
2144{
2145 return 0;
2146}
2147
2148static inline int security_sysctl(struct ctl_table *table, int op)
2149{
2150 return 0;
2151}
2152
2153static inline int security_quotactl (int cmds, int type, int id,
2154 struct super_block * sb)
2155{
2156 return 0;
2157}
2158
2159static inline int security_quota_on (struct dentry * dentry)
2160{
2161 return 0;
2162}
2163
2164static inline int security_syslog(int type)
2165{
2166 return cap_syslog(type);
2167}
2168
2169static inline int security_settime(struct timespec *ts, struct timezone *tz)
2170{
2171 return cap_settime(ts, tz);
2172}
2173
2174static inline int security_vm_enough_memory(long pages)
2175{
2176 return cap_vm_enough_memory(pages);
2177}
2178
2179static inline int security_bprm_alloc (struct linux_binprm *bprm)
2180{
2181 return 0;
2182}
2183
2184static inline void security_bprm_free (struct linux_binprm *bprm)
2185{ }
2186
2187static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
2188{
2189 cap_bprm_apply_creds (bprm, unsafe);
2190}
2191
2192static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
2193{
2194 return;
2195}
2196
2197static inline int security_bprm_set (struct linux_binprm *bprm)
2198{
2199 return cap_bprm_set_security (bprm);
2200}
2201
2202static inline int security_bprm_check (struct linux_binprm *bprm)
2203{
2204 return 0;
2205}
2206
2207static inline int security_bprm_secureexec (struct linux_binprm *bprm)
2208{
2209 return cap_bprm_secureexec(bprm);
2210}
2211
2212static inline int security_sb_alloc (struct super_block *sb)
2213{
2214 return 0;
2215}
2216
2217static inline void security_sb_free (struct super_block *sb)
2218{ }
2219
2220static inline int security_sb_copy_data (struct file_system_type *type,
2221 void *orig, void *copy)
2222{
2223 return 0;
2224}
2225
2226static inline int security_sb_kern_mount (struct super_block *sb, void *data)
2227{
2228 return 0;
2229}
2230
2231static inline int security_sb_statfs (struct dentry *dentry)
2232{
2233 return 0;
2234}
2235
2236static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
2237 char *type, unsigned long flags,
2238 void *data)
2239{
2240 return 0;
2241}
2242
2243static inline int security_sb_check_sb (struct vfsmount *mnt,
2244 struct nameidata *nd)
2245{
2246 return 0;
2247}
2248
2249static inline int security_sb_umount (struct vfsmount *mnt, int flags)
2250{
2251 return 0;
2252}
2253
2254static inline void security_sb_umount_close (struct vfsmount *mnt)
2255{ }
2256
2257static inline void security_sb_umount_busy (struct vfsmount *mnt)
2258{ }
2259
2260static inline void security_sb_post_remount (struct vfsmount *mnt,
2261 unsigned long flags, void *data)
2262{ }
2263
2264static inline void security_sb_post_mountroot (void)
2265{ }
2266
2267static inline void security_sb_post_addmount (struct vfsmount *mnt,
2268 struct nameidata *mountpoint_nd)
2269{ }
2270
2271static inline int security_sb_pivotroot (struct nameidata *old_nd,
2272 struct nameidata *new_nd)
2273{
2274 return 0;
2275}
2276
2277static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
2278 struct nameidata *new_nd)
2279{ }
2280
2281static inline int security_inode_alloc (struct inode *inode)
2282{
2283 return 0;
2284}
2285
2286static inline void security_inode_free (struct inode *inode)
2287{ }
2288
2289static inline int security_inode_init_security (struct inode *inode,
2290 struct inode *dir,
2291 char **name,
2292 void **value,
2293 size_t *len)
2294{
2295 return -EOPNOTSUPP;
2296}
2297
2298static inline int security_inode_create (struct inode *dir,
2299 struct dentry *dentry,
2300 int mode)
2301{
2302 return 0;
2303}
2304
2305static inline int security_inode_link (struct dentry *old_dentry,
2306 struct inode *dir,
2307 struct dentry *new_dentry)
2308{
2309 return 0;
2310}
2311
2312static inline int security_inode_unlink (struct inode *dir,
2313 struct dentry *dentry)
2314{
2315 return 0;
2316}
2317
2318static inline int security_inode_symlink (struct inode *dir,
2319 struct dentry *dentry,
2320 const char *old_name)
2321{
2322 return 0;
2323}
2324
2325static inline int security_inode_mkdir (struct inode *dir,
2326 struct dentry *dentry,
2327 int mode)
2328{
2329 return 0;
2330}
2331
2332static inline int security_inode_rmdir (struct inode *dir,
2333 struct dentry *dentry)
2334{
2335 return 0;
2336}
2337
2338static inline int security_inode_mknod (struct inode *dir,
2339 struct dentry *dentry,
2340 int mode, dev_t dev)
2341{
2342 return 0;
2343}
2344
2345static inline int security_inode_rename (struct inode *old_dir,
2346 struct dentry *old_dentry,
2347 struct inode *new_dir,
2348 struct dentry *new_dentry)
2349{
2350 return 0;
2351}
2352
2353static inline int security_inode_readlink (struct dentry *dentry)
2354{
2355 return 0;
2356}
2357
2358static inline int security_inode_follow_link (struct dentry *dentry,
2359 struct nameidata *nd)
2360{
2361 return 0;
2362}
2363
2364static inline int security_inode_permission (struct inode *inode, int mask,
2365 struct nameidata *nd)
2366{
2367 return 0;
2368}
2369
2370static inline int security_inode_setattr (struct dentry *dentry,
2371 struct iattr *attr)
2372{
2373 return 0;
2374}
2375
2376static inline int security_inode_getattr (struct vfsmount *mnt,
2377 struct dentry *dentry)
2378{
2379 return 0;
2380}
2381
2382static inline void security_inode_delete (struct inode *inode)
2383{ }
2384
2385static inline int security_inode_setxattr (struct dentry *dentry, char *name,
2386 void *value, size_t size, int flags)
2387{
2388 return cap_inode_setxattr(dentry, name, value, size, flags);
2389}
2390
2391static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
2392 void *value, size_t size, int flags)
2393{ }
2394
2395static inline int security_inode_getxattr (struct dentry *dentry, char *name)
2396{
2397 return 0;
2398}
2399
2400static inline int security_inode_listxattr (struct dentry *dentry)
2401{
2402 return 0;
2403}
2404
2405static inline int security_inode_removexattr (struct dentry *dentry, char *name)
2406{
2407 return cap_inode_removexattr(dentry, name);
2408}
2409
2410static inline const char *security_inode_xattr_getsuffix (void)
2411{
2412 return NULL ;
2413}
2414
2415static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
2416{
2417 return -EOPNOTSUPP;
2418}
2419
2420static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
2421{
2422 return -EOPNOTSUPP;
2423}
2424
2425static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
2426{
2427 return 0;
2428}
2429
2430static inline int security_file_permission (struct file *file, int mask)
2431{
2432 return 0;
2433}
2434
2435static inline int security_file_alloc (struct file *file)
2436{
2437 return 0;
2438}
2439
2440static inline void security_file_free (struct file *file)
2441{ }
2442
2443static inline int security_file_ioctl (struct file *file, unsigned int cmd,
2444 unsigned long arg)
2445{
2446 return 0;
2447}
2448
2449static inline int security_file_mmap (struct file *file, unsigned long reqprot,
2450 unsigned long prot,
2451 unsigned long flags)
2452{
2453 return 0;
2454}
2455
2456static inline int security_file_mprotect (struct vm_area_struct *vma,
2457 unsigned long reqprot,
2458 unsigned long prot)
2459{
2460 return 0;
2461}
2462
2463static inline int security_file_lock (struct file *file, unsigned int cmd)
2464{
2465 return 0;
2466}
2467
2468static inline int security_file_fcntl (struct file *file, unsigned int cmd,
2469 unsigned long arg)
2470{
2471 return 0;
2472}
2473
2474static inline int security_file_set_fowner (struct file *file)
2475{
2476 return 0;
2477}
2478
2479static inline int security_file_send_sigiotask (struct task_struct *tsk,
2480 struct fown_struct *fown,
2481 int sig)
2482{
2483 return 0;
2484}
2485
2486static inline int security_file_receive (struct file *file)
2487{
2488 return 0;
2489}
2490
2491static inline int security_task_create (unsigned long clone_flags)
2492{
2493 return 0;
2494}
2495
2496static inline int security_task_alloc (struct task_struct *p)
2497{
2498 return 0;
2499}
2500
2501static inline void security_task_free (struct task_struct *p)
2502{ }
2503
2504static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
2505 int flags)
2506{
2507 return 0;
2508}
2509
2510static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
2511 uid_t old_suid, int flags)
2512{
2513 return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
2514}
2515
2516static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
2517 int flags)
2518{
2519 return 0;
2520}
2521
2522static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
2523{
2524 return 0;
2525}
2526
2527static inline int security_task_getpgid (struct task_struct *p)
2528{
2529 return 0;
2530}
2531
2532static inline int security_task_getsid (struct task_struct *p)
2533{
2534 return 0;
2535}
2536
2537static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
2538{ }
2539
2540static inline int security_task_setgroups (struct group_info *group_info)
2541{
2542 return 0;
2543}
2544
2545static inline int security_task_setnice (struct task_struct *p, int nice)
2546{
2547 return 0;
2548}
2549
2550static inline int security_task_setioprio (struct task_struct *p, int ioprio)
2551{
2552 return 0;
2553}
2554
2555static inline int security_task_getioprio (struct task_struct *p)
2556{
2557 return 0;
2558}
2559
2560static inline int security_task_setrlimit (unsigned int resource,
2561 struct rlimit *new_rlim)
2562{
2563 return 0;
2564}
2565
2566static inline int security_task_setscheduler (struct task_struct *p,
2567 int policy,
2568 struct sched_param *lp)
2569{
2570 return 0;
2571}
2572
2573static inline int security_task_getscheduler (struct task_struct *p)
2574{
2575 return 0;
2576}
2577
2578static inline int security_task_movememory (struct task_struct *p)
2579{
2580 return 0;
2581}
2582
2583static inline int security_task_kill (struct task_struct *p,
2584 struct siginfo *info, int sig,
2585 u32 secid)
2586{
2587 return 0;
2588}
2589
2590static inline int security_task_wait (struct task_struct *p)
2591{
2592 return 0;
2593}
2594
2595static inline int security_task_prctl (int option, unsigned long arg2,
2596 unsigned long arg3,
2597 unsigned long arg4,
2598 unsigned long arg5)
2599{
2600 return 0;
2601}
2602
2603static inline void security_task_reparent_to_init (struct task_struct *p)
2604{
2605 cap_task_reparent_to_init (p);
2606}
2607
2608static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
2609{ }
2610
2611static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
2612 short flag)
2613{
2614 return 0;
2615}
2616
2617static inline int security_msg_msg_alloc (struct msg_msg * msg)
2618{
2619 return 0;
2620}
2621
2622static inline void security_msg_msg_free (struct msg_msg * msg)
2623{ }
2624
2625static inline int security_msg_queue_alloc (struct msg_queue *msq)
2626{
2627 return 0;
2628}
2629
2630static inline void security_msg_queue_free (struct msg_queue *msq)
2631{ }
2632
2633static inline int security_msg_queue_associate (struct msg_queue * msq,
2634 int msqflg)
2635{
2636 return 0;
2637}
2638
2639static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
2640{
2641 return 0;
2642}
2643
2644static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
2645 struct msg_msg * msg, int msqflg)
2646{
2647 return 0;
2648}
2649
2650static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
2651 struct msg_msg * msg,
2652 struct task_struct * target,
2653 long type, int mode)
2654{
2655 return 0;
2656}
2657
2658static inline int security_shm_alloc (struct shmid_kernel *shp)
2659{
2660 return 0;
2661}
2662
2663static inline void security_shm_free (struct shmid_kernel *shp)
2664{ }
2665
2666static inline int security_shm_associate (struct shmid_kernel * shp,
2667 int shmflg)
2668{
2669 return 0;
2670}
2671
2672static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
2673{
2674 return 0;
2675}
2676
2677static inline int security_shm_shmat (struct shmid_kernel * shp,
2678 char __user *shmaddr, int shmflg)
2679{
2680 return 0;
2681}
2682
2683static inline int security_sem_alloc (struct sem_array *sma)
2684{
2685 return 0;
2686}
2687
2688static inline void security_sem_free (struct sem_array *sma)
2689{ }
2690
2691static inline int security_sem_associate (struct sem_array * sma, int semflg)
2692{
2693 return 0;
2694}
2695
2696static inline int security_sem_semctl (struct sem_array * sma, int cmd)
2697{
2698 return 0;
2699}
2700
2701static inline int security_sem_semop (struct sem_array * sma,
2702 struct sembuf * sops, unsigned nsops,
2703 int alter)
2704{
2705 return 0;
2706}
2707
2708static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
2709{ }
2710
2711static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
2712{
2713 return -EINVAL;
2714}
2715
2716static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
2717{
2718 return -EINVAL;
2719}
2720
2721static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
2722{
2723 return cap_netlink_send (sk, skb);
2724}
2725
2726static inline int security_netlink_recv (struct sk_buff *skb, int cap)
2727{
2728 return cap_netlink_recv (skb, cap);
2729}
2730
2731static inline struct dentry *securityfs_create_dir(const char *name,
2732 struct dentry *parent)
2733{
2734 return ERR_PTR(-ENODEV);
2735}
2736
2737static inline struct dentry *securityfs_create_file(const char *name,
2738 mode_t mode,
2739 struct dentry *parent,
2740 void *data,
2741 struct file_operations *fops)
2742{
2743 return ERR_PTR(-ENODEV);
2744}
2745
2746static inline void securityfs_remove(struct dentry *dentry)
2747{
2748}
2749
2750static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
2751{
2752 return -EOPNOTSUPP;
2753}
2754
2755static inline void security_release_secctx(char *secdata, u32 seclen)
2756{
2757}
2758#endif
2759
2760#ifdef CONFIG_SECURITY_NETWORK
2761static inline int security_unix_stream_connect(struct socket * sock,
2762 struct socket * other,
2763 struct sock * newsk)
2764{
2765 return security_ops->unix_stream_connect(sock, other, newsk);
2766}
2767
2768
2769static inline int security_unix_may_send(struct socket * sock,
2770 struct socket * other)
2771{
2772 return security_ops->unix_may_send(sock, other);
2773}
2774
2775static inline int security_socket_create (int family, int type,
2776 int protocol, int kern)
2777{
2778 return security_ops->socket_create(family, type, protocol, kern);
2779}
2780
2781static inline void security_socket_post_create(struct socket * sock,
2782 int family,
2783 int type,
2784 int protocol, int kern)
2785{
2786 security_ops->socket_post_create(sock, family, type,
2787 protocol, kern);
2788}
2789
2790static inline int security_socket_bind(struct socket * sock,
2791 struct sockaddr * address,
2792 int addrlen)
2793{
2794 return security_ops->socket_bind(sock, address, addrlen);
2795}
2796
2797static inline int security_socket_connect(struct socket * sock,
2798 struct sockaddr * address,
2799 int addrlen)
2800{
2801 return security_ops->socket_connect(sock, address, addrlen);
2802}
2803
2804static inline int security_socket_listen(struct socket * sock, int backlog)
2805{
2806 return security_ops->socket_listen(sock, backlog);
2807}
2808
2809static inline int security_socket_accept(struct socket * sock,
2810 struct socket * newsock)
2811{
2812 return security_ops->socket_accept(sock, newsock);
2813}
2814
2815static inline void security_socket_post_accept(struct socket * sock,
2816 struct socket * newsock)
2817{
2818 security_ops->socket_post_accept(sock, newsock);
2819}
2820
2821static inline int security_socket_sendmsg(struct socket * sock,
2822 struct msghdr * msg, int size)
2823{
2824 return security_ops->socket_sendmsg(sock, msg, size);
2825}
2826
2827static inline int security_socket_recvmsg(struct socket * sock,
2828 struct msghdr * msg, int size,
2829 int flags)
2830{
2831 return security_ops->socket_recvmsg(sock, msg, size, flags);
2832}
2833
2834static inline int security_socket_getsockname(struct socket * sock)
2835{
2836 return security_ops->socket_getsockname(sock);
2837}
2838
2839static inline int security_socket_getpeername(struct socket * sock)
2840{
2841 return security_ops->socket_getpeername(sock);
2842}
2843
2844static inline int security_socket_getsockopt(struct socket * sock,
2845 int level, int optname)
2846{
2847 return security_ops->socket_getsockopt(sock, level, optname);
2848}
2849
2850static inline int security_socket_setsockopt(struct socket * sock,
2851 int level, int optname)
2852{
2853 return security_ops->socket_setsockopt(sock, level, optname);
2854}
2855
2856static inline int security_socket_shutdown(struct socket * sock, int how)
2857{
2858 return security_ops->socket_shutdown(sock, how);
2859}
2860
2861static inline int security_sock_rcv_skb (struct sock * sk,
2862 struct sk_buff * skb)
2863{
2864 return security_ops->socket_sock_rcv_skb (sk, skb);
2865}
2866
2867static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2868 int __user *optlen, unsigned len)
2869{
2870 return security_ops->socket_getpeersec_stream(sock, optval, optlen, len);
2871}
2872
2873static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
2874{
2875 return security_ops->socket_getpeersec_dgram(sock, skb, secid);
2876}
2877
2878static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
2879{
2880 return security_ops->sk_alloc_security(sk, family, priority);
2881}
2882
2883static inline void security_sk_free(struct sock *sk)
2884{
2885 return security_ops->sk_free_security(sk);
2886}
2887
2888static inline unsigned int security_sk_sid(struct sock *sk, struct flowi *fl, u8 dir)
2889{
2890 return security_ops->sk_getsid(sk, fl, dir);
2891}
2892#else
2893static inline int security_unix_stream_connect(struct socket * sock,
2894 struct socket * other,
2895 struct sock * newsk)
2896{
2897 return 0;
2898}
2899
2900static inline int security_unix_may_send(struct socket * sock,
2901 struct socket * other)
2902{
2903 return 0;
2904}
2905
2906static inline int security_socket_create (int family, int type,
2907 int protocol, int kern)
2908{
2909 return 0;
2910}
2911
2912static inline void security_socket_post_create(struct socket * sock,
2913 int family,
2914 int type,
2915 int protocol, int kern)
2916{
2917}
2918
2919static inline int security_socket_bind(struct socket * sock,
2920 struct sockaddr * address,
2921 int addrlen)
2922{
2923 return 0;
2924}
2925
2926static inline int security_socket_connect(struct socket * sock,
2927 struct sockaddr * address,
2928 int addrlen)
2929{
2930 return 0;
2931}
2932
2933static inline int security_socket_listen(struct socket * sock, int backlog)
2934{
2935 return 0;
2936}
2937
2938static inline int security_socket_accept(struct socket * sock,
2939 struct socket * newsock)
2940{
2941 return 0;
2942}
2943
2944static inline void security_socket_post_accept(struct socket * sock,
2945 struct socket * newsock)
2946{
2947}
2948
2949static inline int security_socket_sendmsg(struct socket * sock,
2950 struct msghdr * msg, int size)
2951{
2952 return 0;
2953}
2954
2955static inline int security_socket_recvmsg(struct socket * sock,
2956 struct msghdr * msg, int size,
2957 int flags)
2958{
2959 return 0;
2960}
2961
2962static inline int security_socket_getsockname(struct socket * sock)
2963{
2964 return 0;
2965}
2966
2967static inline int security_socket_getpeername(struct socket * sock)
2968{
2969 return 0;
2970}
2971
2972static inline int security_socket_getsockopt(struct socket * sock,
2973 int level, int optname)
2974{
2975 return 0;
2976}
2977
2978static inline int security_socket_setsockopt(struct socket * sock,
2979 int level, int optname)
2980{
2981 return 0;
2982}
2983
2984static inline int security_socket_shutdown(struct socket * sock, int how)
2985{
2986 return 0;
2987}
2988static inline int security_sock_rcv_skb (struct sock * sk,
2989 struct sk_buff * skb)
2990{
2991 return 0;
2992}
2993
2994static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
2995 int __user *optlen, unsigned len)
2996{
2997 return -ENOPROTOOPT;
2998}
2999
3000static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
3001{
3002 return -ENOPROTOOPT;
3003}
3004
3005static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
3006{
3007 return 0;
3008}
3009
3010static inline void security_sk_free(struct sock *sk)
3011{
3012}
3013
3014static inline unsigned int security_sk_sid(struct sock *sk, struct flowi *fl, u8 dir)
3015{
3016 return 0;
3017}
3018#endif
3019
3020#ifdef CONFIG_SECURITY_NETWORK_XFRM
3021static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
3022{
3023 return security_ops->xfrm_policy_alloc_security(xp, sec_ctx);
3024}
3025
3026static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3027{
3028 return security_ops->xfrm_policy_clone_security(old, new);
3029}
3030
3031static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
3032{
3033 security_ops->xfrm_policy_free_security(xp);
3034}
3035
3036static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3037{
3038 return security_ops->xfrm_policy_delete_security(xp);
3039}
3040
3041static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx)
3042{
3043 return security_ops->xfrm_state_alloc_security(x, sec_ctx);
3044}
3045
3046static inline int security_xfrm_state_delete(struct xfrm_state *x)
3047{
3048 return security_ops->xfrm_state_delete_security(x);
3049}
3050
3051static inline void security_xfrm_state_free(struct xfrm_state *x)
3052{
3053 security_ops->xfrm_state_free_security(x);
3054}
3055
3056static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir)
3057{
3058 return security_ops->xfrm_policy_lookup(xp, sk_sid, dir);
3059}
3060#else
3061static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
3062{
3063 return 0;
3064}
3065
3066static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
3067{
3068 return 0;
3069}
3070
3071static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
3072{
3073}
3074
3075static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
3076{
3077 return 0;
3078}
3079
3080static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx)
3081{
3082 return 0;
3083}
3084
3085static inline void security_xfrm_state_free(struct xfrm_state *x)
3086{
3087}
3088
3089static inline int security_xfrm_state_delete(struct xfrm_state *x)
3090{
3091 return 0;
3092}
3093
3094static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir)
3095{
3096 return 0;
3097}
3098#endif
3099
3100#ifdef CONFIG_KEYS
3101#ifdef CONFIG_SECURITY
3102static inline int security_key_alloc(struct key *key,
3103 struct task_struct *tsk,
3104 unsigned long flags)
3105{
3106 return security_ops->key_alloc(key, tsk, flags);
3107}
3108
3109static inline void security_key_free(struct key *key)
3110{
3111 security_ops->key_free(key);
3112}
3113
3114static inline int security_key_permission(key_ref_t key_ref,
3115 struct task_struct *context,
3116 key_perm_t perm)
3117{
3118 return security_ops->key_permission(key_ref, context, perm);
3119}
3120
3121#else
3122
3123static inline int security_key_alloc(struct key *key,
3124 struct task_struct *tsk,
3125 unsigned long flags)
3126{
3127 return 0;
3128}
3129
3130static inline void security_key_free(struct key *key)
3131{
3132}
3133
3134static inline int security_key_permission(key_ref_t key_ref,
3135 struct task_struct *context,
3136 key_perm_t perm)
3137{
3138 return 0;
3139}
3140
3141#endif
3142#endif
3143
3144#endif
3145
3146