security.h 43 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640
  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 nameidata;
  45. struct iattr;
  46. struct fown_struct;
  47. struct file_operations;
  48. struct shmid_kernel;
  49. struct msg_msg;
  50. struct msg_queue;
  51. struct xattr;
  52. struct xfrm_sec_ctx;
  53. struct mm_struct;
  54. /* If capable should audit the security request */
  55. #define SECURITY_CAP_NOAUDIT 0
  56. #define SECURITY_CAP_AUDIT 1
  57. /* LSM Agnostic defines for sb_set_mnt_opts */
  58. #define SECURITY_LSM_NATIVE_LABELS 1
  59. struct ctl_table;
  60. struct audit_krule;
  61. struct user_namespace;
  62. struct timezone;
  63. /* These functions are in security/commoncap.c */
  64. extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
  65. int cap, int audit);
  66. extern int cap_settime(const struct timespec *ts, const struct timezone *tz);
  67. extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
  68. extern int cap_ptrace_traceme(struct task_struct *parent);
  69. extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
  70. extern int cap_capset(struct cred *new, const struct cred *old,
  71. const kernel_cap_t *effective,
  72. const kernel_cap_t *inheritable,
  73. const kernel_cap_t *permitted);
  74. extern int cap_bprm_set_creds(struct linux_binprm *bprm);
  75. extern int cap_bprm_secureexec(struct linux_binprm *bprm);
  76. extern int cap_inode_setxattr(struct dentry *dentry, const char *name,
  77. const void *value, size_t size, int flags);
  78. extern int cap_inode_removexattr(struct dentry *dentry, const char *name);
  79. extern int cap_inode_need_killpriv(struct dentry *dentry);
  80. extern int cap_inode_killpriv(struct dentry *dentry);
  81. extern int cap_mmap_addr(unsigned long addr);
  82. extern int cap_mmap_file(struct file *file, unsigned long reqprot,
  83. unsigned long prot, unsigned long flags);
  84. extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
  85. extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
  86. unsigned long arg4, unsigned long arg5);
  87. extern int cap_task_setscheduler(struct task_struct *p);
  88. extern int cap_task_setioprio(struct task_struct *p, int ioprio);
  89. extern int cap_task_setnice(struct task_struct *p, int nice);
  90. extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
  91. struct msghdr;
  92. struct sk_buff;
  93. struct sock;
  94. struct sockaddr;
  95. struct socket;
  96. struct flowi;
  97. struct dst_entry;
  98. struct xfrm_selector;
  99. struct xfrm_policy;
  100. struct xfrm_state;
  101. struct xfrm_user_sec_ctx;
  102. struct seq_file;
  103. #ifdef CONFIG_MMU
  104. extern unsigned long mmap_min_addr;
  105. extern unsigned long dac_mmap_min_addr;
  106. #else
  107. #define mmap_min_addr 0UL
  108. #define dac_mmap_min_addr 0UL
  109. #endif
  110. /*
  111. * Values used in the task_security_ops calls
  112. */
  113. /* setuid or setgid, id0 == uid or gid */
  114. #define LSM_SETID_ID 1
  115. /* setreuid or setregid, id0 == real, id1 == eff */
  116. #define LSM_SETID_RE 2
  117. /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
  118. #define LSM_SETID_RES 4
  119. /* setfsuid or setfsgid, id0 == fsuid or fsgid */
  120. #define LSM_SETID_FS 8
  121. /* forward declares to avoid warnings */
  122. struct sched_param;
  123. struct request_sock;
  124. /* bprm->unsafe reasons */
  125. #define LSM_UNSAFE_SHARE 1
  126. #define LSM_UNSAFE_PTRACE 2
  127. #define LSM_UNSAFE_PTRACE_CAP 4
  128. #define LSM_UNSAFE_NO_NEW_PRIVS 8
  129. #ifdef CONFIG_MMU
  130. extern int mmap_min_addr_handler(struct ctl_table *table, int write,
  131. void __user *buffer, size_t *lenp, loff_t *ppos);
  132. #endif
  133. /* security_inode_init_security callback function to write xattrs */
  134. typedef int (*initxattrs) (struct inode *inode,
  135. const struct xattr *xattr_array, void *fs_data);
  136. #ifdef CONFIG_SECURITY
  137. struct security_mnt_opts {
  138. char **mnt_opts;
  139. int *mnt_opts_flags;
  140. int num_mnt_opts;
  141. };
  142. static inline void security_init_mnt_opts(struct security_mnt_opts *opts)
  143. {
  144. opts->mnt_opts = NULL;
  145. opts->mnt_opts_flags = NULL;
  146. opts->num_mnt_opts = 0;
  147. }
  148. static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
  149. {
  150. int i;
  151. if (opts->mnt_opts)
  152. for (i = 0; i < opts->num_mnt_opts; i++)
  153. kfree(opts->mnt_opts[i]);
  154. kfree(opts->mnt_opts);
  155. opts->mnt_opts = NULL;
  156. kfree(opts->mnt_opts_flags);
  157. opts->mnt_opts_flags = NULL;
  158. opts->num_mnt_opts = 0;
  159. }
  160. /* prototypes */
  161. extern int security_init(void);
  162. /* Security operations */
  163. int security_binder_set_context_mgr(struct task_struct *mgr);
  164. int security_binder_transaction(struct task_struct *from,
  165. struct task_struct *to);
  166. int security_binder_transfer_binder(struct task_struct *from,
  167. struct task_struct *to);
  168. int security_binder_transfer_file(struct task_struct *from,
  169. struct task_struct *to, struct file *file);
  170. int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
  171. int security_ptrace_traceme(struct task_struct *parent);
  172. int security_capget(struct task_struct *target,
  173. kernel_cap_t *effective,
  174. kernel_cap_t *inheritable,
  175. kernel_cap_t *permitted);
  176. int security_capset(struct cred *new, const struct cred *old,
  177. const kernel_cap_t *effective,
  178. const kernel_cap_t *inheritable,
  179. const kernel_cap_t *permitted);
  180. int security_capable(const struct cred *cred, struct user_namespace *ns,
  181. int cap);
  182. int security_capable_noaudit(const struct cred *cred, struct user_namespace *ns,
  183. int cap);
  184. int security_quotactl(int cmds, int type, int id, struct super_block *sb);
  185. int security_quota_on(struct dentry *dentry);
  186. int security_syslog(int type);
  187. int security_settime(const struct timespec *ts, const struct timezone *tz);
  188. int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
  189. int security_bprm_set_creds(struct linux_binprm *bprm);
  190. int security_bprm_check(struct linux_binprm *bprm);
  191. void security_bprm_committing_creds(struct linux_binprm *bprm);
  192. void security_bprm_committed_creds(struct linux_binprm *bprm);
  193. int security_bprm_secureexec(struct linux_binprm *bprm);
  194. int security_sb_alloc(struct super_block *sb);
  195. void security_sb_free(struct super_block *sb);
  196. int security_sb_copy_data(char *orig, char *copy);
  197. int security_sb_remount(struct super_block *sb, void *data);
  198. int security_sb_kern_mount(struct super_block *sb, int flags, void *data);
  199. int security_sb_show_options(struct seq_file *m, struct super_block *sb);
  200. int security_sb_statfs(struct dentry *dentry);
  201. int security_sb_mount(const char *dev_name, struct path *path,
  202. const char *type, unsigned long flags, void *data);
  203. int security_sb_umount(struct vfsmount *mnt, int flags);
  204. int security_sb_pivotroot(struct path *old_path, struct path *new_path);
  205. int security_sb_set_mnt_opts(struct super_block *sb,
  206. struct security_mnt_opts *opts,
  207. unsigned long kern_flags,
  208. unsigned long *set_kern_flags);
  209. int security_sb_clone_mnt_opts(const struct super_block *oldsb,
  210. struct super_block *newsb);
  211. int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts);
  212. int security_dentry_init_security(struct dentry *dentry, int mode,
  213. struct qstr *name, void **ctx,
  214. u32 *ctxlen);
  215. int security_inode_alloc(struct inode *inode);
  216. void security_inode_free(struct inode *inode);
  217. int security_inode_init_security(struct inode *inode, struct inode *dir,
  218. const struct qstr *qstr,
  219. initxattrs initxattrs, void *fs_data);
  220. int security_old_inode_init_security(struct inode *inode, struct inode *dir,
  221. const struct qstr *qstr, const char **name,
  222. void **value, size_t *len);
  223. int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
  224. int security_inode_link(struct dentry *old_dentry, struct inode *dir,
  225. struct dentry *new_dentry);
  226. int security_inode_unlink(struct inode *dir, struct dentry *dentry);
  227. int security_inode_symlink(struct inode *dir, struct dentry *dentry,
  228. const char *old_name);
  229. int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
  230. int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
  231. int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
  232. int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
  233. struct inode *new_dir, struct dentry *new_dentry,
  234. unsigned int flags);
  235. int security_inode_readlink(struct dentry *dentry);
  236. int security_inode_follow_link(struct dentry *dentry, struct nameidata *nd);
  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 nameidata *nd)
  586. {
  587. return 0;
  588. }
  589. static inline int security_inode_permission(struct inode *inode, int mask)
  590. {
  591. return 0;
  592. }
  593. static inline int security_inode_setattr(struct dentry *dentry,
  594. struct iattr *attr)
  595. {
  596. return 0;
  597. }
  598. static inline int security_inode_getattr(const struct path *path)
  599. {
  600. return 0;
  601. }
  602. static inline int security_inode_setxattr(struct dentry *dentry,
  603. const char *name, const void *value, size_t size, int flags)
  604. {
  605. return cap_inode_setxattr(dentry, name, value, size, flags);
  606. }
  607. static inline void security_inode_post_setxattr(struct dentry *dentry,
  608. const char *name, const void *value, size_t size, int flags)
  609. { }
  610. static inline int security_inode_getxattr(struct dentry *dentry,
  611. const char *name)
  612. {
  613. return 0;
  614. }
  615. static inline int security_inode_listxattr(struct dentry *dentry)
  616. {
  617. return 0;
  618. }
  619. static inline int security_inode_removexattr(struct dentry *dentry,
  620. const char *name)
  621. {
  622. return cap_inode_removexattr(dentry, name);
  623. }
  624. static inline int security_inode_need_killpriv(struct dentry *dentry)
  625. {
  626. return cap_inode_need_killpriv(dentry);
  627. }
  628. static inline int security_inode_killpriv(struct dentry *dentry)
  629. {
  630. return cap_inode_killpriv(dentry);
  631. }
  632. static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc)
  633. {
  634. return -EOPNOTSUPP;
  635. }
  636. static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
  637. {
  638. return -EOPNOTSUPP;
  639. }
  640. static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
  641. {
  642. return 0;
  643. }
  644. static inline void security_inode_getsecid(const struct inode *inode, u32 *secid)
  645. {
  646. *secid = 0;
  647. }
  648. static inline int security_file_permission(struct file *file, int mask)
  649. {
  650. return 0;
  651. }
  652. static inline int security_file_alloc(struct file *file)
  653. {
  654. return 0;
  655. }
  656. static inline void security_file_free(struct file *file)
  657. { }
  658. static inline int security_file_ioctl(struct file *file, unsigned int cmd,
  659. unsigned long arg)
  660. {
  661. return 0;
  662. }
  663. static inline int security_mmap_file(struct file *file, unsigned long prot,
  664. unsigned long flags)
  665. {
  666. return 0;
  667. }
  668. static inline int security_mmap_addr(unsigned long addr)
  669. {
  670. return cap_mmap_addr(addr);
  671. }
  672. static inline int security_file_mprotect(struct vm_area_struct *vma,
  673. unsigned long reqprot,
  674. unsigned long prot)
  675. {
  676. return 0;
  677. }
  678. static inline int security_file_lock(struct file *file, unsigned int cmd)
  679. {
  680. return 0;
  681. }
  682. static inline int security_file_fcntl(struct file *file, unsigned int cmd,
  683. unsigned long arg)
  684. {
  685. return 0;
  686. }
  687. static inline void security_file_set_fowner(struct file *file)
  688. {
  689. return;
  690. }
  691. static inline int security_file_send_sigiotask(struct task_struct *tsk,
  692. struct fown_struct *fown,
  693. int sig)
  694. {
  695. return 0;
  696. }
  697. static inline int security_file_receive(struct file *file)
  698. {
  699. return 0;
  700. }
  701. static inline int security_file_open(struct file *file,
  702. const struct cred *cred)
  703. {
  704. return 0;
  705. }
  706. static inline int security_task_create(unsigned long clone_flags)
  707. {
  708. return 0;
  709. }
  710. static inline void security_task_free(struct task_struct *task)
  711. { }
  712. static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
  713. {
  714. return 0;
  715. }
  716. static inline void security_cred_free(struct cred *cred)
  717. { }
  718. static inline int security_prepare_creds(struct cred *new,
  719. const struct cred *old,
  720. gfp_t gfp)
  721. {
  722. return 0;
  723. }
  724. static inline void security_transfer_creds(struct cred *new,
  725. const struct cred *old)
  726. {
  727. }
  728. static inline int security_kernel_act_as(struct cred *cred, u32 secid)
  729. {
  730. return 0;
  731. }
  732. static inline int security_kernel_create_files_as(struct cred *cred,
  733. struct inode *inode)
  734. {
  735. return 0;
  736. }
  737. static inline int security_kernel_fw_from_file(struct file *file,
  738. char *buf, size_t size)
  739. {
  740. return 0;
  741. }
  742. static inline int security_kernel_module_request(char *kmod_name)
  743. {
  744. return 0;
  745. }
  746. static inline int security_kernel_module_from_file(struct file *file)
  747. {
  748. return 0;
  749. }
  750. static inline int security_task_fix_setuid(struct cred *new,
  751. const struct cred *old,
  752. int flags)
  753. {
  754. return cap_task_fix_setuid(new, old, flags);
  755. }
  756. static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
  757. {
  758. return 0;
  759. }
  760. static inline int security_task_getpgid(struct task_struct *p)
  761. {
  762. return 0;
  763. }
  764. static inline int security_task_getsid(struct task_struct *p)
  765. {
  766. return 0;
  767. }
  768. static inline void security_task_getsecid(struct task_struct *p, u32 *secid)
  769. {
  770. *secid = 0;
  771. }
  772. static inline int security_task_setnice(struct task_struct *p, int nice)
  773. {
  774. return cap_task_setnice(p, nice);
  775. }
  776. static inline int security_task_setioprio(struct task_struct *p, int ioprio)
  777. {
  778. return cap_task_setioprio(p, ioprio);
  779. }
  780. static inline int security_task_getioprio(struct task_struct *p)
  781. {
  782. return 0;
  783. }
  784. static inline int security_task_setrlimit(struct task_struct *p,
  785. unsigned int resource,
  786. struct rlimit *new_rlim)
  787. {
  788. return 0;
  789. }
  790. static inline int security_task_setscheduler(struct task_struct *p)
  791. {
  792. return cap_task_setscheduler(p);
  793. }
  794. static inline int security_task_getscheduler(struct task_struct *p)
  795. {
  796. return 0;
  797. }
  798. static inline int security_task_movememory(struct task_struct *p)
  799. {
  800. return 0;
  801. }
  802. static inline int security_task_kill(struct task_struct *p,
  803. struct siginfo *info, int sig,
  804. u32 secid)
  805. {
  806. return 0;
  807. }
  808. static inline int security_task_wait(struct task_struct *p)
  809. {
  810. return 0;
  811. }
  812. static inline int security_task_prctl(int option, unsigned long arg2,
  813. unsigned long arg3,
  814. unsigned long arg4,
  815. unsigned long arg5)
  816. {
  817. return cap_task_prctl(option, arg2, arg3, arg3, arg5);
  818. }
  819. static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
  820. { }
  821. static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
  822. short flag)
  823. {
  824. return 0;
  825. }
  826. static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
  827. {
  828. *secid = 0;
  829. }
  830. static inline int security_msg_msg_alloc(struct msg_msg *msg)
  831. {
  832. return 0;
  833. }
  834. static inline void security_msg_msg_free(struct msg_msg *msg)
  835. { }
  836. static inline int security_msg_queue_alloc(struct msg_queue *msq)
  837. {
  838. return 0;
  839. }
  840. static inline void security_msg_queue_free(struct msg_queue *msq)
  841. { }
  842. static inline int security_msg_queue_associate(struct msg_queue *msq,
  843. int msqflg)
  844. {
  845. return 0;
  846. }
  847. static inline int security_msg_queue_msgctl(struct msg_queue *msq, int cmd)
  848. {
  849. return 0;
  850. }
  851. static inline int security_msg_queue_msgsnd(struct msg_queue *msq,
  852. struct msg_msg *msg, int msqflg)
  853. {
  854. return 0;
  855. }
  856. static inline int security_msg_queue_msgrcv(struct msg_queue *msq,
  857. struct msg_msg *msg,
  858. struct task_struct *target,
  859. long type, int mode)
  860. {
  861. return 0;
  862. }
  863. static inline int security_shm_alloc(struct shmid_kernel *shp)
  864. {
  865. return 0;
  866. }
  867. static inline void security_shm_free(struct shmid_kernel *shp)
  868. { }
  869. static inline int security_shm_associate(struct shmid_kernel *shp,
  870. int shmflg)
  871. {
  872. return 0;
  873. }
  874. static inline int security_shm_shmctl(struct shmid_kernel *shp, int cmd)
  875. {
  876. return 0;
  877. }
  878. static inline int security_shm_shmat(struct shmid_kernel *shp,
  879. char __user *shmaddr, int shmflg)
  880. {
  881. return 0;
  882. }
  883. static inline int security_sem_alloc(struct sem_array *sma)
  884. {
  885. return 0;
  886. }
  887. static inline void security_sem_free(struct sem_array *sma)
  888. { }
  889. static inline int security_sem_associate(struct sem_array *sma, int semflg)
  890. {
  891. return 0;
  892. }
  893. static inline int security_sem_semctl(struct sem_array *sma, int cmd)
  894. {
  895. return 0;
  896. }
  897. static inline int security_sem_semop(struct sem_array *sma,
  898. struct sembuf *sops, unsigned nsops,
  899. int alter)
  900. {
  901. return 0;
  902. }
  903. static inline void security_d_instantiate(struct dentry *dentry, struct inode *inode)
  904. { }
  905. static inline int security_getprocattr(struct task_struct *p, char *name, char **value)
  906. {
  907. return -EINVAL;
  908. }
  909. static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
  910. {
  911. return -EINVAL;
  912. }
  913. static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
  914. {
  915. return 0;
  916. }
  917. static inline int security_ismaclabel(const char *name)
  918. {
  919. return 0;
  920. }
  921. static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
  922. {
  923. return -EOPNOTSUPP;
  924. }
  925. static inline int security_secctx_to_secid(const char *secdata,
  926. u32 seclen,
  927. u32 *secid)
  928. {
  929. return -EOPNOTSUPP;
  930. }
  931. static inline void security_release_secctx(char *secdata, u32 seclen)
  932. {
  933. }
  934. static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
  935. {
  936. return -EOPNOTSUPP;
  937. }
  938. static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
  939. {
  940. return -EOPNOTSUPP;
  941. }
  942. static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
  943. {
  944. return -EOPNOTSUPP;
  945. }
  946. #endif /* CONFIG_SECURITY */
  947. #ifdef CONFIG_SECURITY_NETWORK
  948. int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
  949. int security_unix_may_send(struct socket *sock, struct socket *other);
  950. int security_socket_create(int family, int type, int protocol, int kern);
  951. int security_socket_post_create(struct socket *sock, int family,
  952. int type, int protocol, int kern);
  953. int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
  954. int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
  955. int security_socket_listen(struct socket *sock, int backlog);
  956. int security_socket_accept(struct socket *sock, struct socket *newsock);
  957. int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
  958. int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
  959. int size, int flags);
  960. int security_socket_getsockname(struct socket *sock);
  961. int security_socket_getpeername(struct socket *sock);
  962. int security_socket_getsockopt(struct socket *sock, int level, int optname);
  963. int security_socket_setsockopt(struct socket *sock, int level, int optname);
  964. int security_socket_shutdown(struct socket *sock, int how);
  965. int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
  966. int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
  967. int __user *optlen, unsigned len);
  968. int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
  969. int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
  970. void security_sk_free(struct sock *sk);
  971. void security_sk_clone(const struct sock *sk, struct sock *newsk);
  972. void security_sk_classify_flow(struct sock *sk, struct flowi *fl);
  973. void security_req_classify_flow(const struct request_sock *req, struct flowi *fl);
  974. void security_sock_graft(struct sock*sk, struct socket *parent);
  975. int security_inet_conn_request(struct sock *sk,
  976. struct sk_buff *skb, struct request_sock *req);
  977. void security_inet_csk_clone(struct sock *newsk,
  978. const struct request_sock *req);
  979. void security_inet_conn_established(struct sock *sk,
  980. struct sk_buff *skb);
  981. int security_secmark_relabel_packet(u32 secid);
  982. void security_secmark_refcount_inc(void);
  983. void security_secmark_refcount_dec(void);
  984. int security_tun_dev_alloc_security(void **security);
  985. void security_tun_dev_free_security(void *security);
  986. int security_tun_dev_create(void);
  987. int security_tun_dev_attach_queue(void *security);
  988. int security_tun_dev_attach(struct sock *sk, void *security);
  989. int security_tun_dev_open(void *security);
  990. #else /* CONFIG_SECURITY_NETWORK */
  991. static inline int security_unix_stream_connect(struct sock *sock,
  992. struct sock *other,
  993. struct sock *newsk)
  994. {
  995. return 0;
  996. }
  997. static inline int security_unix_may_send(struct socket *sock,
  998. struct socket *other)
  999. {
  1000. return 0;
  1001. }
  1002. static inline int security_socket_create(int family, int type,
  1003. int protocol, int kern)
  1004. {
  1005. return 0;
  1006. }
  1007. static inline int security_socket_post_create(struct socket *sock,
  1008. int family,
  1009. int type,
  1010. int protocol, int kern)
  1011. {
  1012. return 0;
  1013. }
  1014. static inline int security_socket_bind(struct socket *sock,
  1015. struct sockaddr *address,
  1016. int addrlen)
  1017. {
  1018. return 0;
  1019. }
  1020. static inline int security_socket_connect(struct socket *sock,
  1021. struct sockaddr *address,
  1022. int addrlen)
  1023. {
  1024. return 0;
  1025. }
  1026. static inline int security_socket_listen(struct socket *sock, int backlog)
  1027. {
  1028. return 0;
  1029. }
  1030. static inline int security_socket_accept(struct socket *sock,
  1031. struct socket *newsock)
  1032. {
  1033. return 0;
  1034. }
  1035. static inline int security_socket_sendmsg(struct socket *sock,
  1036. struct msghdr *msg, int size)
  1037. {
  1038. return 0;
  1039. }
  1040. static inline int security_socket_recvmsg(struct socket *sock,
  1041. struct msghdr *msg, int size,
  1042. int flags)
  1043. {
  1044. return 0;
  1045. }
  1046. static inline int security_socket_getsockname(struct socket *sock)
  1047. {
  1048. return 0;
  1049. }
  1050. static inline int security_socket_getpeername(struct socket *sock)
  1051. {
  1052. return 0;
  1053. }
  1054. static inline int security_socket_getsockopt(struct socket *sock,
  1055. int level, int optname)
  1056. {
  1057. return 0;
  1058. }
  1059. static inline int security_socket_setsockopt(struct socket *sock,
  1060. int level, int optname)
  1061. {
  1062. return 0;
  1063. }
  1064. static inline int security_socket_shutdown(struct socket *sock, int how)
  1065. {
  1066. return 0;
  1067. }
  1068. static inline int security_sock_rcv_skb(struct sock *sk,
  1069. struct sk_buff *skb)
  1070. {
  1071. return 0;
  1072. }
  1073. static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
  1074. int __user *optlen, unsigned len)
  1075. {
  1076. return -ENOPROTOOPT;
  1077. }
  1078. static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
  1079. {
  1080. return -ENOPROTOOPT;
  1081. }
  1082. static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
  1083. {
  1084. return 0;
  1085. }
  1086. static inline void security_sk_free(struct sock *sk)
  1087. {
  1088. }
  1089. static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
  1090. {
  1091. }
  1092. static inline void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
  1093. {
  1094. }
  1095. static inline void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
  1096. {
  1097. }
  1098. static inline void security_sock_graft(struct sock *sk, struct socket *parent)
  1099. {
  1100. }
  1101. static inline int security_inet_conn_request(struct sock *sk,
  1102. struct sk_buff *skb, struct request_sock *req)
  1103. {
  1104. return 0;
  1105. }
  1106. static inline void security_inet_csk_clone(struct sock *newsk,
  1107. const struct request_sock *req)
  1108. {
  1109. }
  1110. static inline void security_inet_conn_established(struct sock *sk,
  1111. struct sk_buff *skb)
  1112. {
  1113. }
  1114. static inline int security_secmark_relabel_packet(u32 secid)
  1115. {
  1116. return 0;
  1117. }
  1118. static inline void security_secmark_refcount_inc(void)
  1119. {
  1120. }
  1121. static inline void security_secmark_refcount_dec(void)
  1122. {
  1123. }
  1124. static inline int security_tun_dev_alloc_security(void **security)
  1125. {
  1126. return 0;
  1127. }
  1128. static inline void security_tun_dev_free_security(void *security)
  1129. {
  1130. }
  1131. static inline int security_tun_dev_create(void)
  1132. {
  1133. return 0;
  1134. }
  1135. static inline int security_tun_dev_attach_queue(void *security)
  1136. {
  1137. return 0;
  1138. }
  1139. static inline int security_tun_dev_attach(struct sock *sk, void *security)
  1140. {
  1141. return 0;
  1142. }
  1143. static inline int security_tun_dev_open(void *security)
  1144. {
  1145. return 0;
  1146. }
  1147. #endif /* CONFIG_SECURITY_NETWORK */
  1148. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  1149. int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
  1150. struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp);
  1151. int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
  1152. void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
  1153. int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
  1154. int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
  1155. int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
  1156. struct xfrm_sec_ctx *polsec, u32 secid);
  1157. int security_xfrm_state_delete(struct xfrm_state *x);
  1158. void security_xfrm_state_free(struct xfrm_state *x);
  1159. int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir);
  1160. int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
  1161. struct xfrm_policy *xp,
  1162. const struct flowi *fl);
  1163. int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
  1164. void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl);
  1165. #else /* CONFIG_SECURITY_NETWORK_XFRM */
  1166. static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
  1167. struct xfrm_user_sec_ctx *sec_ctx,
  1168. gfp_t gfp)
  1169. {
  1170. return 0;
  1171. }
  1172. static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
  1173. {
  1174. return 0;
  1175. }
  1176. static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
  1177. {
  1178. }
  1179. static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
  1180. {
  1181. return 0;
  1182. }
  1183. static inline int security_xfrm_state_alloc(struct xfrm_state *x,
  1184. struct xfrm_user_sec_ctx *sec_ctx)
  1185. {
  1186. return 0;
  1187. }
  1188. static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
  1189. struct xfrm_sec_ctx *polsec, u32 secid)
  1190. {
  1191. return 0;
  1192. }
  1193. static inline void security_xfrm_state_free(struct xfrm_state *x)
  1194. {
  1195. }
  1196. static inline int security_xfrm_state_delete(struct xfrm_state *x)
  1197. {
  1198. return 0;
  1199. }
  1200. static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir)
  1201. {
  1202. return 0;
  1203. }
  1204. static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
  1205. struct xfrm_policy *xp, const struct flowi *fl)
  1206. {
  1207. return 1;
  1208. }
  1209. static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
  1210. {
  1211. return 0;
  1212. }
  1213. static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
  1214. {
  1215. }
  1216. #endif /* CONFIG_SECURITY_NETWORK_XFRM */
  1217. #ifdef CONFIG_SECURITY_PATH
  1218. int security_path_unlink(struct path *dir, struct dentry *dentry);
  1219. int security_path_mkdir(struct path *dir, struct dentry *dentry, umode_t mode);
  1220. int security_path_rmdir(struct path *dir, struct dentry *dentry);
  1221. int security_path_mknod(struct path *dir, struct dentry *dentry, umode_t mode,
  1222. unsigned int dev);
  1223. int security_path_truncate(struct path *path);
  1224. int security_path_symlink(struct path *dir, struct dentry *dentry,
  1225. const char *old_name);
  1226. int security_path_link(struct dentry *old_dentry, struct path *new_dir,
  1227. struct dentry *new_dentry);
  1228. int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
  1229. struct path *new_dir, struct dentry *new_dentry,
  1230. unsigned int flags);
  1231. int security_path_chmod(struct path *path, umode_t mode);
  1232. int security_path_chown(struct path *path, kuid_t uid, kgid_t gid);
  1233. int security_path_chroot(struct path *path);
  1234. #else /* CONFIG_SECURITY_PATH */
  1235. static inline int security_path_unlink(struct path *dir, struct dentry *dentry)
  1236. {
  1237. return 0;
  1238. }
  1239. static inline int security_path_mkdir(struct path *dir, struct dentry *dentry,
  1240. umode_t mode)
  1241. {
  1242. return 0;
  1243. }
  1244. static inline int security_path_rmdir(struct path *dir, struct dentry *dentry)
  1245. {
  1246. return 0;
  1247. }
  1248. static inline int security_path_mknod(struct path *dir, struct dentry *dentry,
  1249. umode_t mode, unsigned int dev)
  1250. {
  1251. return 0;
  1252. }
  1253. static inline int security_path_truncate(struct path *path)
  1254. {
  1255. return 0;
  1256. }
  1257. static inline int security_path_symlink(struct path *dir, struct dentry *dentry,
  1258. const char *old_name)
  1259. {
  1260. return 0;
  1261. }
  1262. static inline int security_path_link(struct dentry *old_dentry,
  1263. struct path *new_dir,
  1264. struct dentry *new_dentry)
  1265. {
  1266. return 0;
  1267. }
  1268. static inline int security_path_rename(struct path *old_dir,
  1269. struct dentry *old_dentry,
  1270. struct path *new_dir,
  1271. struct dentry *new_dentry,
  1272. unsigned int flags)
  1273. {
  1274. return 0;
  1275. }
  1276. static inline int security_path_chmod(struct path *path, umode_t mode)
  1277. {
  1278. return 0;
  1279. }
  1280. static inline int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
  1281. {
  1282. return 0;
  1283. }
  1284. static inline int security_path_chroot(struct path *path)
  1285. {
  1286. return 0;
  1287. }
  1288. #endif /* CONFIG_SECURITY_PATH */
  1289. #ifdef CONFIG_KEYS
  1290. #ifdef CONFIG_SECURITY
  1291. int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
  1292. void security_key_free(struct key *key);
  1293. int security_key_permission(key_ref_t key_ref,
  1294. const struct cred *cred, unsigned perm);
  1295. int security_key_getsecurity(struct key *key, char **_buffer);
  1296. #else
  1297. static inline int security_key_alloc(struct key *key,
  1298. const struct cred *cred,
  1299. unsigned long flags)
  1300. {
  1301. return 0;
  1302. }
  1303. static inline void security_key_free(struct key *key)
  1304. {
  1305. }
  1306. static inline int security_key_permission(key_ref_t key_ref,
  1307. const struct cred *cred,
  1308. unsigned perm)
  1309. {
  1310. return 0;
  1311. }
  1312. static inline int security_key_getsecurity(struct key *key, char **_buffer)
  1313. {
  1314. *_buffer = NULL;
  1315. return 0;
  1316. }
  1317. #endif
  1318. #endif /* CONFIG_KEYS */
  1319. #ifdef CONFIG_AUDIT
  1320. #ifdef CONFIG_SECURITY
  1321. int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
  1322. int security_audit_rule_known(struct audit_krule *krule);
  1323. int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule,
  1324. struct audit_context *actx);
  1325. void security_audit_rule_free(void *lsmrule);
  1326. #else
  1327. static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
  1328. void **lsmrule)
  1329. {
  1330. return 0;
  1331. }
  1332. static inline int security_audit_rule_known(struct audit_krule *krule)
  1333. {
  1334. return 0;
  1335. }
  1336. static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
  1337. void *lsmrule, struct audit_context *actx)
  1338. {
  1339. return 0;
  1340. }
  1341. static inline void security_audit_rule_free(void *lsmrule)
  1342. { }
  1343. #endif /* CONFIG_SECURITY */
  1344. #endif /* CONFIG_AUDIT */
  1345. #ifdef CONFIG_SECURITYFS
  1346. extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
  1347. struct dentry *parent, void *data,
  1348. const struct file_operations *fops);
  1349. extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
  1350. extern void securityfs_remove(struct dentry *dentry);
  1351. #else /* CONFIG_SECURITYFS */
  1352. static inline struct dentry *securityfs_create_dir(const char *name,
  1353. struct dentry *parent)
  1354. {
  1355. return ERR_PTR(-ENODEV);
  1356. }
  1357. static inline struct dentry *securityfs_create_file(const char *name,
  1358. umode_t mode,
  1359. struct dentry *parent,
  1360. void *data,
  1361. const struct file_operations *fops)
  1362. {
  1363. return ERR_PTR(-ENODEV);
  1364. }
  1365. static inline void securityfs_remove(struct dentry *dentry)
  1366. {}
  1367. #endif
  1368. #ifdef CONFIG_SECURITY
  1369. static inline char *alloc_secdata(void)
  1370. {
  1371. return (char *)get_zeroed_page(GFP_KERNEL);
  1372. }
  1373. static inline void free_secdata(void *secdata)
  1374. {
  1375. free_page((unsigned long)secdata);
  1376. }
  1377. #else
  1378. static inline char *alloc_secdata(void)
  1379. {
  1380. return (char *)1;
  1381. }
  1382. static inline void free_secdata(void *secdata)
  1383. { }
  1384. #endif /* CONFIG_SECURITY */
  1385. #endif /* ! __LINUX_SECURITY_H */