security.h 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641
  1. /*
  2. * Linux Security plug
  3. *
  4. * Copyright (C) 2001 WireX Communications, Inc <chris@wirex.com>
  5. * Copyright (C) 2001 Greg Kroah-Hartman <greg@kroah.com>
  6. * Copyright (C) 2001 Networks Associates Technology, Inc <ssmalley@nai.com>
  7. * Copyright (C) 2001 James Morris <jmorris@intercode.com.au>
  8. * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group)
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * Due to this file being licensed under the GPL there is controversy over
  16. * whether this permits you to write a module that #includes this file
  17. * without placing your module under the GPL. Please consult a lawyer for
  18. * advice before doing this.
  19. *
  20. */
  21. #ifndef __LINUX_SECURITY_H
  22. #define __LINUX_SECURITY_H
  23. #include <linux/key.h>
  24. #include <linux/capability.h>
  25. #include <linux/slab.h>
  26. #include <linux/err.h>
  27. #include <linux/string.h>
  28. #include <linux/mm.h>
  29. struct linux_binprm;
  30. struct cred;
  31. struct rlimit;
  32. struct siginfo;
  33. struct sem_array;
  34. struct sembuf;
  35. struct kern_ipc_perm;
  36. struct audit_context;
  37. struct super_block;
  38. struct inode;
  39. struct dentry;
  40. struct file;
  41. struct vfsmount;
  42. struct path;
  43. struct qstr;
  44. struct iattr;
  45. struct fown_struct;
  46. struct file_operations;
  47. struct shmid_kernel;
  48. struct msg_msg;
  49. struct msg_queue;
  50. struct xattr;
  51. struct xfrm_sec_ctx;
  52. struct mm_struct;
  53. /* If capable should audit the security request */
  54. #define SECURITY_CAP_NOAUDIT 0
  55. #define SECURITY_CAP_AUDIT 1
  56. /* LSM Agnostic defines for sb_set_mnt_opts */
  57. #define SECURITY_LSM_NATIVE_LABELS 1
  58. struct ctl_table;
  59. struct audit_krule;
  60. struct user_namespace;
  61. struct timezone;
  62. /* These functions are in security/commoncap.c */
  63. extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
  64. int cap, int audit);
  65. extern int cap_settime(const struct timespec *ts, const struct timezone *tz);
  66. extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
  67. extern int cap_ptrace_traceme(struct task_struct *parent);
  68. extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
  69. extern int cap_capset(struct cred *new, const struct cred *old,
  70. const kernel_cap_t *effective,
  71. const kernel_cap_t *inheritable,
  72. const kernel_cap_t *permitted);
  73. extern int cap_bprm_set_creds(struct linux_binprm *bprm);
  74. extern int cap_bprm_secureexec(struct linux_binprm *bprm);
  75. extern int cap_inode_setxattr(struct dentry *dentry, const char *name,
  76. const void *value, size_t size, int flags);
  77. extern int cap_inode_removexattr(struct dentry *dentry, const char *name);
  78. extern int cap_inode_need_killpriv(struct dentry *dentry);
  79. extern int cap_inode_killpriv(struct dentry *dentry);
  80. extern int cap_mmap_addr(unsigned long addr);
  81. extern int cap_mmap_file(struct file *file, unsigned long reqprot,
  82. unsigned long prot, unsigned long flags);
  83. extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
  84. extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
  85. unsigned long arg4, unsigned long arg5);
  86. extern int cap_task_setscheduler(struct task_struct *p);
  87. extern int cap_task_setioprio(struct task_struct *p, int ioprio);
  88. extern int cap_task_setnice(struct task_struct *p, int nice);
  89. extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
  90. struct msghdr;
  91. struct sk_buff;
  92. struct sock;
  93. struct sockaddr;
  94. struct socket;
  95. struct flowi;
  96. struct dst_entry;
  97. struct xfrm_selector;
  98. struct xfrm_policy;
  99. struct xfrm_state;
  100. struct xfrm_user_sec_ctx;
  101. struct seq_file;
  102. #ifdef CONFIG_MMU
  103. extern unsigned long mmap_min_addr;
  104. extern unsigned long dac_mmap_min_addr;
  105. #else
  106. #define mmap_min_addr 0UL
  107. #define dac_mmap_min_addr 0UL
  108. #endif
  109. /*
  110. * Values used in the task_security_ops calls
  111. */
  112. /* setuid or setgid, id0 == uid or gid */
  113. #define LSM_SETID_ID 1
  114. /* setreuid or setregid, id0 == real, id1 == eff */
  115. #define LSM_SETID_RE 2
  116. /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
  117. #define LSM_SETID_RES 4
  118. /* setfsuid or setfsgid, id0 == fsuid or fsgid */
  119. #define LSM_SETID_FS 8
  120. /* forward declares to avoid warnings */
  121. struct sched_param;
  122. struct request_sock;
  123. /* bprm->unsafe reasons */
  124. #define LSM_UNSAFE_SHARE 1
  125. #define LSM_UNSAFE_PTRACE 2
  126. #define LSM_UNSAFE_PTRACE_CAP 4
  127. #define LSM_UNSAFE_NO_NEW_PRIVS 8
  128. #ifdef CONFIG_MMU
  129. extern int mmap_min_addr_handler(struct ctl_table *table, int write,
  130. void __user *buffer, size_t *lenp, loff_t *ppos);
  131. #endif
  132. /* security_inode_init_security callback function to write xattrs */
  133. typedef int (*initxattrs) (struct inode *inode,
  134. const struct xattr *xattr_array, void *fs_data);
  135. #ifdef CONFIG_SECURITY
  136. struct security_mnt_opts {
  137. char **mnt_opts;
  138. int *mnt_opts_flags;
  139. int num_mnt_opts;
  140. };
  141. static inline void security_init_mnt_opts(struct security_mnt_opts *opts)
  142. {
  143. opts->mnt_opts = NULL;
  144. opts->mnt_opts_flags = NULL;
  145. opts->num_mnt_opts = 0;
  146. }
  147. static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
  148. {
  149. int i;
  150. if (opts->mnt_opts)
  151. for (i = 0; i < opts->num_mnt_opts; i++)
  152. kfree(opts->mnt_opts[i]);
  153. kfree(opts->mnt_opts);
  154. opts->mnt_opts = NULL;
  155. kfree(opts->mnt_opts_flags);
  156. opts->mnt_opts_flags = NULL;
  157. opts->num_mnt_opts = 0;
  158. }
  159. /* prototypes */
  160. extern int security_init(void);
  161. /* Security operations */
  162. int security_binder_set_context_mgr(struct task_struct *mgr);
  163. int security_binder_transaction(struct task_struct *from,
  164. struct task_struct *to);
  165. int security_binder_transfer_binder(struct task_struct *from,
  166. struct task_struct *to);
  167. int security_binder_transfer_file(struct task_struct *from,
  168. struct task_struct *to, struct file *file);
  169. int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
  170. int security_ptrace_traceme(struct task_struct *parent);
  171. int security_capget(struct task_struct *target,
  172. kernel_cap_t *effective,
  173. kernel_cap_t *inheritable,
  174. kernel_cap_t *permitted);
  175. int security_capset(struct cred *new, const struct cred *old,
  176. const kernel_cap_t *effective,
  177. const kernel_cap_t *inheritable,
  178. const kernel_cap_t *permitted);
  179. int security_capable(const struct cred *cred, struct user_namespace *ns,
  180. int cap);
  181. int security_capable_noaudit(const struct cred *cred, struct user_namespace *ns,
  182. int cap);
  183. int security_quotactl(int cmds, int type, int id, struct super_block *sb);
  184. int security_quota_on(struct dentry *dentry);
  185. int security_syslog(int type);
  186. int security_settime(const struct timespec *ts, const struct timezone *tz);
  187. int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
  188. int security_bprm_set_creds(struct linux_binprm *bprm);
  189. int security_bprm_check(struct linux_binprm *bprm);
  190. void security_bprm_committing_creds(struct linux_binprm *bprm);
  191. void security_bprm_committed_creds(struct linux_binprm *bprm);
  192. int security_bprm_secureexec(struct linux_binprm *bprm);
  193. int security_sb_alloc(struct super_block *sb);
  194. void security_sb_free(struct super_block *sb);
  195. int security_sb_copy_data(char *orig, char *copy);
  196. int security_sb_remount(struct super_block *sb, void *data);
  197. int security_sb_kern_mount(struct super_block *sb, int flags, void *data);
  198. int security_sb_show_options(struct seq_file *m, struct super_block *sb);
  199. int security_sb_statfs(struct dentry *dentry);
  200. int security_sb_mount(const char *dev_name, struct path *path,
  201. const char *type, unsigned long flags, void *data);
  202. int security_sb_umount(struct vfsmount *mnt, int flags);
  203. int security_sb_pivotroot(struct path *old_path, struct path *new_path);
  204. int security_sb_set_mnt_opts(struct super_block *sb,
  205. struct security_mnt_opts *opts,
  206. unsigned long kern_flags,
  207. unsigned long *set_kern_flags);
  208. int security_sb_clone_mnt_opts(const struct super_block *oldsb,
  209. struct super_block *newsb);
  210. int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts);
  211. int security_dentry_init_security(struct dentry *dentry, int mode,
  212. struct qstr *name, void **ctx,
  213. u32 *ctxlen);
  214. int security_inode_alloc(struct inode *inode);
  215. void security_inode_free(struct inode *inode);
  216. int security_inode_init_security(struct inode *inode, struct inode *dir,
  217. const struct qstr *qstr,
  218. initxattrs initxattrs, void *fs_data);
  219. int security_old_inode_init_security(struct inode *inode, struct inode *dir,
  220. const struct qstr *qstr, const char **name,
  221. void **value, size_t *len);
  222. int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
  223. int security_inode_link(struct dentry *old_dentry, struct inode *dir,
  224. struct dentry *new_dentry);
  225. int security_inode_unlink(struct inode *dir, struct dentry *dentry);
  226. int security_inode_symlink(struct inode *dir, struct dentry *dentry,
  227. const char *old_name);
  228. int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
  229. int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
  230. int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
  231. int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
  232. struct inode *new_dir, struct dentry *new_dentry,
  233. unsigned int flags);
  234. int security_inode_readlink(struct dentry *dentry);
  235. int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
  236. bool rcu);
  237. int security_inode_permission(struct inode *inode, int mask);
  238. int security_inode_setattr(struct dentry *dentry, struct iattr *attr);
  239. int security_inode_getattr(const struct path *path);
  240. int security_inode_setxattr(struct dentry *dentry, const char *name,
  241. const void *value, size_t size, int flags);
  242. void security_inode_post_setxattr(struct dentry *dentry, const char *name,
  243. const void *value, size_t size, int flags);
  244. int security_inode_getxattr(struct dentry *dentry, const char *name);
  245. int security_inode_listxattr(struct dentry *dentry);
  246. int security_inode_removexattr(struct dentry *dentry, const char *name);
  247. int security_inode_need_killpriv(struct dentry *dentry);
  248. int security_inode_killpriv(struct dentry *dentry);
  249. int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc);
  250. int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
  251. int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
  252. void security_inode_getsecid(const struct inode *inode, u32 *secid);
  253. int security_file_permission(struct file *file, int mask);
  254. int security_file_alloc(struct file *file);
  255. void security_file_free(struct file *file);
  256. int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
  257. int security_mmap_file(struct file *file, unsigned long prot,
  258. unsigned long flags);
  259. int security_mmap_addr(unsigned long addr);
  260. int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
  261. unsigned long prot);
  262. int security_file_lock(struct file *file, unsigned int cmd);
  263. int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
  264. void security_file_set_fowner(struct file *file);
  265. int security_file_send_sigiotask(struct task_struct *tsk,
  266. struct fown_struct *fown, int sig);
  267. int security_file_receive(struct file *file);
  268. int security_file_open(struct file *file, const struct cred *cred);
  269. int security_task_create(unsigned long clone_flags);
  270. void security_task_free(struct task_struct *task);
  271. int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
  272. void security_cred_free(struct cred *cred);
  273. int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
  274. void security_transfer_creds(struct cred *new, const struct cred *old);
  275. int security_kernel_act_as(struct cred *new, u32 secid);
  276. int security_kernel_create_files_as(struct cred *new, struct inode *inode);
  277. int security_kernel_fw_from_file(struct file *file, char *buf, size_t size);
  278. int security_kernel_module_request(char *kmod_name);
  279. int security_kernel_module_from_file(struct file *file);
  280. int security_task_fix_setuid(struct cred *new, const struct cred *old,
  281. int flags);
  282. int security_task_setpgid(struct task_struct *p, pid_t pgid);
  283. int security_task_getpgid(struct task_struct *p);
  284. int security_task_getsid(struct task_struct *p);
  285. void security_task_getsecid(struct task_struct *p, u32 *secid);
  286. int security_task_setnice(struct task_struct *p, int nice);
  287. int security_task_setioprio(struct task_struct *p, int ioprio);
  288. int security_task_getioprio(struct task_struct *p);
  289. int security_task_setrlimit(struct task_struct *p, unsigned int resource,
  290. struct rlimit *new_rlim);
  291. int security_task_setscheduler(struct task_struct *p);
  292. int security_task_getscheduler(struct task_struct *p);
  293. int security_task_movememory(struct task_struct *p);
  294. int security_task_kill(struct task_struct *p, struct siginfo *info,
  295. int sig, u32 secid);
  296. int security_task_wait(struct task_struct *p);
  297. int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
  298. unsigned long arg4, unsigned long arg5);
  299. void security_task_to_inode(struct task_struct *p, struct inode *inode);
  300. int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
  301. void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
  302. int security_msg_msg_alloc(struct msg_msg *msg);
  303. void security_msg_msg_free(struct msg_msg *msg);
  304. int security_msg_queue_alloc(struct msg_queue *msq);
  305. void security_msg_queue_free(struct msg_queue *msq);
  306. int security_msg_queue_associate(struct msg_queue *msq, int msqflg);
  307. int security_msg_queue_msgctl(struct msg_queue *msq, int cmd);
  308. int security_msg_queue_msgsnd(struct msg_queue *msq,
  309. struct msg_msg *msg, int msqflg);
  310. int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
  311. struct task_struct *target, long type, int mode);
  312. int security_shm_alloc(struct shmid_kernel *shp);
  313. void security_shm_free(struct shmid_kernel *shp);
  314. int security_shm_associate(struct shmid_kernel *shp, int shmflg);
  315. int security_shm_shmctl(struct shmid_kernel *shp, int cmd);
  316. int security_shm_shmat(struct shmid_kernel *shp, char __user *shmaddr, int shmflg);
  317. int security_sem_alloc(struct sem_array *sma);
  318. void security_sem_free(struct sem_array *sma);
  319. int security_sem_associate(struct sem_array *sma, int semflg);
  320. int security_sem_semctl(struct sem_array *sma, int cmd);
  321. int security_sem_semop(struct sem_array *sma, struct sembuf *sops,
  322. unsigned nsops, int alter);
  323. void security_d_instantiate(struct dentry *dentry, struct inode *inode);
  324. int security_getprocattr(struct task_struct *p, char *name, char **value);
  325. int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size);
  326. int security_netlink_send(struct sock *sk, struct sk_buff *skb);
  327. int security_ismaclabel(const char *name);
  328. int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
  329. int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
  330. void security_release_secctx(char *secdata, u32 seclen);
  331. int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
  332. int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
  333. int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
  334. #else /* CONFIG_SECURITY */
  335. struct security_mnt_opts {
  336. };
  337. static inline void security_init_mnt_opts(struct security_mnt_opts *opts)
  338. {
  339. }
  340. static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
  341. {
  342. }
  343. /*
  344. * This is the default capabilities functionality. Most of these functions
  345. * are just stubbed out, but a few must call the proper capable code.
  346. */
  347. static inline int security_init(void)
  348. {
  349. return 0;
  350. }
  351. static inline int security_binder_set_context_mgr(struct task_struct *mgr)
  352. {
  353. return 0;
  354. }
  355. static inline int security_binder_transaction(struct task_struct *from,
  356. struct task_struct *to)
  357. {
  358. return 0;
  359. }
  360. static inline int security_binder_transfer_binder(struct task_struct *from,
  361. struct task_struct *to)
  362. {
  363. return 0;
  364. }
  365. static inline int security_binder_transfer_file(struct task_struct *from,
  366. struct task_struct *to,
  367. struct file *file)
  368. {
  369. return 0;
  370. }
  371. static inline int security_ptrace_access_check(struct task_struct *child,
  372. unsigned int mode)
  373. {
  374. return cap_ptrace_access_check(child, mode);
  375. }
  376. static inline int security_ptrace_traceme(struct task_struct *parent)
  377. {
  378. return cap_ptrace_traceme(parent);
  379. }
  380. static inline int security_capget(struct task_struct *target,
  381. kernel_cap_t *effective,
  382. kernel_cap_t *inheritable,
  383. kernel_cap_t *permitted)
  384. {
  385. return cap_capget(target, effective, inheritable, permitted);
  386. }
  387. static inline int security_capset(struct cred *new,
  388. const struct cred *old,
  389. const kernel_cap_t *effective,
  390. const kernel_cap_t *inheritable,
  391. const kernel_cap_t *permitted)
  392. {
  393. return cap_capset(new, old, effective, inheritable, permitted);
  394. }
  395. static inline int security_capable(const struct cred *cred,
  396. struct user_namespace *ns, int cap)
  397. {
  398. return cap_capable(cred, ns, cap, SECURITY_CAP_AUDIT);
  399. }
  400. static inline int security_capable_noaudit(const struct cred *cred,
  401. struct user_namespace *ns, int cap) {
  402. return cap_capable(cred, ns, cap, SECURITY_CAP_NOAUDIT);
  403. }
  404. static inline int security_quotactl(int cmds, int type, int id,
  405. struct super_block *sb)
  406. {
  407. return 0;
  408. }
  409. static inline int security_quota_on(struct dentry *dentry)
  410. {
  411. return 0;
  412. }
  413. static inline int security_syslog(int type)
  414. {
  415. return 0;
  416. }
  417. static inline int security_settime(const struct timespec *ts,
  418. const struct timezone *tz)
  419. {
  420. return cap_settime(ts, tz);
  421. }
  422. static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
  423. {
  424. return __vm_enough_memory(mm, pages, cap_vm_enough_memory(mm, pages));
  425. }
  426. static inline int security_bprm_set_creds(struct linux_binprm *bprm)
  427. {
  428. return cap_bprm_set_creds(bprm);
  429. }
  430. static inline int security_bprm_check(struct linux_binprm *bprm)
  431. {
  432. return 0;
  433. }
  434. static inline void security_bprm_committing_creds(struct linux_binprm *bprm)
  435. {
  436. }
  437. static inline void security_bprm_committed_creds(struct linux_binprm *bprm)
  438. {
  439. }
  440. static inline int security_bprm_secureexec(struct linux_binprm *bprm)
  441. {
  442. return cap_bprm_secureexec(bprm);
  443. }
  444. static inline int security_sb_alloc(struct super_block *sb)
  445. {
  446. return 0;
  447. }
  448. static inline void security_sb_free(struct super_block *sb)
  449. { }
  450. static inline int security_sb_copy_data(char *orig, char *copy)
  451. {
  452. return 0;
  453. }
  454. static inline int security_sb_remount(struct super_block *sb, void *data)
  455. {
  456. return 0;
  457. }
  458. static inline int security_sb_kern_mount(struct super_block *sb, int flags, void *data)
  459. {
  460. return 0;
  461. }
  462. static inline int security_sb_show_options(struct seq_file *m,
  463. struct super_block *sb)
  464. {
  465. return 0;
  466. }
  467. static inline int security_sb_statfs(struct dentry *dentry)
  468. {
  469. return 0;
  470. }
  471. static inline int security_sb_mount(const char *dev_name, struct path *path,
  472. const char *type, unsigned long flags,
  473. void *data)
  474. {
  475. return 0;
  476. }
  477. static inline int security_sb_umount(struct vfsmount *mnt, int flags)
  478. {
  479. return 0;
  480. }
  481. static inline int security_sb_pivotroot(struct path *old_path,
  482. struct path *new_path)
  483. {
  484. return 0;
  485. }
  486. static inline int security_sb_set_mnt_opts(struct super_block *sb,
  487. struct security_mnt_opts *opts,
  488. unsigned long kern_flags,
  489. unsigned long *set_kern_flags)
  490. {
  491. return 0;
  492. }
  493. static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb,
  494. struct super_block *newsb)
  495. {
  496. return 0;
  497. }
  498. static inline int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts)
  499. {
  500. return 0;
  501. }
  502. static inline int security_inode_alloc(struct inode *inode)
  503. {
  504. return 0;
  505. }
  506. static inline void security_inode_free(struct inode *inode)
  507. { }
  508. static inline int security_dentry_init_security(struct dentry *dentry,
  509. int mode,
  510. struct qstr *name,
  511. void **ctx,
  512. u32 *ctxlen)
  513. {
  514. return -EOPNOTSUPP;
  515. }
  516. static inline int security_inode_init_security(struct inode *inode,
  517. struct inode *dir,
  518. const struct qstr *qstr,
  519. const initxattrs xattrs,
  520. void *fs_data)
  521. {
  522. return 0;
  523. }
  524. static inline int security_old_inode_init_security(struct inode *inode,
  525. struct inode *dir,
  526. const struct qstr *qstr,
  527. const char **name,
  528. void **value, size_t *len)
  529. {
  530. return -EOPNOTSUPP;
  531. }
  532. static inline int security_inode_create(struct inode *dir,
  533. struct dentry *dentry,
  534. umode_t mode)
  535. {
  536. return 0;
  537. }
  538. static inline int security_inode_link(struct dentry *old_dentry,
  539. struct inode *dir,
  540. struct dentry *new_dentry)
  541. {
  542. return 0;
  543. }
  544. static inline int security_inode_unlink(struct inode *dir,
  545. struct dentry *dentry)
  546. {
  547. return 0;
  548. }
  549. static inline int security_inode_symlink(struct inode *dir,
  550. struct dentry *dentry,
  551. const char *old_name)
  552. {
  553. return 0;
  554. }
  555. static inline int security_inode_mkdir(struct inode *dir,
  556. struct dentry *dentry,
  557. int mode)
  558. {
  559. return 0;
  560. }
  561. static inline int security_inode_rmdir(struct inode *dir,
  562. struct dentry *dentry)
  563. {
  564. return 0;
  565. }
  566. static inline int security_inode_mknod(struct inode *dir,
  567. struct dentry *dentry,
  568. int mode, dev_t dev)
  569. {
  570. return 0;
  571. }
  572. static inline int security_inode_rename(struct inode *old_dir,
  573. struct dentry *old_dentry,
  574. struct inode *new_dir,
  575. struct dentry *new_dentry,
  576. unsigned int flags)
  577. {
  578. return 0;
  579. }
  580. static inline int security_inode_readlink(struct dentry *dentry)
  581. {
  582. return 0;
  583. }
  584. static inline int security_inode_follow_link(struct dentry *dentry,
  585. struct inode *inode,
  586. bool rcu)
  587. {
  588. return 0;
  589. }
  590. static inline int security_inode_permission(struct inode *inode, int mask)
  591. {
  592. return 0;
  593. }
  594. static inline int security_inode_setattr(struct dentry *dentry,
  595. struct iattr *attr)
  596. {
  597. return 0;
  598. }
  599. static inline int security_inode_getattr(const struct path *path)
  600. {
  601. return 0;
  602. }
  603. static inline int security_inode_setxattr(struct dentry *dentry,
  604. const char *name, const void *value, size_t size, int flags)
  605. {
  606. return cap_inode_setxattr(dentry, name, value, size, flags);
  607. }
  608. static inline void security_inode_post_setxattr(struct dentry *dentry,
  609. const char *name, const void *value, size_t size, int flags)
  610. { }
  611. static inline int security_inode_getxattr(struct dentry *dentry,
  612. const char *name)
  613. {
  614. return 0;
  615. }
  616. static inline int security_inode_listxattr(struct dentry *dentry)
  617. {
  618. return 0;
  619. }
  620. static inline int security_inode_removexattr(struct dentry *dentry,
  621. const char *name)
  622. {
  623. return cap_inode_removexattr(dentry, name);
  624. }
  625. static inline int security_inode_need_killpriv(struct dentry *dentry)
  626. {
  627. return cap_inode_need_killpriv(dentry);
  628. }
  629. static inline int security_inode_killpriv(struct dentry *dentry)
  630. {
  631. return cap_inode_killpriv(dentry);
  632. }
  633. static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc)
  634. {
  635. return -EOPNOTSUPP;
  636. }
  637. static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
  638. {
  639. return -EOPNOTSUPP;
  640. }
  641. static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
  642. {
  643. return 0;
  644. }
  645. static inline void security_inode_getsecid(const struct inode *inode, u32 *secid)
  646. {
  647. *secid = 0;
  648. }
  649. static inline int security_file_permission(struct file *file, int mask)
  650. {
  651. return 0;
  652. }
  653. static inline int security_file_alloc(struct file *file)
  654. {
  655. return 0;
  656. }
  657. static inline void security_file_free(struct file *file)
  658. { }
  659. static inline int security_file_ioctl(struct file *file, unsigned int cmd,
  660. unsigned long arg)
  661. {
  662. return 0;
  663. }
  664. static inline int security_mmap_file(struct file *file, unsigned long prot,
  665. unsigned long flags)
  666. {
  667. return 0;
  668. }
  669. static inline int security_mmap_addr(unsigned long addr)
  670. {
  671. return cap_mmap_addr(addr);
  672. }
  673. static inline int security_file_mprotect(struct vm_area_struct *vma,
  674. unsigned long reqprot,
  675. unsigned long prot)
  676. {
  677. return 0;
  678. }
  679. static inline int security_file_lock(struct file *file, unsigned int cmd)
  680. {
  681. return 0;
  682. }
  683. static inline int security_file_fcntl(struct file *file, unsigned int cmd,
  684. unsigned long arg)
  685. {
  686. return 0;
  687. }
  688. static inline void security_file_set_fowner(struct file *file)
  689. {
  690. return;
  691. }
  692. static inline int security_file_send_sigiotask(struct task_struct *tsk,
  693. struct fown_struct *fown,
  694. int sig)
  695. {
  696. return 0;
  697. }
  698. static inline int security_file_receive(struct file *file)
  699. {
  700. return 0;
  701. }
  702. static inline int security_file_open(struct file *file,
  703. const struct cred *cred)
  704. {
  705. return 0;
  706. }
  707. static inline int security_task_create(unsigned long clone_flags)
  708. {
  709. return 0;
  710. }
  711. static inline void security_task_free(struct task_struct *task)
  712. { }
  713. static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
  714. {
  715. return 0;
  716. }
  717. static inline void security_cred_free(struct cred *cred)
  718. { }
  719. static inline int security_prepare_creds(struct cred *new,
  720. const struct cred *old,
  721. gfp_t gfp)
  722. {
  723. return 0;
  724. }
  725. static inline void security_transfer_creds(struct cred *new,
  726. const struct cred *old)
  727. {
  728. }
  729. static inline int security_kernel_act_as(struct cred *cred, u32 secid)
  730. {
  731. return 0;
  732. }
  733. static inline int security_kernel_create_files_as(struct cred *cred,
  734. struct inode *inode)
  735. {
  736. return 0;
  737. }
  738. static inline int security_kernel_fw_from_file(struct file *file,
  739. char *buf, size_t size)
  740. {
  741. return 0;
  742. }
  743. static inline int security_kernel_module_request(char *kmod_name)
  744. {
  745. return 0;
  746. }
  747. static inline int security_kernel_module_from_file(struct file *file)
  748. {
  749. return 0;
  750. }
  751. static inline int security_task_fix_setuid(struct cred *new,
  752. const struct cred *old,
  753. int flags)
  754. {
  755. return cap_task_fix_setuid(new, old, flags);
  756. }
  757. static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
  758. {
  759. return 0;
  760. }
  761. static inline int security_task_getpgid(struct task_struct *p)
  762. {
  763. return 0;
  764. }
  765. static inline int security_task_getsid(struct task_struct *p)
  766. {
  767. return 0;
  768. }
  769. static inline void security_task_getsecid(struct task_struct *p, u32 *secid)
  770. {
  771. *secid = 0;
  772. }
  773. static inline int security_task_setnice(struct task_struct *p, int nice)
  774. {
  775. return cap_task_setnice(p, nice);
  776. }
  777. static inline int security_task_setioprio(struct task_struct *p, int ioprio)
  778. {
  779. return cap_task_setioprio(p, ioprio);
  780. }
  781. static inline int security_task_getioprio(struct task_struct *p)
  782. {
  783. return 0;
  784. }
  785. static inline int security_task_setrlimit(struct task_struct *p,
  786. unsigned int resource,
  787. struct rlimit *new_rlim)
  788. {
  789. return 0;
  790. }
  791. static inline int security_task_setscheduler(struct task_struct *p)
  792. {
  793. return cap_task_setscheduler(p);
  794. }
  795. static inline int security_task_getscheduler(struct task_struct *p)
  796. {
  797. return 0;
  798. }
  799. static inline int security_task_movememory(struct task_struct *p)
  800. {
  801. return 0;
  802. }
  803. static inline int security_task_kill(struct task_struct *p,
  804. struct siginfo *info, int sig,
  805. u32 secid)
  806. {
  807. return 0;
  808. }
  809. static inline int security_task_wait(struct task_struct *p)
  810. {
  811. return 0;
  812. }
  813. static inline int security_task_prctl(int option, unsigned long arg2,
  814. unsigned long arg3,
  815. unsigned long arg4,
  816. unsigned long arg5)
  817. {
  818. return cap_task_prctl(option, arg2, arg3, arg4, arg5);
  819. }
  820. static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
  821. { }
  822. static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
  823. short flag)
  824. {
  825. return 0;
  826. }
  827. static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
  828. {
  829. *secid = 0;
  830. }
  831. static inline int security_msg_msg_alloc(struct msg_msg *msg)
  832. {
  833. return 0;
  834. }
  835. static inline void security_msg_msg_free(struct msg_msg *msg)
  836. { }
  837. static inline int security_msg_queue_alloc(struct msg_queue *msq)
  838. {
  839. return 0;
  840. }
  841. static inline void security_msg_queue_free(struct msg_queue *msq)
  842. { }
  843. static inline int security_msg_queue_associate(struct msg_queue *msq,
  844. int msqflg)
  845. {
  846. return 0;
  847. }
  848. static inline int security_msg_queue_msgctl(struct msg_queue *msq, int cmd)
  849. {
  850. return 0;
  851. }
  852. static inline int security_msg_queue_msgsnd(struct msg_queue *msq,
  853. struct msg_msg *msg, int msqflg)
  854. {
  855. return 0;
  856. }
  857. static inline int security_msg_queue_msgrcv(struct msg_queue *msq,
  858. struct msg_msg *msg,
  859. struct task_struct *target,
  860. long type, int mode)
  861. {
  862. return 0;
  863. }
  864. static inline int security_shm_alloc(struct shmid_kernel *shp)
  865. {
  866. return 0;
  867. }
  868. static inline void security_shm_free(struct shmid_kernel *shp)
  869. { }
  870. static inline int security_shm_associate(struct shmid_kernel *shp,
  871. int shmflg)
  872. {
  873. return 0;
  874. }
  875. static inline int security_shm_shmctl(struct shmid_kernel *shp, int cmd)
  876. {
  877. return 0;
  878. }
  879. static inline int security_shm_shmat(struct shmid_kernel *shp,
  880. char __user *shmaddr, int shmflg)
  881. {
  882. return 0;
  883. }
  884. static inline int security_sem_alloc(struct sem_array *sma)
  885. {
  886. return 0;
  887. }
  888. static inline void security_sem_free(struct sem_array *sma)
  889. { }
  890. static inline int security_sem_associate(struct sem_array *sma, int semflg)
  891. {
  892. return 0;
  893. }
  894. static inline int security_sem_semctl(struct sem_array *sma, int cmd)
  895. {
  896. return 0;
  897. }
  898. static inline int security_sem_semop(struct sem_array *sma,
  899. struct sembuf *sops, unsigned nsops,
  900. int alter)
  901. {
  902. return 0;
  903. }
  904. static inline void security_d_instantiate(struct dentry *dentry, struct inode *inode)
  905. { }
  906. static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
  907. {
  908. return -EINVAL;
  909. }
  910. static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
  911. {
  912. return -EINVAL;
  913. }
  914. static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
  915. {
  916. return 0;
  917. }
  918. static inline int security_ismaclabel(const char *name)
  919. {
  920. return 0;
  921. }
  922. static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
  923. {
  924. return -EOPNOTSUPP;
  925. }
  926. static inline int security_secctx_to_secid(const char *secdata,
  927. u32 seclen,
  928. u32 *secid)
  929. {
  930. return -EOPNOTSUPP;
  931. }
  932. static inline void security_release_secctx(char *secdata, u32 seclen)
  933. {
  934. }
  935. static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
  936. {
  937. return -EOPNOTSUPP;
  938. }
  939. static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
  940. {
  941. return -EOPNOTSUPP;
  942. }
  943. static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
  944. {
  945. return -EOPNOTSUPP;
  946. }
  947. #endif /* CONFIG_SECURITY */
  948. #ifdef CONFIG_SECURITY_NETWORK
  949. int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
  950. int security_unix_may_send(struct socket *sock, struct socket *other);
  951. int security_socket_create(int family, int type, int protocol, int kern);
  952. int security_socket_post_create(struct socket *sock, int family,
  953. int type, int protocol, int kern);
  954. int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
  955. int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
  956. int security_socket_listen(struct socket *sock, int backlog);
  957. int security_socket_accept(struct socket *sock, struct socket *newsock);
  958. int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
  959. int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
  960. int size, int flags);
  961. int security_socket_getsockname(struct socket *sock);
  962. int security_socket_getpeername(struct socket *sock);
  963. int security_socket_getsockopt(struct socket *sock, int level, int optname);
  964. int security_socket_setsockopt(struct socket *sock, int level, int optname);
  965. int security_socket_shutdown(struct socket *sock, int how);
  966. int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
  967. int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
  968. int __user *optlen, unsigned len);
  969. int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
  970. int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
  971. void security_sk_free(struct sock *sk);
  972. void security_sk_clone(const struct sock *sk, struct sock *newsk);
  973. void security_sk_classify_flow(struct sock *sk, struct flowi *fl);
  974. void security_req_classify_flow(const struct request_sock *req, struct flowi *fl);
  975. void security_sock_graft(struct sock*sk, struct socket *parent);
  976. int security_inet_conn_request(struct sock *sk,
  977. struct sk_buff *skb, struct request_sock *req);
  978. void security_inet_csk_clone(struct sock *newsk,
  979. const struct request_sock *req);
  980. void security_inet_conn_established(struct sock *sk,
  981. struct sk_buff *skb);
  982. int security_secmark_relabel_packet(u32 secid);
  983. void security_secmark_refcount_inc(void);
  984. void security_secmark_refcount_dec(void);
  985. int security_tun_dev_alloc_security(void **security);
  986. void security_tun_dev_free_security(void *security);
  987. int security_tun_dev_create(void);
  988. int security_tun_dev_attach_queue(void *security);
  989. int security_tun_dev_attach(struct sock *sk, void *security);
  990. int security_tun_dev_open(void *security);
  991. #else /* CONFIG_SECURITY_NETWORK */
  992. static inline int security_unix_stream_connect(struct sock *sock,
  993. struct sock *other,
  994. struct sock *newsk)
  995. {
  996. return 0;
  997. }
  998. static inline int security_unix_may_send(struct socket *sock,
  999. struct socket *other)
  1000. {
  1001. return 0;
  1002. }
  1003. static inline int security_socket_create(int family, int type,
  1004. int protocol, int kern)
  1005. {
  1006. return 0;
  1007. }
  1008. static inline int security_socket_post_create(struct socket *sock,
  1009. int family,
  1010. int type,
  1011. int protocol, int kern)
  1012. {
  1013. return 0;
  1014. }
  1015. static inline int security_socket_bind(struct socket *sock,
  1016. struct sockaddr *address,
  1017. int addrlen)
  1018. {
  1019. return 0;
  1020. }
  1021. static inline int security_socket_connect(struct socket *sock,
  1022. struct sockaddr *address,
  1023. int addrlen)
  1024. {
  1025. return 0;
  1026. }
  1027. static inline int security_socket_listen(struct socket *sock, int backlog)
  1028. {
  1029. return 0;
  1030. }
  1031. static inline int security_socket_accept(struct socket *sock,
  1032. struct socket *newsock)
  1033. {
  1034. return 0;
  1035. }
  1036. static inline int security_socket_sendmsg(struct socket *sock,
  1037. struct msghdr *msg, int size)
  1038. {
  1039. return 0;
  1040. }
  1041. static inline int security_socket_recvmsg(struct socket *sock,
  1042. struct msghdr *msg, int size,
  1043. int flags)
  1044. {
  1045. return 0;
  1046. }
  1047. static inline int security_socket_getsockname(struct socket *sock)
  1048. {
  1049. return 0;
  1050. }
  1051. static inline int security_socket_getpeername(struct socket *sock)
  1052. {
  1053. return 0;
  1054. }
  1055. static inline int security_socket_getsockopt(struct socket *sock,
  1056. int level, int optname)
  1057. {
  1058. return 0;
  1059. }
  1060. static inline int security_socket_setsockopt(struct socket *sock,
  1061. int level, int optname)
  1062. {
  1063. return 0;
  1064. }
  1065. static inline int security_socket_shutdown(struct socket *sock, int how)
  1066. {
  1067. return 0;
  1068. }
  1069. static inline int security_sock_rcv_skb(struct sock *sk,
  1070. struct sk_buff *skb)
  1071. {
  1072. return 0;
  1073. }
  1074. static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
  1075. int __user *optlen, unsigned len)
  1076. {
  1077. return -ENOPROTOOPT;
  1078. }
  1079. static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
  1080. {
  1081. return -ENOPROTOOPT;
  1082. }
  1083. static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
  1084. {
  1085. return 0;
  1086. }
  1087. static inline void security_sk_free(struct sock *sk)
  1088. {
  1089. }
  1090. static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
  1091. {
  1092. }
  1093. static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
  1094. {
  1095. }
  1096. static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
  1097. {
  1098. }
  1099. static inline void security_sock_graft(struct sock *sk, struct socket *parent)
  1100. {
  1101. }
  1102. static inline int security_inet_conn_request(struct sock *sk,
  1103. struct sk_buff *skb, struct request_sock *req)
  1104. {
  1105. return 0;
  1106. }
  1107. static inline void security_inet_csk_clone(struct sock *newsk,
  1108. const struct request_sock *req)
  1109. {
  1110. }
  1111. static inline void security_inet_conn_established(struct sock *sk,
  1112. struct sk_buff *skb)
  1113. {
  1114. }
  1115. static inline int security_secmark_relabel_packet(u32 secid)
  1116. {
  1117. return 0;
  1118. }
  1119. static inline void security_secmark_refcount_inc(void)
  1120. {
  1121. }
  1122. static inline void security_secmark_refcount_dec(void)
  1123. {
  1124. }
  1125. static inline int security_tun_dev_alloc_security(void **security)
  1126. {
  1127. return 0;
  1128. }
  1129. static inline void security_tun_dev_free_security(void *security)
  1130. {
  1131. }
  1132. static inline int security_tun_dev_create(void)
  1133. {
  1134. return 0;
  1135. }
  1136. static inline int security_tun_dev_attach_queue(void *security)
  1137. {
  1138. return 0;
  1139. }
  1140. static inline int security_tun_dev_attach(struct sock *sk, void *security)
  1141. {
  1142. return 0;
  1143. }
  1144. static inline int security_tun_dev_open(void *security)
  1145. {
  1146. return 0;
  1147. }
  1148. #endif /* CONFIG_SECURITY_NETWORK */
  1149. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  1150. int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
  1151. struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp);
  1152. int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
  1153. void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
  1154. int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
  1155. int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
  1156. int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
  1157. struct xfrm_sec_ctx *polsec, u32 secid);
  1158. int security_xfrm_state_delete(struct xfrm_state *x);
  1159. void security_xfrm_state_free(struct xfrm_state *x);
  1160. int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
  1161. int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
  1162. struct xfrm_policy *xp,
  1163. const struct flowi *fl);
  1164. int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
  1165. void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl);
  1166. #else /* CONFIG_SECURITY_NETWORK_XFRM */
  1167. static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
  1168. struct xfrm_user_sec_ctx *sec_ctx,
  1169. gfp_t gfp)
  1170. {
  1171. return 0;
  1172. }
  1173. static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
  1174. {
  1175. return 0;
  1176. }
  1177. static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
  1178. {
  1179. }
  1180. static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
  1181. {
  1182. return 0;
  1183. }
  1184. static inline int security_xfrm_state_alloc(struct xfrm_state *x,
  1185. struct xfrm_user_sec_ctx *sec_ctx)
  1186. {
  1187. return 0;
  1188. }
  1189. static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
  1190. struct xfrm_sec_ctx *polsec, u32 secid)
  1191. {
  1192. return 0;
  1193. }
  1194. static inline void security_xfrm_state_free(struct xfrm_state *x)
  1195. {
  1196. }
  1197. static inline int security_xfrm_state_delete(struct xfrm_state *x)
  1198. {
  1199. return 0;
  1200. }
  1201. static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir)
  1202. {
  1203. return 0;
  1204. }
  1205. static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
  1206. struct xfrm_policy *xp, const struct flowi *fl)
  1207. {
  1208. return 1;
  1209. }
  1210. static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
  1211. {
  1212. return 0;
  1213. }
  1214. static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
  1215. {
  1216. }
  1217. #endif /* CONFIG_SECURITY_NETWORK_XFRM */
  1218. #ifdef CONFIG_SECURITY_PATH
  1219. int security_path_unlink(struct path *dir, struct dentry *dentry);
  1220. int security_path_mkdir(struct path *dir, struct dentry *dentry, umode_t mode);
  1221. int security_path_rmdir(struct path *dir, struct dentry *dentry);
  1222. int security_path_mknod(struct path *dir, struct dentry *dentry, umode_t mode,
  1223. unsigned int dev);
  1224. int security_path_truncate(struct path *path);
  1225. int security_path_symlink(struct path *dir, struct dentry *dentry,
  1226. const char *old_name);
  1227. int security_path_link(struct dentry *old_dentry, struct path *new_dir,
  1228. struct dentry *new_dentry);
  1229. int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
  1230. struct path *new_dir, struct dentry *new_dentry,
  1231. unsigned int flags);
  1232. int security_path_chmod(struct path *path, umode_t mode);
  1233. int security_path_chown(struct path *path, kuid_t uid, kgid_t gid);
  1234. int security_path_chroot(struct path *path);
  1235. #else /* CONFIG_SECURITY_PATH */
  1236. static inline int security_path_unlink(struct path *dir, struct dentry *dentry)
  1237. {
  1238. return 0;
  1239. }
  1240. static inline int security_path_mkdir(struct path *dir, struct dentry *dentry,
  1241. umode_t mode)
  1242. {
  1243. return 0;
  1244. }
  1245. static inline int security_path_rmdir(struct path *dir, struct dentry *dentry)
  1246. {
  1247. return 0;
  1248. }
  1249. static inline int security_path_mknod(struct path *dir, struct dentry *dentry,
  1250. umode_t mode, unsigned int dev)
  1251. {
  1252. return 0;
  1253. }
  1254. static inline int security_path_truncate(struct path *path)
  1255. {
  1256. return 0;
  1257. }
  1258. static inline int security_path_symlink(struct path *dir, struct dentry *dentry,
  1259. const char *old_name)
  1260. {
  1261. return 0;
  1262. }
  1263. static inline int security_path_link(struct dentry *old_dentry,
  1264. struct path *new_dir,
  1265. struct dentry *new_dentry)
  1266. {
  1267. return 0;
  1268. }
  1269. static inline int security_path_rename(struct path *old_dir,
  1270. struct dentry *old_dentry,
  1271. struct path *new_dir,
  1272. struct dentry *new_dentry,
  1273. unsigned int flags)
  1274. {
  1275. return 0;
  1276. }
  1277. static inline int security_path_chmod(struct path *path, umode_t mode)
  1278. {
  1279. return 0;
  1280. }
  1281. static inline int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
  1282. {
  1283. return 0;
  1284. }
  1285. static inline int security_path_chroot(struct path *path)
  1286. {
  1287. return 0;
  1288. }
  1289. #endif /* CONFIG_SECURITY_PATH */
  1290. #ifdef CONFIG_KEYS
  1291. #ifdef CONFIG_SECURITY
  1292. int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
  1293. void security_key_free(struct key *key);
  1294. int security_key_permission(key_ref_t key_ref,
  1295. const struct cred *cred, unsigned perm);
  1296. int security_key_getsecurity(struct key *key, char **_buffer);
  1297. #else
  1298. static inline int security_key_alloc(struct key *key,
  1299. const struct cred *cred,
  1300. unsigned long flags)
  1301. {
  1302. return 0;
  1303. }
  1304. static inline void security_key_free(struct key *key)
  1305. {
  1306. }
  1307. static inline int security_key_permission(key_ref_t key_ref,
  1308. const struct cred *cred,
  1309. unsigned perm)
  1310. {
  1311. return 0;
  1312. }
  1313. static inline int security_key_getsecurity(struct key *key, char **_buffer)
  1314. {
  1315. *_buffer = NULL;
  1316. return 0;
  1317. }
  1318. #endif
  1319. #endif /* CONFIG_KEYS */
  1320. #ifdef CONFIG_AUDIT
  1321. #ifdef CONFIG_SECURITY
  1322. int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
  1323. int security_audit_rule_known(struct audit_krule *krule);
  1324. int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule,
  1325. struct audit_context *actx);
  1326. void security_audit_rule_free(void *lsmrule);
  1327. #else
  1328. static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
  1329. void **lsmrule)
  1330. {
  1331. return 0;
  1332. }
  1333. static inline int security_audit_rule_known(struct audit_krule *krule)
  1334. {
  1335. return 0;
  1336. }
  1337. static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
  1338. void *lsmrule, struct audit_context *actx)
  1339. {
  1340. return 0;
  1341. }
  1342. static inline void security_audit_rule_free(void *lsmrule)
  1343. { }
  1344. #endif /* CONFIG_SECURITY */
  1345. #endif /* CONFIG_AUDIT */
  1346. #ifdef CONFIG_SECURITYFS
  1347. extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
  1348. struct dentry *parent, void *data,
  1349. const struct file_operations *fops);
  1350. extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
  1351. extern void securityfs_remove(struct dentry *dentry);
  1352. #else /* CONFIG_SECURITYFS */
  1353. static inline struct dentry *securityfs_create_dir(const char *name,
  1354. struct dentry *parent)
  1355. {
  1356. return ERR_PTR(-ENODEV);
  1357. }
  1358. static inline struct dentry *securityfs_create_file(const char *name,
  1359. umode_t mode,
  1360. struct dentry *parent,
  1361. void *data,
  1362. const struct file_operations *fops)
  1363. {
  1364. return ERR_PTR(-ENODEV);
  1365. }
  1366. static inline void securityfs_remove(struct dentry *dentry)
  1367. {}
  1368. #endif
  1369. #ifdef CONFIG_SECURITY
  1370. static inline char *alloc_secdata(void)
  1371. {
  1372. return (char *)get_zeroed_page(GFP_KERNEL);
  1373. }
  1374. static inline void free_secdata(void *secdata)
  1375. {
  1376. free_page((unsigned long)secdata);
  1377. }
  1378. #else
  1379. static inline char *alloc_secdata(void)
  1380. {
  1381. return (char *)1;
  1382. }
  1383. static inline void free_secdata(void *secdata)
  1384. { }
  1385. #endif /* CONFIG_SECURITY */
  1386. #endif /* ! __LINUX_SECURITY_H */