security.h 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098
  1. /*
  2. * Linux Security plug
  3. *
  4. * Copyright (C) 2001 WireX Communications, Inc <[email protected]>
  5. * Copyright (C) 2001 Greg Kroah-Hartman <[email protected]>
  6. * Copyright (C) 2001 Networks Associates Technology, Inc <[email protected]>
  7. * Copyright (C) 2001 James Morris <[email protected]>
  8. * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group)
  9. * Copyright (C) 2016 Mellanox Techonologies
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * Due to this file being licensed under the GPL there is controversy over
  17. * whether this permits you to write a module that #includes this file
  18. * without placing your module under the GPL. Please consult a lawyer for
  19. * advice before doing this.
  20. *
  21. */
  22. #ifndef __LINUX_SECURITY_H
  23. #define __LINUX_SECURITY_H
  24. #include <linux/kernel_read_file.h>
  25. #include <linux/key.h>
  26. #include <linux/capability.h>
  27. #include <linux/fs.h>
  28. #include <linux/slab.h>
  29. #include <linux/err.h>
  30. #include <linux/string.h>
  31. #include <linux/mm.h>
  32. struct linux_binprm;
  33. struct cred;
  34. struct rlimit;
  35. struct kernel_siginfo;
  36. struct sembuf;
  37. struct kern_ipc_perm;
  38. struct audit_context;
  39. struct super_block;
  40. struct inode;
  41. struct dentry;
  42. struct file;
  43. struct vfsmount;
  44. struct path;
  45. struct qstr;
  46. struct iattr;
  47. struct fown_struct;
  48. struct file_operations;
  49. struct msg_msg;
  50. struct xattr;
  51. struct kernfs_node;
  52. struct xfrm_sec_ctx;
  53. struct mm_struct;
  54. struct fs_context;
  55. struct fs_parameter;
  56. enum fs_value_type;
  57. struct watch;
  58. struct watch_notification;
  59. /* Default (no) options for the capable function */
  60. #define CAP_OPT_NONE 0x0
  61. /* If capable should audit the security request */
  62. #define CAP_OPT_NOAUDIT BIT(1)
  63. /* If capable is being called by a setid function */
  64. #define CAP_OPT_INSETID BIT(2)
  65. /* LSM Agnostic defines for fs_context::lsm_flags */
  66. #define SECURITY_LSM_NATIVE_LABELS 1
  67. struct ctl_table;
  68. struct audit_krule;
  69. struct user_namespace;
  70. struct timezone;
  71. enum lsm_event {
  72. LSM_POLICY_CHANGE,
  73. };
  74. #ifndef CONFIG_KDP_CRED
  75. #define security_integrity_current() 0
  76. #endif
  77. /*
  78. * These are reasons that can be passed to the security_locked_down()
  79. * LSM hook. Lockdown reasons that protect kernel integrity (ie, the
  80. * ability for userland to modify kernel code) are placed before
  81. * LOCKDOWN_INTEGRITY_MAX. Lockdown reasons that protect kernel
  82. * confidentiality (ie, the ability for userland to extract
  83. * information from the running kernel that would otherwise be
  84. * restricted) are placed before LOCKDOWN_CONFIDENTIALITY_MAX.
  85. *
  86. * LSM authors should note that the semantics of any given lockdown
  87. * reason are not guaranteed to be stable - the same reason may block
  88. * one set of features in one kernel release, and a slightly different
  89. * set of features in a later kernel release. LSMs that seek to expose
  90. * lockdown policy at any level of granularity other than "none",
  91. * "integrity" or "confidentiality" are responsible for either
  92. * ensuring that they expose a consistent level of functionality to
  93. * userland, or ensuring that userland is aware that this is
  94. * potentially a moving target. It is easy to misuse this information
  95. * in a way that could break userspace. Please be careful not to do
  96. * so.
  97. *
  98. * If you add to this, remember to extend lockdown_reasons in
  99. * security/lockdown/lockdown.c.
  100. */
  101. enum lockdown_reason {
  102. LOCKDOWN_NONE,
  103. LOCKDOWN_MODULE_SIGNATURE,
  104. LOCKDOWN_DEV_MEM,
  105. LOCKDOWN_EFI_TEST,
  106. LOCKDOWN_KEXEC,
  107. LOCKDOWN_HIBERNATION,
  108. LOCKDOWN_PCI_ACCESS,
  109. LOCKDOWN_IOPORT,
  110. LOCKDOWN_MSR,
  111. LOCKDOWN_ACPI_TABLES,
  112. LOCKDOWN_DEVICE_TREE,
  113. LOCKDOWN_PCMCIA_CIS,
  114. LOCKDOWN_TIOCSSERIAL,
  115. LOCKDOWN_MODULE_PARAMETERS,
  116. LOCKDOWN_MMIOTRACE,
  117. LOCKDOWN_DEBUGFS,
  118. LOCKDOWN_XMON_WR,
  119. LOCKDOWN_BPF_WRITE_USER,
  120. LOCKDOWN_DBG_WRITE_KERNEL,
  121. LOCKDOWN_RTAS_ERROR_INJECTION,
  122. LOCKDOWN_INTEGRITY_MAX,
  123. LOCKDOWN_KCORE,
  124. LOCKDOWN_KPROBES,
  125. LOCKDOWN_BPF_READ_KERNEL,
  126. LOCKDOWN_DBG_READ_KERNEL,
  127. LOCKDOWN_PERF,
  128. LOCKDOWN_TRACEFS,
  129. LOCKDOWN_XMON_RW,
  130. LOCKDOWN_XFRM_SECRET,
  131. LOCKDOWN_CONFIDENTIALITY_MAX,
  132. };
  133. extern const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1];
  134. /* These functions are in security/commoncap.c */
  135. extern int cap_capable(const struct cred *cred, struct user_namespace *ns,
  136. int cap, unsigned int opts);
  137. extern int cap_settime(const struct timespec64 *ts, const struct timezone *tz);
  138. extern int cap_ptrace_access_check(struct task_struct *child, unsigned int mode);
  139. extern int cap_ptrace_traceme(struct task_struct *parent);
  140. extern int cap_capget(struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
  141. extern int cap_capset(struct cred *new, const struct cred *old,
  142. const kernel_cap_t *effective,
  143. const kernel_cap_t *inheritable,
  144. const kernel_cap_t *permitted);
  145. extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file);
  146. int cap_inode_setxattr(struct dentry *dentry, const char *name,
  147. const void *value, size_t size, int flags);
  148. int cap_inode_removexattr(struct user_namespace *mnt_userns,
  149. struct dentry *dentry, const char *name);
  150. int cap_inode_need_killpriv(struct dentry *dentry);
  151. int cap_inode_killpriv(struct user_namespace *mnt_userns,
  152. struct dentry *dentry);
  153. int cap_inode_getsecurity(struct user_namespace *mnt_userns,
  154. struct inode *inode, const char *name, void **buffer,
  155. bool alloc);
  156. extern int cap_mmap_addr(unsigned long addr);
  157. extern int cap_mmap_file(struct file *file, unsigned long reqprot,
  158. unsigned long prot, unsigned long flags);
  159. extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
  160. extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
  161. unsigned long arg4, unsigned long arg5);
  162. extern int cap_task_setscheduler(struct task_struct *p);
  163. extern int cap_task_setioprio(struct task_struct *p, int ioprio);
  164. extern int cap_task_setnice(struct task_struct *p, int nice);
  165. extern int cap_vm_enough_memory(struct mm_struct *mm, long pages);
  166. struct msghdr;
  167. struct sk_buff;
  168. struct sock;
  169. struct sockaddr;
  170. struct socket;
  171. struct flowi_common;
  172. struct dst_entry;
  173. struct xfrm_selector;
  174. struct xfrm_policy;
  175. struct xfrm_state;
  176. struct xfrm_user_sec_ctx;
  177. struct seq_file;
  178. struct sctp_association;
  179. #ifdef CONFIG_MMU
  180. extern unsigned long mmap_min_addr;
  181. extern unsigned long dac_mmap_min_addr;
  182. #else
  183. #define mmap_min_addr 0UL
  184. #define dac_mmap_min_addr 0UL
  185. #endif
  186. /*
  187. * Values used in the task_security_ops calls
  188. */
  189. /* setuid or setgid, id0 == uid or gid */
  190. #define LSM_SETID_ID 1
  191. /* setreuid or setregid, id0 == real, id1 == eff */
  192. #define LSM_SETID_RE 2
  193. /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
  194. #define LSM_SETID_RES 4
  195. /* setfsuid or setfsgid, id0 == fsuid or fsgid */
  196. #define LSM_SETID_FS 8
  197. /* Flags for security_task_prlimit(). */
  198. #define LSM_PRLIMIT_READ 1
  199. #define LSM_PRLIMIT_WRITE 2
  200. /* forward declares to avoid warnings */
  201. struct sched_param;
  202. struct request_sock;
  203. /* bprm->unsafe reasons */
  204. #define LSM_UNSAFE_SHARE 1
  205. #define LSM_UNSAFE_PTRACE 2
  206. #define LSM_UNSAFE_NO_NEW_PRIVS 4
  207. #ifdef CONFIG_MMU
  208. extern int mmap_min_addr_handler(struct ctl_table *table, int write,
  209. void *buffer, size_t *lenp, loff_t *ppos);
  210. #endif
  211. /* security_inode_init_security callback function to write xattrs */
  212. typedef int (*initxattrs) (struct inode *inode,
  213. const struct xattr *xattr_array, void *fs_data);
  214. /* Keep the kernel_load_data_id enum in sync with kernel_read_file_id */
  215. #define __data_id_enumify(ENUM, dummy) LOADING_ ## ENUM,
  216. #define __data_id_stringify(dummy, str) #str,
  217. enum kernel_load_data_id {
  218. __kernel_read_file_id(__data_id_enumify)
  219. };
  220. static const char * const kernel_load_data_str[] = {
  221. __kernel_read_file_id(__data_id_stringify)
  222. };
  223. static inline const char *kernel_load_data_id_str(enum kernel_load_data_id id)
  224. {
  225. if ((unsigned)id >= LOADING_MAX_ID)
  226. return kernel_load_data_str[LOADING_UNKNOWN];
  227. return kernel_load_data_str[id];
  228. }
  229. #ifdef CONFIG_SECURITY
  230. int call_blocking_lsm_notifier(enum lsm_event event, void *data);
  231. int register_blocking_lsm_notifier(struct notifier_block *nb);
  232. int unregister_blocking_lsm_notifier(struct notifier_block *nb);
  233. /* prototypes */
  234. extern int security_init(void);
  235. extern int early_security_init(void);
  236. /* Security operations */
  237. int security_binder_set_context_mgr(const struct cred *mgr);
  238. int security_binder_transaction(const struct cred *from,
  239. const struct cred *to);
  240. int security_binder_transfer_binder(const struct cred *from,
  241. const struct cred *to);
  242. int security_binder_transfer_file(const struct cred *from,
  243. const struct cred *to, struct file *file);
  244. int security_ptrace_access_check(struct task_struct *child, unsigned int mode);
  245. int security_ptrace_traceme(struct task_struct *parent);
  246. int security_capget(struct task_struct *target,
  247. kernel_cap_t *effective,
  248. kernel_cap_t *inheritable,
  249. kernel_cap_t *permitted);
  250. int security_capset(struct cred *new, const struct cred *old,
  251. const kernel_cap_t *effective,
  252. const kernel_cap_t *inheritable,
  253. const kernel_cap_t *permitted);
  254. int security_capable(const struct cred *cred,
  255. struct user_namespace *ns,
  256. int cap,
  257. unsigned int opts);
  258. int security_quotactl(int cmds, int type, int id, struct super_block *sb);
  259. int security_quota_on(struct dentry *dentry);
  260. int security_syslog(int type);
  261. int security_settime64(const struct timespec64 *ts, const struct timezone *tz);
  262. int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
  263. int security_bprm_creds_for_exec(struct linux_binprm *bprm);
  264. int security_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file);
  265. int security_bprm_check(struct linux_binprm *bprm);
  266. void security_bprm_committing_creds(struct linux_binprm *bprm);
  267. void security_bprm_committed_creds(struct linux_binprm *bprm);
  268. int security_fs_context_submount(struct fs_context *fc, struct super_block *reference);
  269. int security_fs_context_dup(struct fs_context *fc, struct fs_context *src_fc);
  270. int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param);
  271. int security_sb_alloc(struct super_block *sb);
  272. void security_sb_delete(struct super_block *sb);
  273. void security_sb_free(struct super_block *sb);
  274. void security_free_mnt_opts(void **mnt_opts);
  275. int security_sb_eat_lsm_opts(char *options, void **mnt_opts);
  276. int security_sb_mnt_opts_compat(struct super_block *sb, void *mnt_opts);
  277. int security_sb_remount(struct super_block *sb, void *mnt_opts);
  278. int security_sb_kern_mount(struct super_block *sb);
  279. int security_sb_show_options(struct seq_file *m, struct super_block *sb);
  280. int security_sb_statfs(struct dentry *dentry);
  281. int security_sb_mount(const char *dev_name, const struct path *path,
  282. const char *type, unsigned long flags, void *data);
  283. int security_sb_umount(struct vfsmount *mnt, int flags);
  284. int security_sb_pivotroot(const struct path *old_path, const struct path *new_path);
  285. int security_sb_set_mnt_opts(struct super_block *sb,
  286. void *mnt_opts,
  287. unsigned long kern_flags,
  288. unsigned long *set_kern_flags);
  289. int security_sb_clone_mnt_opts(const struct super_block *oldsb,
  290. struct super_block *newsb,
  291. unsigned long kern_flags,
  292. unsigned long *set_kern_flags);
  293. int security_move_mount(const struct path *from_path, const struct path *to_path);
  294. int security_dentry_init_security(struct dentry *dentry, int mode,
  295. const struct qstr *name,
  296. const char **xattr_name, void **ctx,
  297. u32 *ctxlen);
  298. int security_dentry_create_files_as(struct dentry *dentry, int mode,
  299. struct qstr *name,
  300. const struct cred *old,
  301. struct cred *new);
  302. int security_path_notify(const struct path *path, u64 mask,
  303. unsigned int obj_type);
  304. int security_inode_alloc(struct inode *inode);
  305. void security_inode_free(struct inode *inode);
  306. int security_inode_init_security(struct inode *inode, struct inode *dir,
  307. const struct qstr *qstr,
  308. initxattrs initxattrs, void *fs_data);
  309. int security_inode_init_security_anon(struct inode *inode,
  310. const struct qstr *name,
  311. const struct inode *context_inode);
  312. int security_old_inode_init_security(struct inode *inode, struct inode *dir,
  313. const struct qstr *qstr, const char **name,
  314. void **value, size_t *len);
  315. int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
  316. int security_inode_link(struct dentry *old_dentry, struct inode *dir,
  317. struct dentry *new_dentry);
  318. int security_inode_unlink(struct inode *dir, struct dentry *dentry);
  319. int security_inode_symlink(struct inode *dir, struct dentry *dentry,
  320. const char *old_name);
  321. int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode);
  322. int security_inode_rmdir(struct inode *dir, struct dentry *dentry);
  323. int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev);
  324. int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
  325. struct inode *new_dir, struct dentry *new_dentry,
  326. unsigned int flags);
  327. int security_inode_readlink(struct dentry *dentry);
  328. int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
  329. bool rcu);
  330. int security_inode_permission(struct inode *inode, int mask);
  331. int security_inode_setattr(struct user_namespace *mnt_userns,
  332. struct dentry *dentry, struct iattr *attr);
  333. int security_inode_getattr(const struct path *path);
  334. int security_inode_setxattr(struct user_namespace *mnt_userns,
  335. struct dentry *dentry, const char *name,
  336. const void *value, size_t size, int flags);
  337. void security_inode_post_setxattr(struct dentry *dentry, const char *name,
  338. const void *value, size_t size, int flags);
  339. int security_inode_getxattr(struct dentry *dentry, const char *name);
  340. int security_inode_listxattr(struct dentry *dentry);
  341. int security_inode_removexattr(struct user_namespace *mnt_userns,
  342. struct dentry *dentry, const char *name);
  343. int security_inode_need_killpriv(struct dentry *dentry);
  344. int security_inode_killpriv(struct user_namespace *mnt_userns,
  345. struct dentry *dentry);
  346. int security_inode_getsecurity(struct user_namespace *mnt_userns,
  347. struct inode *inode, const char *name,
  348. void **buffer, bool alloc);
  349. int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
  350. int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size);
  351. void security_inode_getsecid(struct inode *inode, u32 *secid);
  352. int security_inode_copy_up(struct dentry *src, struct cred **new);
  353. int security_inode_copy_up_xattr(const char *name);
  354. int security_kernfs_init_security(struct kernfs_node *kn_dir,
  355. struct kernfs_node *kn);
  356. int security_file_permission(struct file *file, int mask);
  357. int security_file_alloc(struct file *file);
  358. void security_file_free(struct file *file);
  359. int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
  360. int security_mmap_file(struct file *file, unsigned long prot,
  361. unsigned long flags);
  362. int security_mmap_addr(unsigned long addr);
  363. int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
  364. unsigned long prot);
  365. int security_file_lock(struct file *file, unsigned int cmd);
  366. int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg);
  367. void security_file_set_fowner(struct file *file);
  368. int security_file_send_sigiotask(struct task_struct *tsk,
  369. struct fown_struct *fown, int sig);
  370. int security_file_receive(struct file *file);
  371. int security_file_open(struct file *file);
  372. int security_task_alloc(struct task_struct *task, unsigned long clone_flags);
  373. void security_task_free(struct task_struct *task);
  374. int security_cred_alloc_blank(struct cred *cred, gfp_t gfp);
  375. void security_cred_free(struct cred *cred);
  376. int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp);
  377. void security_transfer_creds(struct cred *new, const struct cred *old);
  378. void security_cred_getsecid(const struct cred *c, u32 *secid);
  379. int security_kernel_act_as(struct cred *new, u32 secid);
  380. int security_kernel_create_files_as(struct cred *new, struct inode *inode);
  381. int security_kernel_module_request(char *kmod_name);
  382. int security_kernel_load_data(enum kernel_load_data_id id, bool contents);
  383. int security_kernel_post_load_data(char *buf, loff_t size,
  384. enum kernel_load_data_id id,
  385. char *description);
  386. int security_kernel_read_file(struct file *file, enum kernel_read_file_id id,
  387. bool contents);
  388. int security_kernel_post_read_file(struct file *file, char *buf, loff_t size,
  389. enum kernel_read_file_id id);
  390. int security_task_fix_setuid(struct cred *new, const struct cred *old,
  391. int flags);
  392. int security_task_fix_setgid(struct cred *new, const struct cred *old,
  393. int flags);
  394. int security_task_fix_setgroups(struct cred *new, const struct cred *old);
  395. int security_task_setpgid(struct task_struct *p, pid_t pgid);
  396. int security_task_getpgid(struct task_struct *p);
  397. int security_task_getsid(struct task_struct *p);
  398. void security_current_getsecid_subj(u32 *secid);
  399. void security_task_getsecid_obj(struct task_struct *p, u32 *secid);
  400. int security_task_setnice(struct task_struct *p, int nice);
  401. int security_task_setioprio(struct task_struct *p, int ioprio);
  402. int security_task_getioprio(struct task_struct *p);
  403. int security_task_prlimit(const struct cred *cred, const struct cred *tcred,
  404. unsigned int flags);
  405. int security_task_setrlimit(struct task_struct *p, unsigned int resource,
  406. struct rlimit *new_rlim);
  407. int security_task_setscheduler(struct task_struct *p);
  408. int security_task_getscheduler(struct task_struct *p);
  409. int security_task_movememory(struct task_struct *p);
  410. int security_task_kill(struct task_struct *p, struct kernel_siginfo *info,
  411. int sig, const struct cred *cred);
  412. int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
  413. unsigned long arg4, unsigned long arg5);
  414. void security_task_to_inode(struct task_struct *p, struct inode *inode);
  415. int security_create_user_ns(const struct cred *cred);
  416. int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag);
  417. void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid);
  418. int security_msg_msg_alloc(struct msg_msg *msg);
  419. void security_msg_msg_free(struct msg_msg *msg);
  420. int security_msg_queue_alloc(struct kern_ipc_perm *msq);
  421. void security_msg_queue_free(struct kern_ipc_perm *msq);
  422. int security_msg_queue_associate(struct kern_ipc_perm *msq, int msqflg);
  423. int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd);
  424. int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
  425. struct msg_msg *msg, int msqflg);
  426. int security_msg_queue_msgrcv(struct kern_ipc_perm *msq, struct msg_msg *msg,
  427. struct task_struct *target, long type, int mode);
  428. int security_shm_alloc(struct kern_ipc_perm *shp);
  429. void security_shm_free(struct kern_ipc_perm *shp);
  430. int security_shm_associate(struct kern_ipc_perm *shp, int shmflg);
  431. int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd);
  432. int security_shm_shmat(struct kern_ipc_perm *shp, char __user *shmaddr, int shmflg);
  433. int security_sem_alloc(struct kern_ipc_perm *sma);
  434. void security_sem_free(struct kern_ipc_perm *sma);
  435. int security_sem_associate(struct kern_ipc_perm *sma, int semflg);
  436. int security_sem_semctl(struct kern_ipc_perm *sma, int cmd);
  437. int security_sem_semop(struct kern_ipc_perm *sma, struct sembuf *sops,
  438. unsigned nsops, int alter);
  439. void security_d_instantiate(struct dentry *dentry, struct inode *inode);
  440. int security_getprocattr(struct task_struct *p, const char *lsm, const char *name,
  441. char **value);
  442. int security_setprocattr(const char *lsm, const char *name, void *value,
  443. size_t size);
  444. int security_netlink_send(struct sock *sk, struct sk_buff *skb);
  445. int security_ismaclabel(const char *name);
  446. int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
  447. int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
  448. void security_release_secctx(char *secdata, u32 seclen);
  449. void security_inode_invalidate_secctx(struct inode *inode);
  450. int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
  451. int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
  452. int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
  453. int security_locked_down(enum lockdown_reason what);
  454. #else /* CONFIG_SECURITY */
  455. static inline int call_blocking_lsm_notifier(enum lsm_event event, void *data)
  456. {
  457. return 0;
  458. }
  459. static inline int register_blocking_lsm_notifier(struct notifier_block *nb)
  460. {
  461. return 0;
  462. }
  463. static inline int unregister_blocking_lsm_notifier(struct notifier_block *nb)
  464. {
  465. return 0;
  466. }
  467. static inline void security_free_mnt_opts(void **mnt_opts)
  468. {
  469. }
  470. /*
  471. * This is the default capabilities functionality. Most of these functions
  472. * are just stubbed out, but a few must call the proper capable code.
  473. */
  474. static inline int security_init(void)
  475. {
  476. return 0;
  477. }
  478. static inline int early_security_init(void)
  479. {
  480. return 0;
  481. }
  482. static inline int security_binder_set_context_mgr(const struct cred *mgr)
  483. {
  484. return 0;
  485. }
  486. static inline int security_binder_transaction(const struct cred *from,
  487. const struct cred *to)
  488. {
  489. return 0;
  490. }
  491. static inline int security_binder_transfer_binder(const struct cred *from,
  492. const struct cred *to)
  493. {
  494. return 0;
  495. }
  496. static inline int security_binder_transfer_file(const struct cred *from,
  497. const struct cred *to,
  498. struct file *file)
  499. {
  500. return 0;
  501. }
  502. static inline int security_ptrace_access_check(struct task_struct *child,
  503. unsigned int mode)
  504. {
  505. return cap_ptrace_access_check(child, mode);
  506. }
  507. static inline int security_ptrace_traceme(struct task_struct *parent)
  508. {
  509. return cap_ptrace_traceme(parent);
  510. }
  511. static inline int security_capget(struct task_struct *target,
  512. kernel_cap_t *effective,
  513. kernel_cap_t *inheritable,
  514. kernel_cap_t *permitted)
  515. {
  516. return cap_capget(target, effective, inheritable, permitted);
  517. }
  518. static inline int security_capset(struct cred *new,
  519. const struct cred *old,
  520. const kernel_cap_t *effective,
  521. const kernel_cap_t *inheritable,
  522. const kernel_cap_t *permitted)
  523. {
  524. return cap_capset(new, old, effective, inheritable, permitted);
  525. }
  526. static inline int security_capable(const struct cred *cred,
  527. struct user_namespace *ns,
  528. int cap,
  529. unsigned int opts)
  530. {
  531. return cap_capable(cred, ns, cap, opts);
  532. }
  533. static inline int security_quotactl(int cmds, int type, int id,
  534. struct super_block *sb)
  535. {
  536. return 0;
  537. }
  538. static inline int security_quota_on(struct dentry *dentry)
  539. {
  540. return 0;
  541. }
  542. static inline int security_syslog(int type)
  543. {
  544. return 0;
  545. }
  546. static inline int security_settime64(const struct timespec64 *ts,
  547. const struct timezone *tz)
  548. {
  549. return cap_settime(ts, tz);
  550. }
  551. static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
  552. {
  553. return __vm_enough_memory(mm, pages, cap_vm_enough_memory(mm, pages));
  554. }
  555. static inline int security_bprm_creds_for_exec(struct linux_binprm *bprm)
  556. {
  557. return 0;
  558. }
  559. static inline int security_bprm_creds_from_file(struct linux_binprm *bprm,
  560. struct file *file)
  561. {
  562. return cap_bprm_creds_from_file(bprm, file);
  563. }
  564. static inline int security_bprm_check(struct linux_binprm *bprm)
  565. {
  566. return 0;
  567. }
  568. static inline void security_bprm_committing_creds(struct linux_binprm *bprm)
  569. {
  570. }
  571. static inline void security_bprm_committed_creds(struct linux_binprm *bprm)
  572. {
  573. }
  574. static inline int security_fs_context_submount(struct fs_context *fc,
  575. struct super_block *reference)
  576. {
  577. return 0;
  578. }
  579. static inline int security_fs_context_dup(struct fs_context *fc,
  580. struct fs_context *src_fc)
  581. {
  582. return 0;
  583. }
  584. static inline int security_fs_context_parse_param(struct fs_context *fc,
  585. struct fs_parameter *param)
  586. {
  587. return -ENOPARAM;
  588. }
  589. static inline int security_sb_alloc(struct super_block *sb)
  590. {
  591. return 0;
  592. }
  593. static inline void security_sb_delete(struct super_block *sb)
  594. { }
  595. static inline void security_sb_free(struct super_block *sb)
  596. { }
  597. static inline int security_sb_eat_lsm_opts(char *options,
  598. void **mnt_opts)
  599. {
  600. return 0;
  601. }
  602. static inline int security_sb_remount(struct super_block *sb,
  603. void *mnt_opts)
  604. {
  605. return 0;
  606. }
  607. static inline int security_sb_mnt_opts_compat(struct super_block *sb,
  608. void *mnt_opts)
  609. {
  610. return 0;
  611. }
  612. static inline int security_sb_kern_mount(struct super_block *sb)
  613. {
  614. return 0;
  615. }
  616. static inline int security_sb_show_options(struct seq_file *m,
  617. struct super_block *sb)
  618. {
  619. return 0;
  620. }
  621. static inline int security_sb_statfs(struct dentry *dentry)
  622. {
  623. return 0;
  624. }
  625. static inline int security_sb_mount(const char *dev_name, const struct path *path,
  626. const char *type, unsigned long flags,
  627. void *data)
  628. {
  629. return 0;
  630. }
  631. static inline int security_sb_umount(struct vfsmount *mnt, int flags)
  632. {
  633. return 0;
  634. }
  635. static inline int security_sb_pivotroot(const struct path *old_path,
  636. const struct path *new_path)
  637. {
  638. return 0;
  639. }
  640. static inline int security_sb_set_mnt_opts(struct super_block *sb,
  641. void *mnt_opts,
  642. unsigned long kern_flags,
  643. unsigned long *set_kern_flags)
  644. {
  645. return 0;
  646. }
  647. static inline int security_sb_clone_mnt_opts(const struct super_block *oldsb,
  648. struct super_block *newsb,
  649. unsigned long kern_flags,
  650. unsigned long *set_kern_flags)
  651. {
  652. return 0;
  653. }
  654. static inline int security_move_mount(const struct path *from_path,
  655. const struct path *to_path)
  656. {
  657. return 0;
  658. }
  659. static inline int security_path_notify(const struct path *path, u64 mask,
  660. unsigned int obj_type)
  661. {
  662. return 0;
  663. }
  664. static inline int security_inode_alloc(struct inode *inode)
  665. {
  666. return 0;
  667. }
  668. static inline void security_inode_free(struct inode *inode)
  669. { }
  670. static inline int security_dentry_init_security(struct dentry *dentry,
  671. int mode,
  672. const struct qstr *name,
  673. const char **xattr_name,
  674. void **ctx,
  675. u32 *ctxlen)
  676. {
  677. return -EOPNOTSUPP;
  678. }
  679. static inline int security_dentry_create_files_as(struct dentry *dentry,
  680. int mode, struct qstr *name,
  681. const struct cred *old,
  682. struct cred *new)
  683. {
  684. return 0;
  685. }
  686. static inline int security_inode_init_security(struct inode *inode,
  687. struct inode *dir,
  688. const struct qstr *qstr,
  689. const initxattrs xattrs,
  690. void *fs_data)
  691. {
  692. return 0;
  693. }
  694. static inline int security_inode_init_security_anon(struct inode *inode,
  695. const struct qstr *name,
  696. const struct inode *context_inode)
  697. {
  698. return 0;
  699. }
  700. static inline int security_old_inode_init_security(struct inode *inode,
  701. struct inode *dir,
  702. const struct qstr *qstr,
  703. const char **name,
  704. void **value, size_t *len)
  705. {
  706. return -EOPNOTSUPP;
  707. }
  708. static inline int security_inode_create(struct inode *dir,
  709. struct dentry *dentry,
  710. umode_t mode)
  711. {
  712. return 0;
  713. }
  714. static inline int security_inode_link(struct dentry *old_dentry,
  715. struct inode *dir,
  716. struct dentry *new_dentry)
  717. {
  718. return 0;
  719. }
  720. static inline int security_inode_unlink(struct inode *dir,
  721. struct dentry *dentry)
  722. {
  723. return 0;
  724. }
  725. static inline int security_inode_symlink(struct inode *dir,
  726. struct dentry *dentry,
  727. const char *old_name)
  728. {
  729. return 0;
  730. }
  731. static inline int security_inode_mkdir(struct inode *dir,
  732. struct dentry *dentry,
  733. int mode)
  734. {
  735. return 0;
  736. }
  737. static inline int security_inode_rmdir(struct inode *dir,
  738. struct dentry *dentry)
  739. {
  740. return 0;
  741. }
  742. static inline int security_inode_mknod(struct inode *dir,
  743. struct dentry *dentry,
  744. int mode, dev_t dev)
  745. {
  746. return 0;
  747. }
  748. static inline int security_inode_rename(struct inode *old_dir,
  749. struct dentry *old_dentry,
  750. struct inode *new_dir,
  751. struct dentry *new_dentry,
  752. unsigned int flags)
  753. {
  754. return 0;
  755. }
  756. static inline int security_inode_readlink(struct dentry *dentry)
  757. {
  758. return 0;
  759. }
  760. static inline int security_inode_follow_link(struct dentry *dentry,
  761. struct inode *inode,
  762. bool rcu)
  763. {
  764. return 0;
  765. }
  766. static inline int security_inode_permission(struct inode *inode, int mask)
  767. {
  768. return 0;
  769. }
  770. static inline int security_inode_setattr(struct user_namespace *mnt_userns,
  771. struct dentry *dentry,
  772. struct iattr *attr)
  773. {
  774. return 0;
  775. }
  776. static inline int security_inode_getattr(const struct path *path)
  777. {
  778. return 0;
  779. }
  780. static inline int security_inode_setxattr(struct user_namespace *mnt_userns,
  781. struct dentry *dentry, const char *name, const void *value,
  782. size_t size, int flags)
  783. {
  784. return cap_inode_setxattr(dentry, name, value, size, flags);
  785. }
  786. static inline void security_inode_post_setxattr(struct dentry *dentry,
  787. const char *name, const void *value, size_t size, int flags)
  788. { }
  789. static inline int security_inode_getxattr(struct dentry *dentry,
  790. const char *name)
  791. {
  792. return 0;
  793. }
  794. static inline int security_inode_listxattr(struct dentry *dentry)
  795. {
  796. return 0;
  797. }
  798. static inline int security_inode_removexattr(struct user_namespace *mnt_userns,
  799. struct dentry *dentry,
  800. const char *name)
  801. {
  802. return cap_inode_removexattr(mnt_userns, dentry, name);
  803. }
  804. static inline int security_inode_need_killpriv(struct dentry *dentry)
  805. {
  806. return cap_inode_need_killpriv(dentry);
  807. }
  808. static inline int security_inode_killpriv(struct user_namespace *mnt_userns,
  809. struct dentry *dentry)
  810. {
  811. return cap_inode_killpriv(mnt_userns, dentry);
  812. }
  813. static inline int security_inode_getsecurity(struct user_namespace *mnt_userns,
  814. struct inode *inode,
  815. const char *name, void **buffer,
  816. bool alloc)
  817. {
  818. return cap_inode_getsecurity(mnt_userns, inode, name, buffer, alloc);
  819. }
  820. static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
  821. {
  822. return -EOPNOTSUPP;
  823. }
  824. static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
  825. {
  826. return 0;
  827. }
  828. static inline void security_inode_getsecid(struct inode *inode, u32 *secid)
  829. {
  830. *secid = 0;
  831. }
  832. static inline int security_inode_copy_up(struct dentry *src, struct cred **new)
  833. {
  834. return 0;
  835. }
  836. static inline int security_kernfs_init_security(struct kernfs_node *kn_dir,
  837. struct kernfs_node *kn)
  838. {
  839. return 0;
  840. }
  841. static inline int security_inode_copy_up_xattr(const char *name)
  842. {
  843. return -EOPNOTSUPP;
  844. }
  845. static inline int security_file_permission(struct file *file, int mask)
  846. {
  847. return 0;
  848. }
  849. static inline int security_file_alloc(struct file *file)
  850. {
  851. return 0;
  852. }
  853. static inline void security_file_free(struct file *file)
  854. { }
  855. static inline int security_file_ioctl(struct file *file, unsigned int cmd,
  856. unsigned long arg)
  857. {
  858. return 0;
  859. }
  860. static inline int security_mmap_file(struct file *file, unsigned long prot,
  861. unsigned long flags)
  862. {
  863. return 0;
  864. }
  865. static inline int security_mmap_addr(unsigned long addr)
  866. {
  867. return cap_mmap_addr(addr);
  868. }
  869. static inline int security_file_mprotect(struct vm_area_struct *vma,
  870. unsigned long reqprot,
  871. unsigned long prot)
  872. {
  873. return 0;
  874. }
  875. static inline int security_file_lock(struct file *file, unsigned int cmd)
  876. {
  877. return 0;
  878. }
  879. static inline int security_file_fcntl(struct file *file, unsigned int cmd,
  880. unsigned long arg)
  881. {
  882. return 0;
  883. }
  884. static inline void security_file_set_fowner(struct file *file)
  885. {
  886. return;
  887. }
  888. static inline int security_file_send_sigiotask(struct task_struct *tsk,
  889. struct fown_struct *fown,
  890. int sig)
  891. {
  892. return 0;
  893. }
  894. static inline int security_file_receive(struct file *file)
  895. {
  896. return 0;
  897. }
  898. static inline int security_file_open(struct file *file)
  899. {
  900. return 0;
  901. }
  902. static inline int security_task_alloc(struct task_struct *task,
  903. unsigned long clone_flags)
  904. {
  905. return 0;
  906. }
  907. static inline void security_task_free(struct task_struct *task)
  908. { }
  909. static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
  910. {
  911. return 0;
  912. }
  913. static inline void security_cred_free(struct cred *cred)
  914. { }
  915. static inline int security_prepare_creds(struct cred *new,
  916. const struct cred *old,
  917. gfp_t gfp)
  918. {
  919. return 0;
  920. }
  921. static inline void security_transfer_creds(struct cred *new,
  922. const struct cred *old)
  923. {
  924. }
  925. static inline void security_cred_getsecid(const struct cred *c, u32 *secid)
  926. {
  927. *secid = 0;
  928. }
  929. static inline int security_kernel_act_as(struct cred *cred, u32 secid)
  930. {
  931. return 0;
  932. }
  933. static inline int security_kernel_create_files_as(struct cred *cred,
  934. struct inode *inode)
  935. {
  936. return 0;
  937. }
  938. static inline int security_kernel_module_request(char *kmod_name)
  939. {
  940. return 0;
  941. }
  942. static inline int security_kernel_load_data(enum kernel_load_data_id id, bool contents)
  943. {
  944. return 0;
  945. }
  946. static inline int security_kernel_post_load_data(char *buf, loff_t size,
  947. enum kernel_load_data_id id,
  948. char *description)
  949. {
  950. return 0;
  951. }
  952. static inline int security_kernel_read_file(struct file *file,
  953. enum kernel_read_file_id id,
  954. bool contents)
  955. {
  956. return 0;
  957. }
  958. static inline int security_kernel_post_read_file(struct file *file,
  959. char *buf, loff_t size,
  960. enum kernel_read_file_id id)
  961. {
  962. return 0;
  963. }
  964. static inline int security_task_fix_setuid(struct cred *new,
  965. const struct cred *old,
  966. int flags)
  967. {
  968. return cap_task_fix_setuid(new, old, flags);
  969. }
  970. static inline int security_task_fix_setgid(struct cred *new,
  971. const struct cred *old,
  972. int flags)
  973. {
  974. return 0;
  975. }
  976. static inline int security_task_fix_setgroups(struct cred *new,
  977. const struct cred *old)
  978. {
  979. return 0;
  980. }
  981. static inline int security_task_setpgid(struct task_struct *p, pid_t pgid)
  982. {
  983. return 0;
  984. }
  985. static inline int security_task_getpgid(struct task_struct *p)
  986. {
  987. return 0;
  988. }
  989. static inline int security_task_getsid(struct task_struct *p)
  990. {
  991. return 0;
  992. }
  993. static inline void security_current_getsecid_subj(u32 *secid)
  994. {
  995. *secid = 0;
  996. }
  997. static inline void security_task_getsecid_obj(struct task_struct *p, u32 *secid)
  998. {
  999. *secid = 0;
  1000. }
  1001. static inline int security_task_setnice(struct task_struct *p, int nice)
  1002. {
  1003. return cap_task_setnice(p, nice);
  1004. }
  1005. static inline int security_task_setioprio(struct task_struct *p, int ioprio)
  1006. {
  1007. return cap_task_setioprio(p, ioprio);
  1008. }
  1009. static inline int security_task_getioprio(struct task_struct *p)
  1010. {
  1011. return 0;
  1012. }
  1013. static inline int security_task_prlimit(const struct cred *cred,
  1014. const struct cred *tcred,
  1015. unsigned int flags)
  1016. {
  1017. return 0;
  1018. }
  1019. static inline int security_task_setrlimit(struct task_struct *p,
  1020. unsigned int resource,
  1021. struct rlimit *new_rlim)
  1022. {
  1023. return 0;
  1024. }
  1025. static inline int security_task_setscheduler(struct task_struct *p)
  1026. {
  1027. return cap_task_setscheduler(p);
  1028. }
  1029. static inline int security_task_getscheduler(struct task_struct *p)
  1030. {
  1031. return 0;
  1032. }
  1033. static inline int security_task_movememory(struct task_struct *p)
  1034. {
  1035. return 0;
  1036. }
  1037. static inline int security_task_kill(struct task_struct *p,
  1038. struct kernel_siginfo *info, int sig,
  1039. const struct cred *cred)
  1040. {
  1041. return 0;
  1042. }
  1043. static inline int security_task_prctl(int option, unsigned long arg2,
  1044. unsigned long arg3,
  1045. unsigned long arg4,
  1046. unsigned long arg5)
  1047. {
  1048. return cap_task_prctl(option, arg2, arg3, arg4, arg5);
  1049. }
  1050. static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
  1051. { }
  1052. static inline int security_create_user_ns(const struct cred *cred)
  1053. {
  1054. return 0;
  1055. }
  1056. static inline int security_ipc_permission(struct kern_ipc_perm *ipcp,
  1057. short flag)
  1058. {
  1059. return 0;
  1060. }
  1061. static inline void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
  1062. {
  1063. *secid = 0;
  1064. }
  1065. static inline int security_msg_msg_alloc(struct msg_msg *msg)
  1066. {
  1067. return 0;
  1068. }
  1069. static inline void security_msg_msg_free(struct msg_msg *msg)
  1070. { }
  1071. static inline int security_msg_queue_alloc(struct kern_ipc_perm *msq)
  1072. {
  1073. return 0;
  1074. }
  1075. static inline void security_msg_queue_free(struct kern_ipc_perm *msq)
  1076. { }
  1077. static inline int security_msg_queue_associate(struct kern_ipc_perm *msq,
  1078. int msqflg)
  1079. {
  1080. return 0;
  1081. }
  1082. static inline int security_msg_queue_msgctl(struct kern_ipc_perm *msq, int cmd)
  1083. {
  1084. return 0;
  1085. }
  1086. static inline int security_msg_queue_msgsnd(struct kern_ipc_perm *msq,
  1087. struct msg_msg *msg, int msqflg)
  1088. {
  1089. return 0;
  1090. }
  1091. static inline int security_msg_queue_msgrcv(struct kern_ipc_perm *msq,
  1092. struct msg_msg *msg,
  1093. struct task_struct *target,
  1094. long type, int mode)
  1095. {
  1096. return 0;
  1097. }
  1098. static inline int security_shm_alloc(struct kern_ipc_perm *shp)
  1099. {
  1100. return 0;
  1101. }
  1102. static inline void security_shm_free(struct kern_ipc_perm *shp)
  1103. { }
  1104. static inline int security_shm_associate(struct kern_ipc_perm *shp,
  1105. int shmflg)
  1106. {
  1107. return 0;
  1108. }
  1109. static inline int security_shm_shmctl(struct kern_ipc_perm *shp, int cmd)
  1110. {
  1111. return 0;
  1112. }
  1113. static inline int security_shm_shmat(struct kern_ipc_perm *shp,
  1114. char __user *shmaddr, int shmflg)
  1115. {
  1116. return 0;
  1117. }
  1118. static inline int security_sem_alloc(struct kern_ipc_perm *sma)
  1119. {
  1120. return 0;
  1121. }
  1122. static inline void security_sem_free(struct kern_ipc_perm *sma)
  1123. { }
  1124. static inline int security_sem_associate(struct kern_ipc_perm *sma, int semflg)
  1125. {
  1126. return 0;
  1127. }
  1128. static inline int security_sem_semctl(struct kern_ipc_perm *sma, int cmd)
  1129. {
  1130. return 0;
  1131. }
  1132. static inline int security_sem_semop(struct kern_ipc_perm *sma,
  1133. struct sembuf *sops, unsigned nsops,
  1134. int alter)
  1135. {
  1136. return 0;
  1137. }
  1138. static inline void security_d_instantiate(struct dentry *dentry,
  1139. struct inode *inode)
  1140. { }
  1141. static inline int security_getprocattr(struct task_struct *p, const char *lsm,
  1142. const char *name, char **value)
  1143. {
  1144. return -EINVAL;
  1145. }
  1146. static inline int security_setprocattr(const char *lsm, char *name,
  1147. void *value, size_t size)
  1148. {
  1149. return -EINVAL;
  1150. }
  1151. static inline int security_netlink_send(struct sock *sk, struct sk_buff *skb)
  1152. {
  1153. return 0;
  1154. }
  1155. static inline int security_ismaclabel(const char *name)
  1156. {
  1157. return 0;
  1158. }
  1159. static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
  1160. {
  1161. return -EOPNOTSUPP;
  1162. }
  1163. static inline int security_secctx_to_secid(const char *secdata,
  1164. u32 seclen,
  1165. u32 *secid)
  1166. {
  1167. return -EOPNOTSUPP;
  1168. }
  1169. static inline void security_release_secctx(char *secdata, u32 seclen)
  1170. {
  1171. }
  1172. static inline void security_inode_invalidate_secctx(struct inode *inode)
  1173. {
  1174. }
  1175. static inline int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
  1176. {
  1177. return -EOPNOTSUPP;
  1178. }
  1179. static inline int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
  1180. {
  1181. return -EOPNOTSUPP;
  1182. }
  1183. static inline int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
  1184. {
  1185. return -EOPNOTSUPP;
  1186. }
  1187. static inline int security_locked_down(enum lockdown_reason what)
  1188. {
  1189. return 0;
  1190. }
  1191. #endif /* CONFIG_SECURITY */
  1192. #if defined(CONFIG_SECURITY) && defined(CONFIG_WATCH_QUEUE)
  1193. int security_post_notification(const struct cred *w_cred,
  1194. const struct cred *cred,
  1195. struct watch_notification *n);
  1196. #else
  1197. static inline int security_post_notification(const struct cred *w_cred,
  1198. const struct cred *cred,
  1199. struct watch_notification *n)
  1200. {
  1201. return 0;
  1202. }
  1203. #endif
  1204. #if defined(CONFIG_SECURITY) && defined(CONFIG_KEY_NOTIFICATIONS)
  1205. int security_watch_key(struct key *key);
  1206. #else
  1207. static inline int security_watch_key(struct key *key)
  1208. {
  1209. return 0;
  1210. }
  1211. #endif
  1212. #ifdef CONFIG_SECURITY_NETWORK
  1213. int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk);
  1214. int security_unix_may_send(struct socket *sock, struct socket *other);
  1215. int security_socket_create(int family, int type, int protocol, int kern);
  1216. int security_socket_post_create(struct socket *sock, int family,
  1217. int type, int protocol, int kern);
  1218. int security_socket_socketpair(struct socket *socka, struct socket *sockb);
  1219. int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen);
  1220. int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen);
  1221. int security_socket_listen(struct socket *sock, int backlog);
  1222. int security_socket_accept(struct socket *sock, struct socket *newsock);
  1223. int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size);
  1224. int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
  1225. int size, int flags);
  1226. int security_socket_getsockname(struct socket *sock);
  1227. int security_socket_getpeername(struct socket *sock);
  1228. int security_socket_getsockopt(struct socket *sock, int level, int optname);
  1229. int security_socket_setsockopt(struct socket *sock, int level, int optname);
  1230. int security_socket_shutdown(struct socket *sock, int how);
  1231. int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb);
  1232. int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
  1233. int __user *optlen, unsigned len);
  1234. int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid);
  1235. int security_sk_alloc(struct sock *sk, int family, gfp_t priority);
  1236. void security_sk_free(struct sock *sk);
  1237. void security_sk_clone(const struct sock *sk, struct sock *newsk);
  1238. void security_sk_classify_flow(struct sock *sk, struct flowi_common *flic);
  1239. void security_req_classify_flow(const struct request_sock *req,
  1240. struct flowi_common *flic);
  1241. void security_sock_graft(struct sock*sk, struct socket *parent);
  1242. int security_inet_conn_request(const struct sock *sk,
  1243. struct sk_buff *skb, struct request_sock *req);
  1244. void security_inet_csk_clone(struct sock *newsk,
  1245. const struct request_sock *req);
  1246. void security_inet_conn_established(struct sock *sk,
  1247. struct sk_buff *skb);
  1248. int security_secmark_relabel_packet(u32 secid);
  1249. void security_secmark_refcount_inc(void);
  1250. void security_secmark_refcount_dec(void);
  1251. int security_tun_dev_alloc_security(void **security);
  1252. void security_tun_dev_free_security(void *security);
  1253. int security_tun_dev_create(void);
  1254. int security_tun_dev_attach_queue(void *security);
  1255. int security_tun_dev_attach(struct sock *sk, void *security);
  1256. int security_tun_dev_open(void *security);
  1257. int security_sctp_assoc_request(struct sctp_association *asoc, struct sk_buff *skb);
  1258. int security_sctp_bind_connect(struct sock *sk, int optname,
  1259. struct sockaddr *address, int addrlen);
  1260. void security_sctp_sk_clone(struct sctp_association *asoc, struct sock *sk,
  1261. struct sock *newsk);
  1262. int security_sctp_assoc_established(struct sctp_association *asoc,
  1263. struct sk_buff *skb);
  1264. #else /* CONFIG_SECURITY_NETWORK */
  1265. static inline int security_unix_stream_connect(struct sock *sock,
  1266. struct sock *other,
  1267. struct sock *newsk)
  1268. {
  1269. return 0;
  1270. }
  1271. static inline int security_unix_may_send(struct socket *sock,
  1272. struct socket *other)
  1273. {
  1274. return 0;
  1275. }
  1276. static inline int security_socket_create(int family, int type,
  1277. int protocol, int kern)
  1278. {
  1279. return 0;
  1280. }
  1281. static inline int security_socket_post_create(struct socket *sock,
  1282. int family,
  1283. int type,
  1284. int protocol, int kern)
  1285. {
  1286. return 0;
  1287. }
  1288. static inline int security_socket_socketpair(struct socket *socka,
  1289. struct socket *sockb)
  1290. {
  1291. return 0;
  1292. }
  1293. static inline int security_socket_bind(struct socket *sock,
  1294. struct sockaddr *address,
  1295. int addrlen)
  1296. {
  1297. return 0;
  1298. }
  1299. static inline int security_socket_connect(struct socket *sock,
  1300. struct sockaddr *address,
  1301. int addrlen)
  1302. {
  1303. return 0;
  1304. }
  1305. static inline int security_socket_listen(struct socket *sock, int backlog)
  1306. {
  1307. return 0;
  1308. }
  1309. static inline int security_socket_accept(struct socket *sock,
  1310. struct socket *newsock)
  1311. {
  1312. return 0;
  1313. }
  1314. static inline int security_socket_sendmsg(struct socket *sock,
  1315. struct msghdr *msg, int size)
  1316. {
  1317. return 0;
  1318. }
  1319. static inline int security_socket_recvmsg(struct socket *sock,
  1320. struct msghdr *msg, int size,
  1321. int flags)
  1322. {
  1323. return 0;
  1324. }
  1325. static inline int security_socket_getsockname(struct socket *sock)
  1326. {
  1327. return 0;
  1328. }
  1329. static inline int security_socket_getpeername(struct socket *sock)
  1330. {
  1331. return 0;
  1332. }
  1333. static inline int security_socket_getsockopt(struct socket *sock,
  1334. int level, int optname)
  1335. {
  1336. return 0;
  1337. }
  1338. static inline int security_socket_setsockopt(struct socket *sock,
  1339. int level, int optname)
  1340. {
  1341. return 0;
  1342. }
  1343. static inline int security_socket_shutdown(struct socket *sock, int how)
  1344. {
  1345. return 0;
  1346. }
  1347. static inline int security_sock_rcv_skb(struct sock *sk,
  1348. struct sk_buff *skb)
  1349. {
  1350. return 0;
  1351. }
  1352. static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
  1353. int __user *optlen, unsigned len)
  1354. {
  1355. return -ENOPROTOOPT;
  1356. }
  1357. static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
  1358. {
  1359. return -ENOPROTOOPT;
  1360. }
  1361. static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
  1362. {
  1363. return 0;
  1364. }
  1365. static inline void security_sk_free(struct sock *sk)
  1366. {
  1367. }
  1368. static inline void security_sk_clone(const struct sock *sk, struct sock *newsk)
  1369. {
  1370. }
  1371. static inline void security_sk_classify_flow(struct sock *sk,
  1372. struct flowi_common *flic)
  1373. {
  1374. }
  1375. static inline void security_req_classify_flow(const struct request_sock *req,
  1376. struct flowi_common *flic)
  1377. {
  1378. }
  1379. static inline void security_sock_graft(struct sock *sk, struct socket *parent)
  1380. {
  1381. }
  1382. static inline int security_inet_conn_request(const struct sock *sk,
  1383. struct sk_buff *skb, struct request_sock *req)
  1384. {
  1385. return 0;
  1386. }
  1387. static inline void security_inet_csk_clone(struct sock *newsk,
  1388. const struct request_sock *req)
  1389. {
  1390. }
  1391. static inline void security_inet_conn_established(struct sock *sk,
  1392. struct sk_buff *skb)
  1393. {
  1394. }
  1395. static inline int security_secmark_relabel_packet(u32 secid)
  1396. {
  1397. return 0;
  1398. }
  1399. static inline void security_secmark_refcount_inc(void)
  1400. {
  1401. }
  1402. static inline void security_secmark_refcount_dec(void)
  1403. {
  1404. }
  1405. static inline int security_tun_dev_alloc_security(void **security)
  1406. {
  1407. return 0;
  1408. }
  1409. static inline void security_tun_dev_free_security(void *security)
  1410. {
  1411. }
  1412. static inline int security_tun_dev_create(void)
  1413. {
  1414. return 0;
  1415. }
  1416. static inline int security_tun_dev_attach_queue(void *security)
  1417. {
  1418. return 0;
  1419. }
  1420. static inline int security_tun_dev_attach(struct sock *sk, void *security)
  1421. {
  1422. return 0;
  1423. }
  1424. static inline int security_tun_dev_open(void *security)
  1425. {
  1426. return 0;
  1427. }
  1428. static inline int security_sctp_assoc_request(struct sctp_association *asoc,
  1429. struct sk_buff *skb)
  1430. {
  1431. return 0;
  1432. }
  1433. static inline int security_sctp_bind_connect(struct sock *sk, int optname,
  1434. struct sockaddr *address,
  1435. int addrlen)
  1436. {
  1437. return 0;
  1438. }
  1439. static inline void security_sctp_sk_clone(struct sctp_association *asoc,
  1440. struct sock *sk,
  1441. struct sock *newsk)
  1442. {
  1443. }
  1444. static inline int security_sctp_assoc_established(struct sctp_association *asoc,
  1445. struct sk_buff *skb)
  1446. {
  1447. return 0;
  1448. }
  1449. #endif /* CONFIG_SECURITY_NETWORK */
  1450. #ifdef CONFIG_SECURITY_INFINIBAND
  1451. int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey);
  1452. int security_ib_endport_manage_subnet(void *sec, const char *name, u8 port_num);
  1453. int security_ib_alloc_security(void **sec);
  1454. void security_ib_free_security(void *sec);
  1455. #else /* CONFIG_SECURITY_INFINIBAND */
  1456. static inline int security_ib_pkey_access(void *sec, u64 subnet_prefix, u16 pkey)
  1457. {
  1458. return 0;
  1459. }
  1460. static inline int security_ib_endport_manage_subnet(void *sec, const char *dev_name, u8 port_num)
  1461. {
  1462. return 0;
  1463. }
  1464. static inline int security_ib_alloc_security(void **sec)
  1465. {
  1466. return 0;
  1467. }
  1468. static inline void security_ib_free_security(void *sec)
  1469. {
  1470. }
  1471. #endif /* CONFIG_SECURITY_INFINIBAND */
  1472. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  1473. int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
  1474. struct xfrm_user_sec_ctx *sec_ctx, gfp_t gfp);
  1475. int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx, struct xfrm_sec_ctx **new_ctxp);
  1476. void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx);
  1477. int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx);
  1478. int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
  1479. int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
  1480. struct xfrm_sec_ctx *polsec, u32 secid);
  1481. int security_xfrm_state_delete(struct xfrm_state *x);
  1482. void security_xfrm_state_free(struct xfrm_state *x);
  1483. int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid);
  1484. int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
  1485. struct xfrm_policy *xp,
  1486. const struct flowi_common *flic);
  1487. int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid);
  1488. void security_skb_classify_flow(struct sk_buff *skb, struct flowi_common *flic);
  1489. #else /* CONFIG_SECURITY_NETWORK_XFRM */
  1490. static inline int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
  1491. struct xfrm_user_sec_ctx *sec_ctx,
  1492. gfp_t gfp)
  1493. {
  1494. return 0;
  1495. }
  1496. static inline int security_xfrm_policy_clone(struct xfrm_sec_ctx *old, struct xfrm_sec_ctx **new_ctxp)
  1497. {
  1498. return 0;
  1499. }
  1500. static inline void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
  1501. {
  1502. }
  1503. static inline int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
  1504. {
  1505. return 0;
  1506. }
  1507. static inline int security_xfrm_state_alloc(struct xfrm_state *x,
  1508. struct xfrm_user_sec_ctx *sec_ctx)
  1509. {
  1510. return 0;
  1511. }
  1512. static inline int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
  1513. struct xfrm_sec_ctx *polsec, u32 secid)
  1514. {
  1515. return 0;
  1516. }
  1517. static inline void security_xfrm_state_free(struct xfrm_state *x)
  1518. {
  1519. }
  1520. static inline int security_xfrm_state_delete(struct xfrm_state *x)
  1521. {
  1522. return 0;
  1523. }
  1524. static inline int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid)
  1525. {
  1526. return 0;
  1527. }
  1528. static inline int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
  1529. struct xfrm_policy *xp,
  1530. const struct flowi_common *flic)
  1531. {
  1532. return 1;
  1533. }
  1534. static inline int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
  1535. {
  1536. return 0;
  1537. }
  1538. static inline void security_skb_classify_flow(struct sk_buff *skb,
  1539. struct flowi_common *flic)
  1540. {
  1541. }
  1542. #endif /* CONFIG_SECURITY_NETWORK_XFRM */
  1543. #ifdef CONFIG_SECURITY_PATH
  1544. int security_path_unlink(const struct path *dir, struct dentry *dentry);
  1545. int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode);
  1546. int security_path_rmdir(const struct path *dir, struct dentry *dentry);
  1547. int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode,
  1548. unsigned int dev);
  1549. int security_path_truncate(const struct path *path);
  1550. int security_path_symlink(const struct path *dir, struct dentry *dentry,
  1551. const char *old_name);
  1552. int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
  1553. struct dentry *new_dentry);
  1554. int security_path_rename(const struct path *old_dir, struct dentry *old_dentry,
  1555. const struct path *new_dir, struct dentry *new_dentry,
  1556. unsigned int flags);
  1557. int security_path_chmod(const struct path *path, umode_t mode);
  1558. int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid);
  1559. int security_path_chroot(const struct path *path);
  1560. #else /* CONFIG_SECURITY_PATH */
  1561. static inline int security_path_unlink(const struct path *dir, struct dentry *dentry)
  1562. {
  1563. return 0;
  1564. }
  1565. static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry,
  1566. umode_t mode)
  1567. {
  1568. return 0;
  1569. }
  1570. static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry)
  1571. {
  1572. return 0;
  1573. }
  1574. static inline int security_path_mknod(const struct path *dir, struct dentry *dentry,
  1575. umode_t mode, unsigned int dev)
  1576. {
  1577. return 0;
  1578. }
  1579. static inline int security_path_truncate(const struct path *path)
  1580. {
  1581. return 0;
  1582. }
  1583. static inline int security_path_symlink(const struct path *dir, struct dentry *dentry,
  1584. const char *old_name)
  1585. {
  1586. return 0;
  1587. }
  1588. static inline int security_path_link(struct dentry *old_dentry,
  1589. const struct path *new_dir,
  1590. struct dentry *new_dentry)
  1591. {
  1592. return 0;
  1593. }
  1594. static inline int security_path_rename(const struct path *old_dir,
  1595. struct dentry *old_dentry,
  1596. const struct path *new_dir,
  1597. struct dentry *new_dentry,
  1598. unsigned int flags)
  1599. {
  1600. return 0;
  1601. }
  1602. static inline int security_path_chmod(const struct path *path, umode_t mode)
  1603. {
  1604. return 0;
  1605. }
  1606. static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
  1607. {
  1608. return 0;
  1609. }
  1610. static inline int security_path_chroot(const struct path *path)
  1611. {
  1612. return 0;
  1613. }
  1614. #endif /* CONFIG_SECURITY_PATH */
  1615. #ifdef CONFIG_KEYS
  1616. #ifdef CONFIG_SECURITY
  1617. int security_key_alloc(struct key *key, const struct cred *cred, unsigned long flags);
  1618. void security_key_free(struct key *key);
  1619. int security_key_permission(key_ref_t key_ref, const struct cred *cred,
  1620. enum key_need_perm need_perm);
  1621. int security_key_getsecurity(struct key *key, char **_buffer);
  1622. #else
  1623. static inline int security_key_alloc(struct key *key,
  1624. const struct cred *cred,
  1625. unsigned long flags)
  1626. {
  1627. return 0;
  1628. }
  1629. static inline void security_key_free(struct key *key)
  1630. {
  1631. }
  1632. static inline int security_key_permission(key_ref_t key_ref,
  1633. const struct cred *cred,
  1634. enum key_need_perm need_perm)
  1635. {
  1636. return 0;
  1637. }
  1638. static inline int security_key_getsecurity(struct key *key, char **_buffer)
  1639. {
  1640. *_buffer = NULL;
  1641. return 0;
  1642. }
  1643. #endif
  1644. #endif /* CONFIG_KEYS */
  1645. #ifdef CONFIG_AUDIT
  1646. #ifdef CONFIG_SECURITY
  1647. int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule);
  1648. int security_audit_rule_known(struct audit_krule *krule);
  1649. int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule);
  1650. void security_audit_rule_free(void *lsmrule);
  1651. #else
  1652. static inline int security_audit_rule_init(u32 field, u32 op, char *rulestr,
  1653. void **lsmrule)
  1654. {
  1655. return 0;
  1656. }
  1657. static inline int security_audit_rule_known(struct audit_krule *krule)
  1658. {
  1659. return 0;
  1660. }
  1661. static inline int security_audit_rule_match(u32 secid, u32 field, u32 op,
  1662. void *lsmrule)
  1663. {
  1664. return 0;
  1665. }
  1666. static inline void security_audit_rule_free(void *lsmrule)
  1667. { }
  1668. #endif /* CONFIG_SECURITY */
  1669. #endif /* CONFIG_AUDIT */
  1670. #ifdef CONFIG_SECURITYFS
  1671. extern struct dentry *securityfs_create_file(const char *name, umode_t mode,
  1672. struct dentry *parent, void *data,
  1673. const struct file_operations *fops);
  1674. extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
  1675. struct dentry *securityfs_create_symlink(const char *name,
  1676. struct dentry *parent,
  1677. const char *target,
  1678. const struct inode_operations *iops);
  1679. extern void securityfs_remove(struct dentry *dentry);
  1680. #else /* CONFIG_SECURITYFS */
  1681. static inline struct dentry *securityfs_create_dir(const char *name,
  1682. struct dentry *parent)
  1683. {
  1684. return ERR_PTR(-ENODEV);
  1685. }
  1686. static inline struct dentry *securityfs_create_file(const char *name,
  1687. umode_t mode,
  1688. struct dentry *parent,
  1689. void *data,
  1690. const struct file_operations *fops)
  1691. {
  1692. return ERR_PTR(-ENODEV);
  1693. }
  1694. static inline struct dentry *securityfs_create_symlink(const char *name,
  1695. struct dentry *parent,
  1696. const char *target,
  1697. const struct inode_operations *iops)
  1698. {
  1699. return ERR_PTR(-ENODEV);
  1700. }
  1701. static inline void securityfs_remove(struct dentry *dentry)
  1702. {}
  1703. #endif
  1704. #ifdef CONFIG_BPF_SYSCALL
  1705. union bpf_attr;
  1706. struct bpf_map;
  1707. struct bpf_prog;
  1708. struct bpf_prog_aux;
  1709. #ifdef CONFIG_SECURITY
  1710. extern int security_bpf(int cmd, union bpf_attr *attr, unsigned int size);
  1711. extern int security_bpf_map(struct bpf_map *map, fmode_t fmode);
  1712. extern int security_bpf_prog(struct bpf_prog *prog);
  1713. extern int security_bpf_map_alloc(struct bpf_map *map);
  1714. extern void security_bpf_map_free(struct bpf_map *map);
  1715. extern int security_bpf_prog_alloc(struct bpf_prog_aux *aux);
  1716. extern void security_bpf_prog_free(struct bpf_prog_aux *aux);
  1717. #else
  1718. static inline int security_bpf(int cmd, union bpf_attr *attr,
  1719. unsigned int size)
  1720. {
  1721. return 0;
  1722. }
  1723. static inline int security_bpf_map(struct bpf_map *map, fmode_t fmode)
  1724. {
  1725. return 0;
  1726. }
  1727. static inline int security_bpf_prog(struct bpf_prog *prog)
  1728. {
  1729. return 0;
  1730. }
  1731. static inline int security_bpf_map_alloc(struct bpf_map *map)
  1732. {
  1733. return 0;
  1734. }
  1735. static inline void security_bpf_map_free(struct bpf_map *map)
  1736. { }
  1737. static inline int security_bpf_prog_alloc(struct bpf_prog_aux *aux)
  1738. {
  1739. return 0;
  1740. }
  1741. static inline void security_bpf_prog_free(struct bpf_prog_aux *aux)
  1742. { }
  1743. #endif /* CONFIG_SECURITY */
  1744. #endif /* CONFIG_BPF_SYSCALL */
  1745. #ifdef CONFIG_PERF_EVENTS
  1746. struct perf_event_attr;
  1747. struct perf_event;
  1748. #ifdef CONFIG_SECURITY
  1749. extern int security_perf_event_open(struct perf_event_attr *attr, int type);
  1750. extern int security_perf_event_alloc(struct perf_event *event);
  1751. extern void security_perf_event_free(struct perf_event *event);
  1752. extern int security_perf_event_read(struct perf_event *event);
  1753. extern int security_perf_event_write(struct perf_event *event);
  1754. #else
  1755. static inline int security_perf_event_open(struct perf_event_attr *attr,
  1756. int type)
  1757. {
  1758. return 0;
  1759. }
  1760. static inline int security_perf_event_alloc(struct perf_event *event)
  1761. {
  1762. return 0;
  1763. }
  1764. static inline void security_perf_event_free(struct perf_event *event)
  1765. {
  1766. }
  1767. static inline int security_perf_event_read(struct perf_event *event)
  1768. {
  1769. return 0;
  1770. }
  1771. static inline int security_perf_event_write(struct perf_event *event)
  1772. {
  1773. return 0;
  1774. }
  1775. #endif /* CONFIG_SECURITY */
  1776. #endif /* CONFIG_PERF_EVENTS */
  1777. #ifdef CONFIG_IO_URING
  1778. #ifdef CONFIG_SECURITY
  1779. extern int security_uring_override_creds(const struct cred *new);
  1780. extern int security_uring_sqpoll(void);
  1781. extern int security_uring_cmd(struct io_uring_cmd *ioucmd);
  1782. #else
  1783. static inline int security_uring_override_creds(const struct cred *new)
  1784. {
  1785. return 0;
  1786. }
  1787. static inline int security_uring_sqpoll(void)
  1788. {
  1789. return 0;
  1790. }
  1791. static inline int security_uring_cmd(struct io_uring_cmd *ioucmd)
  1792. {
  1793. return 0;
  1794. }
  1795. #endif /* CONFIG_SECURITY */
  1796. #endif /* CONFIG_IO_URING */
  1797. #endif /* ! __LINUX_SECURITY_H */