lsm_hooks.h 89 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065
  1. /*
  2. * Linux Security Module interfaces
  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. * Copyright (C) 2015 Intel Corporation.
  10. * Copyright (C) 2015 Casey Schaufler <casey@schaufler-ca.com>
  11. * Copyright (C) 2016 Mellanox Techonologies
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 2 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * Due to this file being licensed under the GPL there is controversy over
  19. * whether this permits you to write a module that #includes this file
  20. * without placing your module under the GPL. Please consult a lawyer for
  21. * advice before doing this.
  22. *
  23. */
  24. #ifndef __LINUX_LSM_HOOKS_H
  25. #define __LINUX_LSM_HOOKS_H
  26. #include <linux/security.h>
  27. #include <linux/init.h>
  28. #include <linux/rculist.h>
  29. /**
  30. * union security_list_options - Linux Security Module hook function list
  31. *
  32. * Security hooks for program execution operations.
  33. *
  34. * @bprm_set_creds:
  35. * Save security information in the bprm->security field, typically based
  36. * on information about the bprm->file, for later use by the apply_creds
  37. * hook. This hook may also optionally check permissions (e.g. for
  38. * transitions between security domains).
  39. * This hook may be called multiple times during a single execve, e.g. for
  40. * interpreters. The hook can tell whether it has already been called by
  41. * checking to see if @bprm->security is non-NULL. If so, then the hook
  42. * may decide either to retain the security information saved earlier or
  43. * to replace it. The hook must set @bprm->secureexec to 1 if a "secure
  44. * exec" has happened as a result of this hook call. The flag is used to
  45. * indicate the need for a sanitized execution environment, and is also
  46. * passed in the ELF auxiliary table on the initial stack to indicate
  47. * whether libc should enable secure mode.
  48. * @bprm contains the linux_binprm structure.
  49. * Return 0 if the hook is successful and permission is granted.
  50. * @bprm_check_security:
  51. * This hook mediates the point when a search for a binary handler will
  52. * begin. It allows a check the @bprm->security value which is set in the
  53. * preceding set_creds call. The primary difference from set_creds is
  54. * that the argv list and envp list are reliably available in @bprm. This
  55. * hook may be called multiple times during a single execve; and in each
  56. * pass set_creds is called first.
  57. * @bprm contains the linux_binprm structure.
  58. * Return 0 if the hook is successful and permission is granted.
  59. * @bprm_committing_creds:
  60. * Prepare to install the new security attributes of a process being
  61. * transformed by an execve operation, based on the old credentials
  62. * pointed to by @current->cred and the information set in @bprm->cred by
  63. * the bprm_set_creds hook. @bprm points to the linux_binprm structure.
  64. * This hook is a good place to perform state changes on the process such
  65. * as closing open file descriptors to which access will no longer be
  66. * granted when the attributes are changed. This is called immediately
  67. * before commit_creds().
  68. * @bprm_committed_creds:
  69. * Tidy up after the installation of the new security attributes of a
  70. * process being transformed by an execve operation. The new credentials
  71. * have, by this point, been set to @current->cred. @bprm points to the
  72. * linux_binprm structure. This hook is a good place to perform state
  73. * changes on the process such as clearing out non-inheritable signal
  74. * state. This is called immediately after commit_creds().
  75. *
  76. * Security hooks for filesystem operations.
  77. *
  78. * @sb_alloc_security:
  79. * Allocate and attach a security structure to the sb->s_security field.
  80. * The s_security field is initialized to NULL when the structure is
  81. * allocated.
  82. * @sb contains the super_block structure to be modified.
  83. * Return 0 if operation was successful.
  84. * @sb_free_security:
  85. * Deallocate and clear the sb->s_security field.
  86. * @sb contains the super_block structure to be modified.
  87. * @sb_statfs:
  88. * Check permission before obtaining filesystem statistics for the @mnt
  89. * mountpoint.
  90. * @dentry is a handle on the superblock for the filesystem.
  91. * Return 0 if permission is granted.
  92. * @sb_mount:
  93. * Check permission before an object specified by @dev_name is mounted on
  94. * the mount point named by @nd. For an ordinary mount, @dev_name
  95. * identifies a device if the file system type requires a device. For a
  96. * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
  97. * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
  98. * pathname of the object being mounted.
  99. * @dev_name contains the name for object being mounted.
  100. * @path contains the path for mount point object.
  101. * @type contains the filesystem type.
  102. * @flags contains the mount flags.
  103. * @data contains the filesystem-specific data.
  104. * Return 0 if permission is granted.
  105. * @sb_copy_data:
  106. * Allow mount option data to be copied prior to parsing by the filesystem,
  107. * so that the security module can extract security-specific mount
  108. * options cleanly (a filesystem may modify the data e.g. with strsep()).
  109. * This also allows the original mount data to be stripped of security-
  110. * specific options to avoid having to make filesystems aware of them.
  111. * @type the type of filesystem being mounted.
  112. * @orig the original mount data copied from userspace.
  113. * @copy copied data which will be passed to the security module.
  114. * Returns 0 if the copy was successful.
  115. * @sb_remount:
  116. * Extracts security system specific mount options and verifies no changes
  117. * are being made to those options.
  118. * @sb superblock being remounted
  119. * @data contains the filesystem-specific data.
  120. * Return 0 if permission is granted.
  121. * @sb_umount:
  122. * Check permission before the @mnt file system is unmounted.
  123. * @mnt contains the mounted file system.
  124. * @flags contains the unmount flags, e.g. MNT_FORCE.
  125. * Return 0 if permission is granted.
  126. * @sb_pivotroot:
  127. * Check permission before pivoting the root filesystem.
  128. * @old_path contains the path for the new location of the
  129. * current root (put_old).
  130. * @new_path contains the path for the new root (new_root).
  131. * Return 0 if permission is granted.
  132. * @sb_set_mnt_opts:
  133. * Set the security relevant mount options used for a superblock
  134. * @sb the superblock to set security mount options for
  135. * @opts binary data structure containing all lsm mount data
  136. * @sb_clone_mnt_opts:
  137. * Copy all security options from a given superblock to another
  138. * @oldsb old superblock which contain information to clone
  139. * @newsb new superblock which needs filled in
  140. * @sb_parse_opts_str:
  141. * Parse a string of security data filling in the opts structure
  142. * @options string containing all mount options known by the LSM
  143. * @opts binary data structure usable by the LSM
  144. * @dentry_init_security:
  145. * Compute a context for a dentry as the inode is not yet available
  146. * since NFSv4 has no label backed by an EA anyway.
  147. * @dentry dentry to use in calculating the context.
  148. * @mode mode used to determine resource type.
  149. * @name name of the last path component used to create file
  150. * @ctx pointer to place the pointer to the resulting context in.
  151. * @ctxlen point to place the length of the resulting context.
  152. * @dentry_create_files_as:
  153. * Compute a context for a dentry as the inode is not yet available
  154. * and set that context in passed in creds so that new files are
  155. * created using that context. Context is calculated using the
  156. * passed in creds and not the creds of the caller.
  157. * @dentry dentry to use in calculating the context.
  158. * @mode mode used to determine resource type.
  159. * @name name of the last path component used to create file
  160. * @old creds which should be used for context calculation
  161. * @new creds to modify
  162. *
  163. *
  164. * Security hooks for inode operations.
  165. *
  166. * @inode_alloc_security:
  167. * Allocate and attach a security structure to @inode->i_security. The
  168. * i_security field is initialized to NULL when the inode structure is
  169. * allocated.
  170. * @inode contains the inode structure.
  171. * Return 0 if operation was successful.
  172. * @inode_free_security:
  173. * @inode contains the inode structure.
  174. * Deallocate the inode security structure and set @inode->i_security to
  175. * NULL.
  176. * @inode_init_security:
  177. * Obtain the security attribute name suffix and value to set on a newly
  178. * created inode and set up the incore security field for the new inode.
  179. * This hook is called by the fs code as part of the inode creation
  180. * transaction and provides for atomic labeling of the inode, unlike
  181. * the post_create/mkdir/... hooks called by the VFS. The hook function
  182. * is expected to allocate the name and value via kmalloc, with the caller
  183. * being responsible for calling kfree after using them.
  184. * If the security module does not use security attributes or does
  185. * not wish to put a security attribute on this particular inode,
  186. * then it should return -EOPNOTSUPP to skip this processing.
  187. * @inode contains the inode structure of the newly created inode.
  188. * @dir contains the inode structure of the parent directory.
  189. * @qstr contains the last path component of the new object
  190. * @name will be set to the allocated name suffix (e.g. selinux).
  191. * @value will be set to the allocated attribute value.
  192. * @len will be set to the length of the value.
  193. * Returns 0 if @name and @value have been successfully set,
  194. * -EOPNOTSUPP if no security attribute is needed, or
  195. * -ENOMEM on memory allocation failure.
  196. * @inode_create:
  197. * Check permission to create a regular file.
  198. * @dir contains inode structure of the parent of the new file.
  199. * @dentry contains the dentry structure for the file to be created.
  200. * @mode contains the file mode of the file to be created.
  201. * Return 0 if permission is granted.
  202. * @inode_link:
  203. * Check permission before creating a new hard link to a file.
  204. * @old_dentry contains the dentry structure for an existing
  205. * link to the file.
  206. * @dir contains the inode structure of the parent directory
  207. * of the new link.
  208. * @new_dentry contains the dentry structure for the new link.
  209. * Return 0 if permission is granted.
  210. * @path_link:
  211. * Check permission before creating a new hard link to a file.
  212. * @old_dentry contains the dentry structure for an existing link
  213. * to the file.
  214. * @new_dir contains the path structure of the parent directory of
  215. * the new link.
  216. * @new_dentry contains the dentry structure for the new link.
  217. * Return 0 if permission is granted.
  218. * @inode_unlink:
  219. * Check the permission to remove a hard link to a file.
  220. * @dir contains the inode structure of parent directory of the file.
  221. * @dentry contains the dentry structure for file to be unlinked.
  222. * Return 0 if permission is granted.
  223. * @path_unlink:
  224. * Check the permission to remove a hard link to a file.
  225. * @dir contains the path structure of parent directory of the file.
  226. * @dentry contains the dentry structure for file to be unlinked.
  227. * Return 0 if permission is granted.
  228. * @inode_symlink:
  229. * Check the permission to create a symbolic link to a file.
  230. * @dir contains the inode structure of parent directory of
  231. * the symbolic link.
  232. * @dentry contains the dentry structure of the symbolic link.
  233. * @old_name contains the pathname of file.
  234. * Return 0 if permission is granted.
  235. * @path_symlink:
  236. * Check the permission to create a symbolic link to a file.
  237. * @dir contains the path structure of parent directory of
  238. * the symbolic link.
  239. * @dentry contains the dentry structure of the symbolic link.
  240. * @old_name contains the pathname of file.
  241. * Return 0 if permission is granted.
  242. * @inode_mkdir:
  243. * Check permissions to create a new directory in the existing directory
  244. * associated with inode structure @dir.
  245. * @dir contains the inode structure of parent of the directory
  246. * to be created.
  247. * @dentry contains the dentry structure of new directory.
  248. * @mode contains the mode of new directory.
  249. * Return 0 if permission is granted.
  250. * @path_mkdir:
  251. * Check permissions to create a new directory in the existing directory
  252. * associated with path structure @path.
  253. * @dir contains the path structure of parent of the directory
  254. * to be created.
  255. * @dentry contains the dentry structure of new directory.
  256. * @mode contains the mode of new directory.
  257. * Return 0 if permission is granted.
  258. * @inode_rmdir:
  259. * Check the permission to remove a directory.
  260. * @dir contains the inode structure of parent of the directory
  261. * to be removed.
  262. * @dentry contains the dentry structure of directory to be removed.
  263. * Return 0 if permission is granted.
  264. * @path_rmdir:
  265. * Check the permission to remove a directory.
  266. * @dir contains the path structure of parent of the directory to be
  267. * removed.
  268. * @dentry contains the dentry structure of directory to be removed.
  269. * Return 0 if permission is granted.
  270. * @inode_mknod:
  271. * Check permissions when creating a special file (or a socket or a fifo
  272. * file created via the mknod system call). Note that if mknod operation
  273. * is being done for a regular file, then the create hook will be called
  274. * and not this hook.
  275. * @dir contains the inode structure of parent of the new file.
  276. * @dentry contains the dentry structure of the new file.
  277. * @mode contains the mode of the new file.
  278. * @dev contains the device number.
  279. * Return 0 if permission is granted.
  280. * @path_mknod:
  281. * Check permissions when creating a file. Note that this hook is called
  282. * even if mknod operation is being done for a regular file.
  283. * @dir contains the path structure of parent of the new file.
  284. * @dentry contains the dentry structure of the new file.
  285. * @mode contains the mode of the new file.
  286. * @dev contains the undecoded device number. Use new_decode_dev() to get
  287. * the decoded device number.
  288. * Return 0 if permission is granted.
  289. * @inode_rename:
  290. * Check for permission to rename a file or directory.
  291. * @old_dir contains the inode structure for parent of the old link.
  292. * @old_dentry contains the dentry structure of the old link.
  293. * @new_dir contains the inode structure for parent of the new link.
  294. * @new_dentry contains the dentry structure of the new link.
  295. * Return 0 if permission is granted.
  296. * @path_rename:
  297. * Check for permission to rename a file or directory.
  298. * @old_dir contains the path structure for parent of the old link.
  299. * @old_dentry contains the dentry structure of the old link.
  300. * @new_dir contains the path structure for parent of the new link.
  301. * @new_dentry contains the dentry structure of the new link.
  302. * Return 0 if permission is granted.
  303. * @path_chmod:
  304. * Check for permission to change DAC's permission of a file or directory.
  305. * @dentry contains the dentry structure.
  306. * @mnt contains the vfsmnt structure.
  307. * @mode contains DAC's mode.
  308. * Return 0 if permission is granted.
  309. * @path_chown:
  310. * Check for permission to change owner/group of a file or directory.
  311. * @path contains the path structure.
  312. * @uid contains new owner's ID.
  313. * @gid contains new group's ID.
  314. * Return 0 if permission is granted.
  315. * @path_chroot:
  316. * Check for permission to change root directory.
  317. * @path contains the path structure.
  318. * Return 0 if permission is granted.
  319. * @inode_readlink:
  320. * Check the permission to read the symbolic link.
  321. * @dentry contains the dentry structure for the file link.
  322. * Return 0 if permission is granted.
  323. * @inode_follow_link:
  324. * Check permission to follow a symbolic link when looking up a pathname.
  325. * @dentry contains the dentry structure for the link.
  326. * @inode contains the inode, which itself is not stable in RCU-walk
  327. * @rcu indicates whether we are in RCU-walk mode.
  328. * Return 0 if permission is granted.
  329. * @inode_permission:
  330. * Check permission before accessing an inode. This hook is called by the
  331. * existing Linux permission function, so a security module can use it to
  332. * provide additional checking for existing Linux permission checks.
  333. * Notice that this hook is called when a file is opened (as well as many
  334. * other operations), whereas the file_security_ops permission hook is
  335. * called when the actual read/write operations are performed.
  336. * @inode contains the inode structure to check.
  337. * @mask contains the permission mask.
  338. * Return 0 if permission is granted.
  339. * @inode_setattr:
  340. * Check permission before setting file attributes. Note that the kernel
  341. * call to notify_change is performed from several locations, whenever
  342. * file attributes change (such as when a file is truncated, chown/chmod
  343. * operations, transferring disk quotas, etc).
  344. * @dentry contains the dentry structure for the file.
  345. * @attr is the iattr structure containing the new file attributes.
  346. * Return 0 if permission is granted.
  347. * @path_truncate:
  348. * Check permission before truncating a file.
  349. * @path contains the path structure for the file.
  350. * Return 0 if permission is granted.
  351. * @inode_getattr:
  352. * Check permission before obtaining file attributes.
  353. * @path contains the path structure for the file.
  354. * Return 0 if permission is granted.
  355. * @inode_setxattr:
  356. * Check permission before setting the extended attributes
  357. * @value identified by @name for @dentry.
  358. * Return 0 if permission is granted.
  359. * @inode_post_setxattr:
  360. * Update inode security field after successful setxattr operation.
  361. * @value identified by @name for @dentry.
  362. * @inode_getxattr:
  363. * Check permission before obtaining the extended attributes
  364. * identified by @name for @dentry.
  365. * Return 0 if permission is granted.
  366. * @inode_listxattr:
  367. * Check permission before obtaining the list of extended attribute
  368. * names for @dentry.
  369. * Return 0 if permission is granted.
  370. * @inode_removexattr:
  371. * Check permission before removing the extended attribute
  372. * identified by @name for @dentry.
  373. * Return 0 if permission is granted.
  374. * @inode_getsecurity:
  375. * Retrieve a copy of the extended attribute representation of the
  376. * security label associated with @name for @inode via @buffer. Note that
  377. * @name is the remainder of the attribute name after the security prefix
  378. * has been removed. @alloc is used to specify of the call should return a
  379. * value via the buffer or just the value length Return size of buffer on
  380. * success.
  381. * @inode_setsecurity:
  382. * Set the security label associated with @name for @inode from the
  383. * extended attribute value @value. @size indicates the size of the
  384. * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
  385. * Note that @name is the remainder of the attribute name after the
  386. * security. prefix has been removed.
  387. * Return 0 on success.
  388. * @inode_listsecurity:
  389. * Copy the extended attribute names for the security labels
  390. * associated with @inode into @buffer. The maximum size of @buffer
  391. * is specified by @buffer_size. @buffer may be NULL to request
  392. * the size of the buffer required.
  393. * Returns number of bytes used/required on success.
  394. * @inode_need_killpriv:
  395. * Called when an inode has been changed.
  396. * @dentry is the dentry being changed.
  397. * Return <0 on error to abort the inode change operation.
  398. * Return 0 if inode_killpriv does not need to be called.
  399. * Return >0 if inode_killpriv does need to be called.
  400. * @inode_killpriv:
  401. * The setuid bit is being removed. Remove similar security labels.
  402. * Called with the dentry->d_inode->i_mutex held.
  403. * @dentry is the dentry being changed.
  404. * Return 0 on success. If error is returned, then the operation
  405. * causing setuid bit removal is failed.
  406. * @inode_getsecid:
  407. * Get the secid associated with the node.
  408. * @inode contains a pointer to the inode.
  409. * @secid contains a pointer to the location where result will be saved.
  410. * In case of failure, @secid will be set to zero.
  411. * @inode_copy_up:
  412. * A file is about to be copied up from lower layer to upper layer of
  413. * overlay filesystem. Security module can prepare a set of new creds
  414. * and modify as need be and return new creds. Caller will switch to
  415. * new creds temporarily to create new file and release newly allocated
  416. * creds.
  417. * @src indicates the union dentry of file that is being copied up.
  418. * @new pointer to pointer to return newly allocated creds.
  419. * Returns 0 on success or a negative error code on error.
  420. * @inode_copy_up_xattr:
  421. * Filter the xattrs being copied up when a unioned file is copied
  422. * up from a lower layer to the union/overlay layer.
  423. * @name indicates the name of the xattr.
  424. * Returns 0 to accept the xattr, 1 to discard the xattr, -EOPNOTSUPP if
  425. * security module does not know about attribute or a negative error code
  426. * to abort the copy up. Note that the caller is responsible for reading
  427. * and writing the xattrs as this hook is merely a filter.
  428. *
  429. * Security hooks for file operations
  430. *
  431. * @file_permission:
  432. * Check file permissions before accessing an open file. This hook is
  433. * called by various operations that read or write files. A security
  434. * module can use this hook to perform additional checking on these
  435. * operations, e.g. to revalidate permissions on use to support privilege
  436. * bracketing or policy changes. Notice that this hook is used when the
  437. * actual read/write operations are performed, whereas the
  438. * inode_security_ops hook is called when a file is opened (as well as
  439. * many other operations).
  440. * Caveat: Although this hook can be used to revalidate permissions for
  441. * various system call operations that read or write files, it does not
  442. * address the revalidation of permissions for memory-mapped files.
  443. * Security modules must handle this separately if they need such
  444. * revalidation.
  445. * @file contains the file structure being accessed.
  446. * @mask contains the requested permissions.
  447. * Return 0 if permission is granted.
  448. * @file_alloc_security:
  449. * Allocate and attach a security structure to the file->f_security field.
  450. * The security field is initialized to NULL when the structure is first
  451. * created.
  452. * @file contains the file structure to secure.
  453. * Return 0 if the hook is successful and permission is granted.
  454. * @file_free_security:
  455. * Deallocate and free any security structures stored in file->f_security.
  456. * @file contains the file structure being modified.
  457. * @file_ioctl:
  458. * @file contains the file structure.
  459. * @cmd contains the operation to perform.
  460. * @arg contains the operational arguments.
  461. * Check permission for an ioctl operation on @file. Note that @arg
  462. * sometimes represents a user space pointer; in other cases, it may be a
  463. * simple integer value. When @arg represents a user space pointer, it
  464. * should never be used by the security module.
  465. * Return 0 if permission is granted.
  466. * @mmap_addr :
  467. * Check permissions for a mmap operation at @addr.
  468. * @addr contains virtual address that will be used for the operation.
  469. * Return 0 if permission is granted.
  470. * @mmap_file :
  471. * Check permissions for a mmap operation. The @file may be NULL, e.g.
  472. * if mapping anonymous memory.
  473. * @file contains the file structure for file to map (may be NULL).
  474. * @reqprot contains the protection requested by the application.
  475. * @prot contains the protection that will be applied by the kernel.
  476. * @flags contains the operational flags.
  477. * Return 0 if permission is granted.
  478. * @file_mprotect:
  479. * Check permissions before changing memory access permissions.
  480. * @vma contains the memory region to modify.
  481. * @reqprot contains the protection requested by the application.
  482. * @prot contains the protection that will be applied by the kernel.
  483. * Return 0 if permission is granted.
  484. * @file_lock:
  485. * Check permission before performing file locking operations.
  486. * Note: this hook mediates both flock and fcntl style locks.
  487. * @file contains the file structure.
  488. * @cmd contains the posix-translated lock operation to perform
  489. * (e.g. F_RDLCK, F_WRLCK).
  490. * Return 0 if permission is granted.
  491. * @file_fcntl:
  492. * Check permission before allowing the file operation specified by @cmd
  493. * from being performed on the file @file. Note that @arg sometimes
  494. * represents a user space pointer; in other cases, it may be a simple
  495. * integer value. When @arg represents a user space pointer, it should
  496. * never be used by the security module.
  497. * @file contains the file structure.
  498. * @cmd contains the operation to be performed.
  499. * @arg contains the operational arguments.
  500. * Return 0 if permission is granted.
  501. * @file_set_fowner:
  502. * Save owner security information (typically from current->security) in
  503. * file->f_security for later use by the send_sigiotask hook.
  504. * @file contains the file structure to update.
  505. * Return 0 on success.
  506. * @file_send_sigiotask:
  507. * Check permission for the file owner @fown to send SIGIO or SIGURG to the
  508. * process @tsk. Note that this hook is sometimes called from interrupt.
  509. * Note that the fown_struct, @fown, is never outside the context of a
  510. * struct file, so the file structure (and associated security information)
  511. * can always be obtained: container_of(fown, struct file, f_owner)
  512. * @tsk contains the structure of task receiving signal.
  513. * @fown contains the file owner information.
  514. * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
  515. * Return 0 if permission is granted.
  516. * @file_receive:
  517. * This hook allows security modules to control the ability of a process
  518. * to receive an open file descriptor via socket IPC.
  519. * @file contains the file structure being received.
  520. * Return 0 if permission is granted.
  521. * @file_open:
  522. * Save open-time permission checking state for later use upon
  523. * file_permission, and recheck access if anything has changed
  524. * since inode_permission.
  525. *
  526. * Security hooks for task operations.
  527. *
  528. * @task_alloc:
  529. * @task task being allocated.
  530. * @clone_flags contains the flags indicating what should be shared.
  531. * Handle allocation of task-related resources.
  532. * Returns a zero on success, negative values on failure.
  533. * @task_free:
  534. * @task task about to be freed.
  535. * Handle release of task-related resources. (Note that this can be called
  536. * from interrupt context.)
  537. * @cred_alloc_blank:
  538. * @cred points to the credentials.
  539. * @gfp indicates the atomicity of any memory allocations.
  540. * Only allocate sufficient memory and attach to @cred such that
  541. * cred_transfer() will not get ENOMEM.
  542. * @cred_free:
  543. * @cred points to the credentials.
  544. * Deallocate and clear the cred->security field in a set of credentials.
  545. * @cred_prepare:
  546. * @new points to the new credentials.
  547. * @old points to the original credentials.
  548. * @gfp indicates the atomicity of any memory allocations.
  549. * Prepare a new set of credentials by copying the data from the old set.
  550. * @cred_transfer:
  551. * @new points to the new credentials.
  552. * @old points to the original credentials.
  553. * Transfer data from original creds to new creds
  554. * @kernel_act_as:
  555. * Set the credentials for a kernel service to act as (subjective context).
  556. * @new points to the credentials to be modified.
  557. * @secid specifies the security ID to be set
  558. * The current task must be the one that nominated @secid.
  559. * Return 0 if successful.
  560. * @kernel_create_files_as:
  561. * Set the file creation context in a set of credentials to be the same as
  562. * the objective context of the specified inode.
  563. * @new points to the credentials to be modified.
  564. * @inode points to the inode to use as a reference.
  565. * The current task must be the one that nominated @inode.
  566. * Return 0 if successful.
  567. * @kernel_module_request:
  568. * Ability to trigger the kernel to automatically upcall to userspace for
  569. * userspace to load a kernel module with the given name.
  570. * @kmod_name name of the module requested by the kernel
  571. * Return 0 if successful.
  572. * @kernel_read_file:
  573. * Read a file specified by userspace.
  574. * @file contains the file structure pointing to the file being read
  575. * by the kernel.
  576. * @id kernel read file identifier
  577. * Return 0 if permission is granted.
  578. * @kernel_post_read_file:
  579. * Read a file specified by userspace.
  580. * @file contains the file structure pointing to the file being read
  581. * by the kernel.
  582. * @buf pointer to buffer containing the file contents.
  583. * @size length of the file contents.
  584. * @id kernel read file identifier
  585. * Return 0 if permission is granted.
  586. * @task_fix_setuid:
  587. * Update the module's state after setting one or more of the user
  588. * identity attributes of the current process. The @flags parameter
  589. * indicates which of the set*uid system calls invoked this hook. If
  590. * @new is the set of credentials that will be installed. Modifications
  591. * should be made to this rather than to @current->cred.
  592. * @old is the set of credentials that are being replaces
  593. * @flags contains one of the LSM_SETID_* values.
  594. * Return 0 on success.
  595. * @task_setpgid:
  596. * Check permission before setting the process group identifier of the
  597. * process @p to @pgid.
  598. * @p contains the task_struct for process being modified.
  599. * @pgid contains the new pgid.
  600. * Return 0 if permission is granted.
  601. * @task_getpgid:
  602. * Check permission before getting the process group identifier of the
  603. * process @p.
  604. * @p contains the task_struct for the process.
  605. * Return 0 if permission is granted.
  606. * @task_getsid:
  607. * Check permission before getting the session identifier of the process
  608. * @p.
  609. * @p contains the task_struct for the process.
  610. * Return 0 if permission is granted.
  611. * @task_getsecid:
  612. * Retrieve the security identifier of the process @p.
  613. * @p contains the task_struct for the process and place is into @secid.
  614. * In case of failure, @secid will be set to zero.
  615. *
  616. * @task_setnice:
  617. * Check permission before setting the nice value of @p to @nice.
  618. * @p contains the task_struct of process.
  619. * @nice contains the new nice value.
  620. * Return 0 if permission is granted.
  621. * @task_setioprio
  622. * Check permission before setting the ioprio value of @p to @ioprio.
  623. * @p contains the task_struct of process.
  624. * @ioprio contains the new ioprio value
  625. * Return 0 if permission is granted.
  626. * @task_getioprio
  627. * Check permission before getting the ioprio value of @p.
  628. * @p contains the task_struct of process.
  629. * Return 0 if permission is granted.
  630. * @task_prlimit:
  631. * Check permission before getting and/or setting the resource limits of
  632. * another task.
  633. * @cred points to the cred structure for the current task.
  634. * @tcred points to the cred structure for the target task.
  635. * @flags contains the LSM_PRLIMIT_* flag bits indicating whether the
  636. * resource limits are being read, modified, or both.
  637. * Return 0 if permission is granted.
  638. * @task_setrlimit:
  639. * Check permission before setting the resource limits of process @p
  640. * for @resource to @new_rlim. The old resource limit values can
  641. * be examined by dereferencing (p->signal->rlim + resource).
  642. * @p points to the task_struct for the target task's group leader.
  643. * @resource contains the resource whose limit is being set.
  644. * @new_rlim contains the new limits for @resource.
  645. * Return 0 if permission is granted.
  646. * @task_setscheduler:
  647. * Check permission before setting scheduling policy and/or parameters of
  648. * process @p based on @policy and @lp.
  649. * @p contains the task_struct for process.
  650. * @policy contains the scheduling policy.
  651. * @lp contains the scheduling parameters.
  652. * Return 0 if permission is granted.
  653. * @task_getscheduler:
  654. * Check permission before obtaining scheduling information for process
  655. * @p.
  656. * @p contains the task_struct for process.
  657. * Return 0 if permission is granted.
  658. * @task_movememory
  659. * Check permission before moving memory owned by process @p.
  660. * @p contains the task_struct for process.
  661. * Return 0 if permission is granted.
  662. * @task_kill:
  663. * Check permission before sending signal @sig to @p. @info can be NULL,
  664. * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
  665. * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
  666. * from the kernel and should typically be permitted.
  667. * SIGIO signals are handled separately by the send_sigiotask hook in
  668. * file_security_ops.
  669. * @p contains the task_struct for process.
  670. * @info contains the signal information.
  671. * @sig contains the signal value.
  672. * @secid contains the sid of the process where the signal originated
  673. * Return 0 if permission is granted.
  674. * @task_prctl:
  675. * Check permission before performing a process control operation on the
  676. * current process.
  677. * @option contains the operation.
  678. * @arg2 contains a argument.
  679. * @arg3 contains a argument.
  680. * @arg4 contains a argument.
  681. * @arg5 contains a argument.
  682. * Return -ENOSYS if no-one wanted to handle this op, any other value to
  683. * cause prctl() to return immediately with that value.
  684. * @task_to_inode:
  685. * Set the security attributes for an inode based on an associated task's
  686. * security attributes, e.g. for /proc/pid inodes.
  687. * @p contains the task_struct for the task.
  688. * @inode contains the inode structure for the inode.
  689. *
  690. * Security hooks for Netlink messaging.
  691. *
  692. * @netlink_send:
  693. * Save security information for a netlink message so that permission
  694. * checking can be performed when the message is processed. The security
  695. * information can be saved using the eff_cap field of the
  696. * netlink_skb_parms structure. Also may be used to provide fine
  697. * grained control over message transmission.
  698. * @sk associated sock of task sending the message.
  699. * @skb contains the sk_buff structure for the netlink message.
  700. * Return 0 if the information was successfully saved and message
  701. * is allowed to be transmitted.
  702. *
  703. * Security hooks for Unix domain networking.
  704. *
  705. * @unix_stream_connect:
  706. * Check permissions before establishing a Unix domain stream connection
  707. * between @sock and @other.
  708. * @sock contains the sock structure.
  709. * @other contains the peer sock structure.
  710. * @newsk contains the new sock structure.
  711. * Return 0 if permission is granted.
  712. * @unix_may_send:
  713. * Check permissions before connecting or sending datagrams from @sock to
  714. * @other.
  715. * @sock contains the socket structure.
  716. * @other contains the peer socket structure.
  717. * Return 0 if permission is granted.
  718. *
  719. * The @unix_stream_connect and @unix_may_send hooks were necessary because
  720. * Linux provides an alternative to the conventional file name space for Unix
  721. * domain sockets. Whereas binding and connecting to sockets in the file name
  722. * space is mediated by the typical file permissions (and caught by the mknod
  723. * and permission hooks in inode_security_ops), binding and connecting to
  724. * sockets in the abstract name space is completely unmediated. Sufficient
  725. * control of Unix domain sockets in the abstract name space isn't possible
  726. * using only the socket layer hooks, since we need to know the actual target
  727. * socket, which is not looked up until we are inside the af_unix code.
  728. *
  729. * Security hooks for socket operations.
  730. *
  731. * @socket_create:
  732. * Check permissions prior to creating a new socket.
  733. * @family contains the requested protocol family.
  734. * @type contains the requested communications type.
  735. * @protocol contains the requested protocol.
  736. * @kern set to 1 if a kernel socket.
  737. * Return 0 if permission is granted.
  738. * @socket_post_create:
  739. * This hook allows a module to update or allocate a per-socket security
  740. * structure. Note that the security field was not added directly to the
  741. * socket structure, but rather, the socket security information is stored
  742. * in the associated inode. Typically, the inode alloc_security hook will
  743. * allocate and and attach security information to
  744. * sock->inode->i_security. This hook may be used to update the
  745. * sock->inode->i_security field with additional information that wasn't
  746. * available when the inode was allocated.
  747. * @sock contains the newly created socket structure.
  748. * @family contains the requested protocol family.
  749. * @type contains the requested communications type.
  750. * @protocol contains the requested protocol.
  751. * @kern set to 1 if a kernel socket.
  752. * @socket_bind:
  753. * Check permission before socket protocol layer bind operation is
  754. * performed and the socket @sock is bound to the address specified in the
  755. * @address parameter.
  756. * @sock contains the socket structure.
  757. * @address contains the address to bind to.
  758. * @addrlen contains the length of address.
  759. * Return 0 if permission is granted.
  760. * @socket_connect:
  761. * Check permission before socket protocol layer connect operation
  762. * attempts to connect socket @sock to a remote address, @address.
  763. * @sock contains the socket structure.
  764. * @address contains the address of remote endpoint.
  765. * @addrlen contains the length of address.
  766. * Return 0 if permission is granted.
  767. * @socket_listen:
  768. * Check permission before socket protocol layer listen operation.
  769. * @sock contains the socket structure.
  770. * @backlog contains the maximum length for the pending connection queue.
  771. * Return 0 if permission is granted.
  772. * @socket_accept:
  773. * Check permission before accepting a new connection. Note that the new
  774. * socket, @newsock, has been created and some information copied to it,
  775. * but the accept operation has not actually been performed.
  776. * @sock contains the listening socket structure.
  777. * @newsock contains the newly created server socket for connection.
  778. * Return 0 if permission is granted.
  779. * @socket_sendmsg:
  780. * Check permission before transmitting a message to another socket.
  781. * @sock contains the socket structure.
  782. * @msg contains the message to be transmitted.
  783. * @size contains the size of message.
  784. * Return 0 if permission is granted.
  785. * @socket_recvmsg:
  786. * Check permission before receiving a message from a socket.
  787. * @sock contains the socket structure.
  788. * @msg contains the message structure.
  789. * @size contains the size of message structure.
  790. * @flags contains the operational flags.
  791. * Return 0 if permission is granted.
  792. * @socket_getsockname:
  793. * Check permission before the local address (name) of the socket object
  794. * @sock is retrieved.
  795. * @sock contains the socket structure.
  796. * Return 0 if permission is granted.
  797. * @socket_getpeername:
  798. * Check permission before the remote address (name) of a socket object
  799. * @sock is retrieved.
  800. * @sock contains the socket structure.
  801. * Return 0 if permission is granted.
  802. * @socket_getsockopt:
  803. * Check permissions before retrieving the options associated with socket
  804. * @sock.
  805. * @sock contains the socket structure.
  806. * @level contains the protocol level to retrieve option from.
  807. * @optname contains the name of option to retrieve.
  808. * Return 0 if permission is granted.
  809. * @socket_setsockopt:
  810. * Check permissions before setting the options associated with socket
  811. * @sock.
  812. * @sock contains the socket structure.
  813. * @level contains the protocol level to set options for.
  814. * @optname contains the name of the option to set.
  815. * Return 0 if permission is granted.
  816. * @socket_shutdown:
  817. * Checks permission before all or part of a connection on the socket
  818. * @sock is shut down.
  819. * @sock contains the socket structure.
  820. * @how contains the flag indicating how future sends and receives
  821. * are handled.
  822. * Return 0 if permission is granted.
  823. * @socket_sock_rcv_skb:
  824. * Check permissions on incoming network packets. This hook is distinct
  825. * from Netfilter's IP input hooks since it is the first time that the
  826. * incoming sk_buff @skb has been associated with a particular socket, @sk.
  827. * Must not sleep inside this hook because some callers hold spinlocks.
  828. * @sk contains the sock (not socket) associated with the incoming sk_buff.
  829. * @skb contains the incoming network data.
  830. * @socket_getpeersec_stream:
  831. * This hook allows the security module to provide peer socket security
  832. * state for unix or connected tcp sockets to userspace via getsockopt
  833. * SO_GETPEERSEC. For tcp sockets this can be meaningful if the
  834. * socket is associated with an ipsec SA.
  835. * @sock is the local socket.
  836. * @optval userspace memory where the security state is to be copied.
  837. * @optlen userspace int where the module should copy the actual length
  838. * of the security state.
  839. * @len as input is the maximum length to copy to userspace provided
  840. * by the caller.
  841. * Return 0 if all is well, otherwise, typical getsockopt return
  842. * values.
  843. * @socket_getpeersec_dgram:
  844. * This hook allows the security module to provide peer socket security
  845. * state for udp sockets on a per-packet basis to userspace via
  846. * getsockopt SO_GETPEERSEC. The application must first have indicated
  847. * the IP_PASSSEC option via getsockopt. It can then retrieve the
  848. * security state returned by this hook for a packet via the SCM_SECURITY
  849. * ancillary message type.
  850. * @skb is the skbuff for the packet being queried
  851. * @secdata is a pointer to a buffer in which to copy the security data
  852. * @seclen is the maximum length for @secdata
  853. * Return 0 on success, error on failure.
  854. * @sk_alloc_security:
  855. * Allocate and attach a security structure to the sk->sk_security field,
  856. * which is used to copy security attributes between local stream sockets.
  857. * @sk_free_security:
  858. * Deallocate security structure.
  859. * @sk_clone_security:
  860. * Clone/copy security structure.
  861. * @sk_getsecid:
  862. * Retrieve the LSM-specific secid for the sock to enable caching
  863. * of network authorizations.
  864. * @sock_graft:
  865. * Sets the socket's isec sid to the sock's sid.
  866. * @inet_conn_request:
  867. * Sets the openreq's sid to socket's sid with MLS portion taken
  868. * from peer sid.
  869. * @inet_csk_clone:
  870. * Sets the new child socket's sid to the openreq sid.
  871. * @inet_conn_established:
  872. * Sets the connection's peersid to the secmark on skb.
  873. * @secmark_relabel_packet:
  874. * check if the process should be allowed to relabel packets to
  875. * the given secid
  876. * @security_secmark_refcount_inc
  877. * tells the LSM to increment the number of secmark labeling rules loaded
  878. * @security_secmark_refcount_dec
  879. * tells the LSM to decrement the number of secmark labeling rules loaded
  880. * @req_classify_flow:
  881. * Sets the flow's sid to the openreq sid.
  882. * @tun_dev_alloc_security:
  883. * This hook allows a module to allocate a security structure for a TUN
  884. * device.
  885. * @security pointer to a security structure pointer.
  886. * Returns a zero on success, negative values on failure.
  887. * @tun_dev_free_security:
  888. * This hook allows a module to free the security structure for a TUN
  889. * device.
  890. * @security pointer to the TUN device's security structure
  891. * @tun_dev_create:
  892. * Check permissions prior to creating a new TUN device.
  893. * @tun_dev_attach_queue:
  894. * Check permissions prior to attaching to a TUN device queue.
  895. * @security pointer to the TUN device's security structure.
  896. * @tun_dev_attach:
  897. * This hook can be used by the module to update any security state
  898. * associated with the TUN device's sock structure.
  899. * @sk contains the existing sock structure.
  900. * @security pointer to the TUN device's security structure.
  901. * @tun_dev_open:
  902. * This hook can be used by the module to update any security state
  903. * associated with the TUN device's security structure.
  904. * @security pointer to the TUN devices's security structure.
  905. *
  906. * Security hooks for SCTP
  907. *
  908. * @sctp_assoc_request:
  909. * Passes the @ep and @chunk->skb of the association INIT packet to
  910. * the security module.
  911. * @ep pointer to sctp endpoint structure.
  912. * @skb pointer to skbuff of association packet.
  913. * Return 0 on success, error on failure.
  914. * @sctp_bind_connect:
  915. * Validiate permissions required for each address associated with sock
  916. * @sk. Depending on @optname, the addresses will be treated as either
  917. * for a connect or bind service. The @addrlen is calculated on each
  918. * ipv4 and ipv6 address using sizeof(struct sockaddr_in) or
  919. * sizeof(struct sockaddr_in6).
  920. * @sk pointer to sock structure.
  921. * @optname name of the option to validate.
  922. * @address list containing one or more ipv4/ipv6 addresses.
  923. * @addrlen total length of address(s).
  924. * Return 0 on success, error on failure.
  925. * @sctp_sk_clone:
  926. * Called whenever a new socket is created by accept(2) (i.e. a TCP
  927. * style socket) or when a socket is 'peeled off' e.g userspace
  928. * calls sctp_peeloff(3).
  929. * @ep pointer to current sctp endpoint structure.
  930. * @sk pointer to current sock structure.
  931. * @sk pointer to new sock structure.
  932. *
  933. * Security hooks for Infiniband
  934. *
  935. * @ib_pkey_access:
  936. * Check permission to access a pkey when modifing a QP.
  937. * @subnet_prefix the subnet prefix of the port being used.
  938. * @pkey the pkey to be accessed.
  939. * @sec pointer to a security structure.
  940. * @ib_endport_manage_subnet:
  941. * Check permissions to send and receive SMPs on a end port.
  942. * @dev_name the IB device name (i.e. mlx4_0).
  943. * @port_num the port number.
  944. * @sec pointer to a security structure.
  945. * @ib_alloc_security:
  946. * Allocate a security structure for Infiniband objects.
  947. * @sec pointer to a security structure pointer.
  948. * Returns 0 on success, non-zero on failure
  949. * @ib_free_security:
  950. * Deallocate an Infiniband security structure.
  951. * @sec contains the security structure to be freed.
  952. *
  953. * Security hooks for XFRM operations.
  954. *
  955. * @xfrm_policy_alloc_security:
  956. * @ctxp is a pointer to the xfrm_sec_ctx being added to Security Policy
  957. * Database used by the XFRM system.
  958. * @sec_ctx contains the security context information being provided by
  959. * the user-level policy update program (e.g., setkey).
  960. * Allocate a security structure to the xp->security field; the security
  961. * field is initialized to NULL when the xfrm_policy is allocated.
  962. * Return 0 if operation was successful (memory to allocate, legal context)
  963. * @gfp is to specify the context for the allocation
  964. * @xfrm_policy_clone_security:
  965. * @old_ctx contains an existing xfrm_sec_ctx.
  966. * @new_ctxp contains a new xfrm_sec_ctx being cloned from old.
  967. * Allocate a security structure in new_ctxp that contains the
  968. * information from the old_ctx structure.
  969. * Return 0 if operation was successful (memory to allocate).
  970. * @xfrm_policy_free_security:
  971. * @ctx contains the xfrm_sec_ctx
  972. * Deallocate xp->security.
  973. * @xfrm_policy_delete_security:
  974. * @ctx contains the xfrm_sec_ctx.
  975. * Authorize deletion of xp->security.
  976. * @xfrm_state_alloc:
  977. * @x contains the xfrm_state being added to the Security Association
  978. * Database by the XFRM system.
  979. * @sec_ctx contains the security context information being provided by
  980. * the user-level SA generation program (e.g., setkey or racoon).
  981. * Allocate a security structure to the x->security field; the security
  982. * field is initialized to NULL when the xfrm_state is allocated. Set the
  983. * context to correspond to sec_ctx. Return 0 if operation was successful
  984. * (memory to allocate, legal context).
  985. * @xfrm_state_alloc_acquire:
  986. * @x contains the xfrm_state being added to the Security Association
  987. * Database by the XFRM system.
  988. * @polsec contains the policy's security context.
  989. * @secid contains the secid from which to take the mls portion of the
  990. * context.
  991. * Allocate a security structure to the x->security field; the security
  992. * field is initialized to NULL when the xfrm_state is allocated. Set the
  993. * context to correspond to secid. Return 0 if operation was successful
  994. * (memory to allocate, legal context).
  995. * @xfrm_state_free_security:
  996. * @x contains the xfrm_state.
  997. * Deallocate x->security.
  998. * @xfrm_state_delete_security:
  999. * @x contains the xfrm_state.
  1000. * Authorize deletion of x->security.
  1001. * @xfrm_policy_lookup:
  1002. * @ctx contains the xfrm_sec_ctx for which the access control is being
  1003. * checked.
  1004. * @fl_secid contains the flow security label that is used to authorize
  1005. * access to the policy xp.
  1006. * @dir contains the direction of the flow (input or output).
  1007. * Check permission when a flow selects a xfrm_policy for processing
  1008. * XFRMs on a packet. The hook is called when selecting either a
  1009. * per-socket policy or a generic xfrm policy.
  1010. * Return 0 if permission is granted, -ESRCH otherwise, or -errno
  1011. * on other errors.
  1012. * @xfrm_state_pol_flow_match:
  1013. * @x contains the state to match.
  1014. * @xp contains the policy to check for a match.
  1015. * @fl contains the flow to check for a match.
  1016. * Return 1 if there is a match.
  1017. * @xfrm_decode_session:
  1018. * @skb points to skb to decode.
  1019. * @secid points to the flow key secid to set.
  1020. * @ckall says if all xfrms used should be checked for same secid.
  1021. * Return 0 if ckall is zero or all xfrms used have the same secid.
  1022. *
  1023. * Security hooks affecting all Key Management operations
  1024. *
  1025. * @key_alloc:
  1026. * Permit allocation of a key and assign security data. Note that key does
  1027. * not have a serial number assigned at this point.
  1028. * @key points to the key.
  1029. * @flags is the allocation flags
  1030. * Return 0 if permission is granted, -ve error otherwise.
  1031. * @key_free:
  1032. * Notification of destruction; free security data.
  1033. * @key points to the key.
  1034. * No return value.
  1035. * @key_permission:
  1036. * See whether a specific operational right is granted to a process on a
  1037. * key.
  1038. * @key_ref refers to the key (key pointer + possession attribute bit).
  1039. * @cred points to the credentials to provide the context against which to
  1040. * evaluate the security data on the key.
  1041. * @perm describes the combination of permissions required of this key.
  1042. * Return 0 if permission is granted, -ve error otherwise.
  1043. * @key_getsecurity:
  1044. * Get a textual representation of the security context attached to a key
  1045. * for the purposes of honouring KEYCTL_GETSECURITY. This function
  1046. * allocates the storage for the NUL-terminated string and the caller
  1047. * should free it.
  1048. * @key points to the key to be queried.
  1049. * @_buffer points to a pointer that should be set to point to the
  1050. * resulting string (if no label or an error occurs).
  1051. * Return the length of the string (including terminating NUL) or -ve if
  1052. * an error.
  1053. * May also return 0 (and a NULL buffer pointer) if there is no label.
  1054. *
  1055. * Security hooks affecting all System V IPC operations.
  1056. *
  1057. * @ipc_permission:
  1058. * Check permissions for access to IPC
  1059. * @ipcp contains the kernel IPC permission structure
  1060. * @flag contains the desired (requested) permission set
  1061. * Return 0 if permission is granted.
  1062. * @ipc_getsecid:
  1063. * Get the secid associated with the ipc object.
  1064. * @ipcp contains the kernel IPC permission structure.
  1065. * @secid contains a pointer to the location where result will be saved.
  1066. * In case of failure, @secid will be set to zero.
  1067. *
  1068. * Security hooks for individual messages held in System V IPC message queues
  1069. * @msg_msg_alloc_security:
  1070. * Allocate and attach a security structure to the msg->security field.
  1071. * The security field is initialized to NULL when the structure is first
  1072. * created.
  1073. * @msg contains the message structure to be modified.
  1074. * Return 0 if operation was successful and permission is granted.
  1075. * @msg_msg_free_security:
  1076. * Deallocate the security structure for this message.
  1077. * @msg contains the message structure to be modified.
  1078. *
  1079. * Security hooks for System V IPC Message Queues
  1080. *
  1081. * @msg_queue_alloc_security:
  1082. * Allocate and attach a security structure to the
  1083. * msq->q_perm.security field. The security field is initialized to
  1084. * NULL when the structure is first created.
  1085. * @msq contains the message queue structure to be modified.
  1086. * Return 0 if operation was successful and permission is granted.
  1087. * @msg_queue_free_security:
  1088. * Deallocate security structure for this message queue.
  1089. * @msq contains the message queue structure to be modified.
  1090. * @msg_queue_associate:
  1091. * Check permission when a message queue is requested through the
  1092. * msgget system call. This hook is only called when returning the
  1093. * message queue identifier for an existing message queue, not when a
  1094. * new message queue is created.
  1095. * @msq contains the message queue to act upon.
  1096. * @msqflg contains the operation control flags.
  1097. * Return 0 if permission is granted.
  1098. * @msg_queue_msgctl:
  1099. * Check permission when a message control operation specified by @cmd
  1100. * is to be performed on the message queue @msq.
  1101. * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
  1102. * @msq contains the message queue to act upon. May be NULL.
  1103. * @cmd contains the operation to be performed.
  1104. * Return 0 if permission is granted.
  1105. * @msg_queue_msgsnd:
  1106. * Check permission before a message, @msg, is enqueued on the message
  1107. * queue, @msq.
  1108. * @msq contains the message queue to send message to.
  1109. * @msg contains the message to be enqueued.
  1110. * @msqflg contains operational flags.
  1111. * Return 0 if permission is granted.
  1112. * @msg_queue_msgrcv:
  1113. * Check permission before a message, @msg, is removed from the message
  1114. * queue, @msq. The @target task structure contains a pointer to the
  1115. * process that will be receiving the message (not equal to the current
  1116. * process when inline receives are being performed).
  1117. * @msq contains the message queue to retrieve message from.
  1118. * @msg contains the message destination.
  1119. * @target contains the task structure for recipient process.
  1120. * @type contains the type of message requested.
  1121. * @mode contains the operational flags.
  1122. * Return 0 if permission is granted.
  1123. *
  1124. * Security hooks for System V Shared Memory Segments
  1125. *
  1126. * @shm_alloc_security:
  1127. * Allocate and attach a security structure to the shp->shm_perm.security
  1128. * field. The security field is initialized to NULL when the structure is
  1129. * first created.
  1130. * @shp contains the shared memory structure to be modified.
  1131. * Return 0 if operation was successful and permission is granted.
  1132. * @shm_free_security:
  1133. * Deallocate the security struct for this memory segment.
  1134. * @shp contains the shared memory structure to be modified.
  1135. * @shm_associate:
  1136. * Check permission when a shared memory region is requested through the
  1137. * shmget system call. This hook is only called when returning the shared
  1138. * memory region identifier for an existing region, not when a new shared
  1139. * memory region is created.
  1140. * @shp contains the shared memory structure to be modified.
  1141. * @shmflg contains the operation control flags.
  1142. * Return 0 if permission is granted.
  1143. * @shm_shmctl:
  1144. * Check permission when a shared memory control operation specified by
  1145. * @cmd is to be performed on the shared memory region @shp.
  1146. * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
  1147. * @shp contains shared memory structure to be modified.
  1148. * @cmd contains the operation to be performed.
  1149. * Return 0 if permission is granted.
  1150. * @shm_shmat:
  1151. * Check permissions prior to allowing the shmat system call to attach the
  1152. * shared memory segment @shp to the data segment of the calling process.
  1153. * The attaching address is specified by @shmaddr.
  1154. * @shp contains the shared memory structure to be modified.
  1155. * @shmaddr contains the address to attach memory region to.
  1156. * @shmflg contains the operational flags.
  1157. * Return 0 if permission is granted.
  1158. *
  1159. * Security hooks for System V Semaphores
  1160. *
  1161. * @sem_alloc_security:
  1162. * Allocate and attach a security structure to the sma->sem_perm.security
  1163. * field. The security field is initialized to NULL when the structure is
  1164. * first created.
  1165. * @sma contains the semaphore structure
  1166. * Return 0 if operation was successful and permission is granted.
  1167. * @sem_free_security:
  1168. * deallocate security struct for this semaphore
  1169. * @sma contains the semaphore structure.
  1170. * @sem_associate:
  1171. * Check permission when a semaphore is requested through the semget
  1172. * system call. This hook is only called when returning the semaphore
  1173. * identifier for an existing semaphore, not when a new one must be
  1174. * created.
  1175. * @sma contains the semaphore structure.
  1176. * @semflg contains the operation control flags.
  1177. * Return 0 if permission is granted.
  1178. * @sem_semctl:
  1179. * Check permission when a semaphore operation specified by @cmd is to be
  1180. * performed on the semaphore @sma. The @sma may be NULL, e.g. for
  1181. * IPC_INFO or SEM_INFO.
  1182. * @sma contains the semaphore structure. May be NULL.
  1183. * @cmd contains the operation to be performed.
  1184. * Return 0 if permission is granted.
  1185. * @sem_semop:
  1186. * Check permissions before performing operations on members of the
  1187. * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
  1188. * may be modified.
  1189. * @sma contains the semaphore structure.
  1190. * @sops contains the operations to perform.
  1191. * @nsops contains the number of operations to perform.
  1192. * @alter contains the flag indicating whether changes are to be made.
  1193. * Return 0 if permission is granted.
  1194. *
  1195. * @binder_set_context_mgr:
  1196. * Check whether @mgr is allowed to be the binder context manager.
  1197. * @mgr contains the task_struct for the task being registered.
  1198. * Return 0 if permission is granted.
  1199. * @binder_transaction:
  1200. * Check whether @from is allowed to invoke a binder transaction call
  1201. * to @to.
  1202. * @from contains the task_struct for the sending task.
  1203. * @to contains the task_struct for the receiving task.
  1204. * @binder_transfer_binder:
  1205. * Check whether @from is allowed to transfer a binder reference to @to.
  1206. * @from contains the task_struct for the sending task.
  1207. * @to contains the task_struct for the receiving task.
  1208. * @binder_transfer_file:
  1209. * Check whether @from is allowed to transfer @file to @to.
  1210. * @from contains the task_struct for the sending task.
  1211. * @file contains the struct file being transferred.
  1212. * @to contains the task_struct for the receiving task.
  1213. *
  1214. * @ptrace_access_check:
  1215. * Check permission before allowing the current process to trace the
  1216. * @child process.
  1217. * Security modules may also want to perform a process tracing check
  1218. * during an execve in the set_security or apply_creds hooks of
  1219. * tracing check during an execve in the bprm_set_creds hook of
  1220. * binprm_security_ops if the process is being traced and its security
  1221. * attributes would be changed by the execve.
  1222. * @child contains the task_struct structure for the target process.
  1223. * @mode contains the PTRACE_MODE flags indicating the form of access.
  1224. * Return 0 if permission is granted.
  1225. * @ptrace_traceme:
  1226. * Check that the @parent process has sufficient permission to trace the
  1227. * current process before allowing the current process to present itself
  1228. * to the @parent process for tracing.
  1229. * @parent contains the task_struct structure for debugger process.
  1230. * Return 0 if permission is granted.
  1231. * @capget:
  1232. * Get the @effective, @inheritable, and @permitted capability sets for
  1233. * the @target process. The hook may also perform permission checking to
  1234. * determine if the current process is allowed to see the capability sets
  1235. * of the @target process.
  1236. * @target contains the task_struct structure for target process.
  1237. * @effective contains the effective capability set.
  1238. * @inheritable contains the inheritable capability set.
  1239. * @permitted contains the permitted capability set.
  1240. * Return 0 if the capability sets were successfully obtained.
  1241. * @capset:
  1242. * Set the @effective, @inheritable, and @permitted capability sets for
  1243. * the current process.
  1244. * @new contains the new credentials structure for target process.
  1245. * @old contains the current credentials structure for target process.
  1246. * @effective contains the effective capability set.
  1247. * @inheritable contains the inheritable capability set.
  1248. * @permitted contains the permitted capability set.
  1249. * Return 0 and update @new if permission is granted.
  1250. * @capable:
  1251. * Check whether the @tsk process has the @cap capability in the indicated
  1252. * credentials.
  1253. * @cred contains the credentials to use.
  1254. * @ns contains the user namespace we want the capability in
  1255. * @cap contains the capability <include/linux/capability.h>.
  1256. * @audit contains whether to write an audit message or not
  1257. * Return 0 if the capability is granted for @tsk.
  1258. * @syslog:
  1259. * Check permission before accessing the kernel message ring or changing
  1260. * logging to the console.
  1261. * See the syslog(2) manual page for an explanation of the @type values.
  1262. * @type contains the type of action.
  1263. * @from_file indicates the context of action (if it came from /proc).
  1264. * Return 0 if permission is granted.
  1265. * @settime:
  1266. * Check permission to change the system time.
  1267. * struct timespec64 is defined in include/linux/time64.h and timezone
  1268. * is defined in include/linux/time.h
  1269. * @ts contains new time
  1270. * @tz contains new timezone
  1271. * Return 0 if permission is granted.
  1272. * @vm_enough_memory:
  1273. * Check permissions for allocating a new virtual mapping.
  1274. * @mm contains the mm struct it is being added to.
  1275. * @pages contains the number of pages.
  1276. * Return 0 if permission is granted.
  1277. *
  1278. * @ismaclabel:
  1279. * Check if the extended attribute specified by @name
  1280. * represents a MAC label. Returns 1 if name is a MAC
  1281. * attribute otherwise returns 0.
  1282. * @name full extended attribute name to check against
  1283. * LSM as a MAC label.
  1284. *
  1285. * @secid_to_secctx:
  1286. * Convert secid to security context. If secdata is NULL the length of
  1287. * the result will be returned in seclen, but no secdata will be returned.
  1288. * This does mean that the length could change between calls to check the
  1289. * length and the next call which actually allocates and returns the
  1290. * secdata.
  1291. * @secid contains the security ID.
  1292. * @secdata contains the pointer that stores the converted security
  1293. * context.
  1294. * @seclen pointer which contains the length of the data
  1295. * @secctx_to_secid:
  1296. * Convert security context to secid.
  1297. * @secid contains the pointer to the generated security ID.
  1298. * @secdata contains the security context.
  1299. *
  1300. * @release_secctx:
  1301. * Release the security context.
  1302. * @secdata contains the security context.
  1303. * @seclen contains the length of the security context.
  1304. *
  1305. * Security hooks for Audit
  1306. *
  1307. * @audit_rule_init:
  1308. * Allocate and initialize an LSM audit rule structure.
  1309. * @field contains the required Audit action.
  1310. * Fields flags are defined in include/linux/audit.h
  1311. * @op contains the operator the rule uses.
  1312. * @rulestr contains the context where the rule will be applied to.
  1313. * @lsmrule contains a pointer to receive the result.
  1314. * Return 0 if @lsmrule has been successfully set,
  1315. * -EINVAL in case of an invalid rule.
  1316. *
  1317. * @audit_rule_known:
  1318. * Specifies whether given @rule contains any fields related to
  1319. * current LSM.
  1320. * @rule contains the audit rule of interest.
  1321. * Return 1 in case of relation found, 0 otherwise.
  1322. *
  1323. * @audit_rule_match:
  1324. * Determine if given @secid matches a rule previously approved
  1325. * by @audit_rule_known.
  1326. * @secid contains the security id in question.
  1327. * @field contains the field which relates to current LSM.
  1328. * @op contains the operator that will be used for matching.
  1329. * @rule points to the audit rule that will be checked against.
  1330. * @actx points to the audit context associated with the check.
  1331. * Return 1 if secid matches the rule, 0 if it does not, -ERRNO on failure.
  1332. *
  1333. * @audit_rule_free:
  1334. * Deallocate the LSM audit rule structure previously allocated by
  1335. * audit_rule_init.
  1336. * @rule contains the allocated rule
  1337. *
  1338. * @inode_invalidate_secctx:
  1339. * Notify the security module that it must revalidate the security context
  1340. * of an inode.
  1341. *
  1342. * @inode_notifysecctx:
  1343. * Notify the security module of what the security context of an inode
  1344. * should be. Initializes the incore security context managed by the
  1345. * security module for this inode. Example usage: NFS client invokes
  1346. * this hook to initialize the security context in its incore inode to the
  1347. * value provided by the server for the file when the server returned the
  1348. * file's attributes to the client.
  1349. *
  1350. * Must be called with inode->i_mutex locked.
  1351. *
  1352. * @inode we wish to set the security context of.
  1353. * @ctx contains the string which we wish to set in the inode.
  1354. * @ctxlen contains the length of @ctx.
  1355. *
  1356. * @inode_setsecctx:
  1357. * Change the security context of an inode. Updates the
  1358. * incore security context managed by the security module and invokes the
  1359. * fs code as needed (via __vfs_setxattr_noperm) to update any backing
  1360. * xattrs that represent the context. Example usage: NFS server invokes
  1361. * this hook to change the security context in its incore inode and on the
  1362. * backing filesystem to a value provided by the client on a SETATTR
  1363. * operation.
  1364. *
  1365. * Must be called with inode->i_mutex locked.
  1366. *
  1367. * @dentry contains the inode we wish to set the security context of.
  1368. * @ctx contains the string which we wish to set in the inode.
  1369. * @ctxlen contains the length of @ctx.
  1370. *
  1371. * @inode_getsecctx:
  1372. * On success, returns 0 and fills out @ctx and @ctxlen with the security
  1373. * context for the given @inode.
  1374. *
  1375. * @inode we wish to get the security context of.
  1376. * @ctx is a pointer in which to place the allocated security context.
  1377. * @ctxlen points to the place to put the length of @ctx.
  1378. *
  1379. * Security hooks for using the eBPF maps and programs functionalities through
  1380. * eBPF syscalls.
  1381. *
  1382. * @bpf:
  1383. * Do a initial check for all bpf syscalls after the attribute is copied
  1384. * into the kernel. The actual security module can implement their own
  1385. * rules to check the specific cmd they need.
  1386. *
  1387. * @bpf_map:
  1388. * Do a check when the kernel generate and return a file descriptor for
  1389. * eBPF maps.
  1390. *
  1391. * @map: bpf map that we want to access
  1392. * @mask: the access flags
  1393. *
  1394. * @bpf_prog:
  1395. * Do a check when the kernel generate and return a file descriptor for
  1396. * eBPF programs.
  1397. *
  1398. * @prog: bpf prog that userspace want to use.
  1399. *
  1400. * @bpf_map_alloc_security:
  1401. * Initialize the security field inside bpf map.
  1402. *
  1403. * @bpf_map_free_security:
  1404. * Clean up the security information stored inside bpf map.
  1405. *
  1406. * @bpf_prog_alloc_security:
  1407. * Initialize the security field inside bpf program.
  1408. *
  1409. * @bpf_prog_free_security:
  1410. * Clean up the security information stored inside bpf prog.
  1411. *
  1412. */
  1413. union security_list_options {
  1414. int (*binder_set_context_mgr)(struct task_struct *mgr);
  1415. int (*binder_transaction)(struct task_struct *from,
  1416. struct task_struct *to);
  1417. int (*binder_transfer_binder)(struct task_struct *from,
  1418. struct task_struct *to);
  1419. int (*binder_transfer_file)(struct task_struct *from,
  1420. struct task_struct *to,
  1421. struct file *file);
  1422. int (*ptrace_access_check)(struct task_struct *child,
  1423. unsigned int mode);
  1424. int (*ptrace_traceme)(struct task_struct *parent);
  1425. int (*capget)(struct task_struct *target, kernel_cap_t *effective,
  1426. kernel_cap_t *inheritable, kernel_cap_t *permitted);
  1427. int (*capset)(struct cred *new, const struct cred *old,
  1428. const kernel_cap_t *effective,
  1429. const kernel_cap_t *inheritable,
  1430. const kernel_cap_t *permitted);
  1431. int (*capable)(const struct cred *cred, struct user_namespace *ns,
  1432. int cap, int audit);
  1433. int (*quotactl)(int cmds, int type, int id, struct super_block *sb);
  1434. int (*quota_on)(struct dentry *dentry);
  1435. int (*syslog)(int type);
  1436. int (*settime)(const struct timespec64 *ts, const struct timezone *tz);
  1437. int (*vm_enough_memory)(struct mm_struct *mm, long pages);
  1438. int (*bprm_set_creds)(struct linux_binprm *bprm);
  1439. int (*bprm_check_security)(struct linux_binprm *bprm);
  1440. void (*bprm_committing_creds)(struct linux_binprm *bprm);
  1441. void (*bprm_committed_creds)(struct linux_binprm *bprm);
  1442. int (*sb_alloc_security)(struct super_block *sb);
  1443. void (*sb_free_security)(struct super_block *sb);
  1444. int (*sb_copy_data)(char *orig, char *copy);
  1445. int (*sb_remount)(struct super_block *sb, void *data);
  1446. int (*sb_kern_mount)(struct super_block *sb, int flags, void *data);
  1447. int (*sb_show_options)(struct seq_file *m, struct super_block *sb);
  1448. int (*sb_statfs)(struct dentry *dentry);
  1449. int (*sb_mount)(const char *dev_name, const struct path *path,
  1450. const char *type, unsigned long flags, void *data);
  1451. int (*sb_umount)(struct vfsmount *mnt, int flags);
  1452. int (*sb_pivotroot)(const struct path *old_path, const struct path *new_path);
  1453. int (*sb_set_mnt_opts)(struct super_block *sb,
  1454. struct security_mnt_opts *opts,
  1455. unsigned long kern_flags,
  1456. unsigned long *set_kern_flags);
  1457. int (*sb_clone_mnt_opts)(const struct super_block *oldsb,
  1458. struct super_block *newsb,
  1459. unsigned long kern_flags,
  1460. unsigned long *set_kern_flags);
  1461. int (*sb_parse_opts_str)(char *options, struct security_mnt_opts *opts);
  1462. int (*dentry_init_security)(struct dentry *dentry, int mode,
  1463. const struct qstr *name, void **ctx,
  1464. u32 *ctxlen);
  1465. int (*dentry_create_files_as)(struct dentry *dentry, int mode,
  1466. struct qstr *name,
  1467. const struct cred *old,
  1468. struct cred *new);
  1469. #ifdef CONFIG_SECURITY_PATH
  1470. int (*path_unlink)(const struct path *dir, struct dentry *dentry);
  1471. int (*path_mkdir)(const struct path *dir, struct dentry *dentry,
  1472. umode_t mode);
  1473. int (*path_rmdir)(const struct path *dir, struct dentry *dentry);
  1474. int (*path_mknod)(const struct path *dir, struct dentry *dentry,
  1475. umode_t mode, unsigned int dev);
  1476. int (*path_truncate)(const struct path *path);
  1477. int (*path_symlink)(const struct path *dir, struct dentry *dentry,
  1478. const char *old_name);
  1479. int (*path_link)(struct dentry *old_dentry, const struct path *new_dir,
  1480. struct dentry *new_dentry);
  1481. int (*path_rename)(const struct path *old_dir, struct dentry *old_dentry,
  1482. const struct path *new_dir,
  1483. struct dentry *new_dentry);
  1484. int (*path_chmod)(const struct path *path, umode_t mode);
  1485. int (*path_chown)(const struct path *path, kuid_t uid, kgid_t gid);
  1486. int (*path_chroot)(const struct path *path);
  1487. #endif
  1488. int (*inode_alloc_security)(struct inode *inode);
  1489. void (*inode_free_security)(struct inode *inode);
  1490. int (*inode_init_security)(struct inode *inode, struct inode *dir,
  1491. const struct qstr *qstr,
  1492. const char **name, void **value,
  1493. size_t *len);
  1494. int (*inode_create)(struct inode *dir, struct dentry *dentry,
  1495. umode_t mode);
  1496. int (*inode_link)(struct dentry *old_dentry, struct inode *dir,
  1497. struct dentry *new_dentry);
  1498. int (*inode_unlink)(struct inode *dir, struct dentry *dentry);
  1499. int (*inode_symlink)(struct inode *dir, struct dentry *dentry,
  1500. const char *old_name);
  1501. int (*inode_mkdir)(struct inode *dir, struct dentry *dentry,
  1502. umode_t mode);
  1503. int (*inode_rmdir)(struct inode *dir, struct dentry *dentry);
  1504. int (*inode_mknod)(struct inode *dir, struct dentry *dentry,
  1505. umode_t mode, dev_t dev);
  1506. int (*inode_rename)(struct inode *old_dir, struct dentry *old_dentry,
  1507. struct inode *new_dir,
  1508. struct dentry *new_dentry);
  1509. int (*inode_readlink)(struct dentry *dentry);
  1510. int (*inode_follow_link)(struct dentry *dentry, struct inode *inode,
  1511. bool rcu);
  1512. int (*inode_permission)(struct inode *inode, int mask);
  1513. int (*inode_setattr)(struct dentry *dentry, struct iattr *attr);
  1514. int (*inode_getattr)(const struct path *path);
  1515. int (*inode_setxattr)(struct dentry *dentry, const char *name,
  1516. const void *value, size_t size, int flags);
  1517. void (*inode_post_setxattr)(struct dentry *dentry, const char *name,
  1518. const void *value, size_t size,
  1519. int flags);
  1520. int (*inode_getxattr)(struct dentry *dentry, const char *name);
  1521. int (*inode_listxattr)(struct dentry *dentry);
  1522. int (*inode_removexattr)(struct dentry *dentry, const char *name);
  1523. int (*inode_need_killpriv)(struct dentry *dentry);
  1524. int (*inode_killpriv)(struct dentry *dentry);
  1525. int (*inode_getsecurity)(struct inode *inode, const char *name,
  1526. void **buffer, bool alloc);
  1527. int (*inode_setsecurity)(struct inode *inode, const char *name,
  1528. const void *value, size_t size,
  1529. int flags);
  1530. int (*inode_listsecurity)(struct inode *inode, char *buffer,
  1531. size_t buffer_size);
  1532. void (*inode_getsecid)(struct inode *inode, u32 *secid);
  1533. int (*inode_copy_up)(struct dentry *src, struct cred **new);
  1534. int (*inode_copy_up_xattr)(const char *name);
  1535. int (*file_permission)(struct file *file, int mask);
  1536. int (*file_alloc_security)(struct file *file);
  1537. void (*file_free_security)(struct file *file);
  1538. int (*file_ioctl)(struct file *file, unsigned int cmd,
  1539. unsigned long arg);
  1540. int (*mmap_addr)(unsigned long addr);
  1541. int (*mmap_file)(struct file *file, unsigned long reqprot,
  1542. unsigned long prot, unsigned long flags);
  1543. int (*file_mprotect)(struct vm_area_struct *vma, unsigned long reqprot,
  1544. unsigned long prot);
  1545. int (*file_lock)(struct file *file, unsigned int cmd);
  1546. int (*file_fcntl)(struct file *file, unsigned int cmd,
  1547. unsigned long arg);
  1548. void (*file_set_fowner)(struct file *file);
  1549. int (*file_send_sigiotask)(struct task_struct *tsk,
  1550. struct fown_struct *fown, int sig);
  1551. int (*file_receive)(struct file *file);
  1552. int (*file_open)(struct file *file, const struct cred *cred);
  1553. int (*task_alloc)(struct task_struct *task, unsigned long clone_flags);
  1554. void (*task_free)(struct task_struct *task);
  1555. int (*cred_alloc_blank)(struct cred *cred, gfp_t gfp);
  1556. void (*cred_free)(struct cred *cred);
  1557. int (*cred_prepare)(struct cred *new, const struct cred *old,
  1558. gfp_t gfp);
  1559. void (*cred_transfer)(struct cred *new, const struct cred *old);
  1560. int (*kernel_act_as)(struct cred *new, u32 secid);
  1561. int (*kernel_create_files_as)(struct cred *new, struct inode *inode);
  1562. int (*kernel_module_request)(char *kmod_name);
  1563. int (*kernel_read_file)(struct file *file, enum kernel_read_file_id id);
  1564. int (*kernel_post_read_file)(struct file *file, char *buf, loff_t size,
  1565. enum kernel_read_file_id id);
  1566. int (*task_fix_setuid)(struct cred *new, const struct cred *old,
  1567. int flags);
  1568. int (*task_setpgid)(struct task_struct *p, pid_t pgid);
  1569. int (*task_getpgid)(struct task_struct *p);
  1570. int (*task_getsid)(struct task_struct *p);
  1571. void (*task_getsecid)(struct task_struct *p, u32 *secid);
  1572. int (*task_setnice)(struct task_struct *p, int nice);
  1573. int (*task_setioprio)(struct task_struct *p, int ioprio);
  1574. int (*task_getioprio)(struct task_struct *p);
  1575. int (*task_prlimit)(const struct cred *cred, const struct cred *tcred,
  1576. unsigned int flags);
  1577. int (*task_setrlimit)(struct task_struct *p, unsigned int resource,
  1578. struct rlimit *new_rlim);
  1579. int (*task_setscheduler)(struct task_struct *p);
  1580. int (*task_getscheduler)(struct task_struct *p);
  1581. int (*task_movememory)(struct task_struct *p);
  1582. int (*task_kill)(struct task_struct *p, struct siginfo *info,
  1583. int sig, u32 secid);
  1584. int (*task_prctl)(int option, unsigned long arg2, unsigned long arg3,
  1585. unsigned long arg4, unsigned long arg5);
  1586. void (*task_to_inode)(struct task_struct *p, struct inode *inode);
  1587. int (*ipc_permission)(struct kern_ipc_perm *ipcp, short flag);
  1588. void (*ipc_getsecid)(struct kern_ipc_perm *ipcp, u32 *secid);
  1589. int (*msg_msg_alloc_security)(struct msg_msg *msg);
  1590. void (*msg_msg_free_security)(struct msg_msg *msg);
  1591. int (*msg_queue_alloc_security)(struct kern_ipc_perm *msq);
  1592. void (*msg_queue_free_security)(struct kern_ipc_perm *msq);
  1593. int (*msg_queue_associate)(struct kern_ipc_perm *msq, int msqflg);
  1594. int (*msg_queue_msgctl)(struct kern_ipc_perm *msq, int cmd);
  1595. int (*msg_queue_msgsnd)(struct kern_ipc_perm *msq, struct msg_msg *msg,
  1596. int msqflg);
  1597. int (*msg_queue_msgrcv)(struct kern_ipc_perm *msq, struct msg_msg *msg,
  1598. struct task_struct *target, long type,
  1599. int mode);
  1600. int (*shm_alloc_security)(struct kern_ipc_perm *shp);
  1601. void (*shm_free_security)(struct kern_ipc_perm *shp);
  1602. int (*shm_associate)(struct kern_ipc_perm *shp, int shmflg);
  1603. int (*shm_shmctl)(struct kern_ipc_perm *shp, int cmd);
  1604. int (*shm_shmat)(struct kern_ipc_perm *shp, char __user *shmaddr,
  1605. int shmflg);
  1606. int (*sem_alloc_security)(struct kern_ipc_perm *sma);
  1607. void (*sem_free_security)(struct kern_ipc_perm *sma);
  1608. int (*sem_associate)(struct kern_ipc_perm *sma, int semflg);
  1609. int (*sem_semctl)(struct kern_ipc_perm *sma, int cmd);
  1610. int (*sem_semop)(struct kern_ipc_perm *sma, struct sembuf *sops,
  1611. unsigned nsops, int alter);
  1612. int (*netlink_send)(struct sock *sk, struct sk_buff *skb);
  1613. void (*d_instantiate)(struct dentry *dentry, struct inode *inode);
  1614. int (*getprocattr)(struct task_struct *p, char *name, char **value);
  1615. int (*setprocattr)(const char *name, void *value, size_t size);
  1616. int (*ismaclabel)(const char *name);
  1617. int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
  1618. int (*secctx_to_secid)(const char *secdata, u32 seclen, u32 *secid);
  1619. void (*release_secctx)(char *secdata, u32 seclen);
  1620. void (*inode_invalidate_secctx)(struct inode *inode);
  1621. int (*inode_notifysecctx)(struct inode *inode, void *ctx, u32 ctxlen);
  1622. int (*inode_setsecctx)(struct dentry *dentry, void *ctx, u32 ctxlen);
  1623. int (*inode_getsecctx)(struct inode *inode, void **ctx, u32 *ctxlen);
  1624. #ifdef CONFIG_SECURITY_NETWORK
  1625. int (*unix_stream_connect)(struct sock *sock, struct sock *other,
  1626. struct sock *newsk);
  1627. int (*unix_may_send)(struct socket *sock, struct socket *other);
  1628. int (*socket_create)(int family, int type, int protocol, int kern);
  1629. int (*socket_post_create)(struct socket *sock, int family, int type,
  1630. int protocol, int kern);
  1631. int (*socket_bind)(struct socket *sock, struct sockaddr *address,
  1632. int addrlen);
  1633. int (*socket_connect)(struct socket *sock, struct sockaddr *address,
  1634. int addrlen);
  1635. int (*socket_listen)(struct socket *sock, int backlog);
  1636. int (*socket_accept)(struct socket *sock, struct socket *newsock);
  1637. int (*socket_sendmsg)(struct socket *sock, struct msghdr *msg,
  1638. int size);
  1639. int (*socket_recvmsg)(struct socket *sock, struct msghdr *msg,
  1640. int size, int flags);
  1641. int (*socket_getsockname)(struct socket *sock);
  1642. int (*socket_getpeername)(struct socket *sock);
  1643. int (*socket_getsockopt)(struct socket *sock, int level, int optname);
  1644. int (*socket_setsockopt)(struct socket *sock, int level, int optname);
  1645. int (*socket_shutdown)(struct socket *sock, int how);
  1646. int (*socket_sock_rcv_skb)(struct sock *sk, struct sk_buff *skb);
  1647. int (*socket_getpeersec_stream)(struct socket *sock,
  1648. char __user *optval,
  1649. int __user *optlen, unsigned len);
  1650. int (*socket_getpeersec_dgram)(struct socket *sock,
  1651. struct sk_buff *skb, u32 *secid);
  1652. int (*sk_alloc_security)(struct sock *sk, int family, gfp_t priority);
  1653. void (*sk_free_security)(struct sock *sk);
  1654. void (*sk_clone_security)(const struct sock *sk, struct sock *newsk);
  1655. void (*sk_getsecid)(struct sock *sk, u32 *secid);
  1656. void (*sock_graft)(struct sock *sk, struct socket *parent);
  1657. int (*inet_conn_request)(struct sock *sk, struct sk_buff *skb,
  1658. struct request_sock *req);
  1659. void (*inet_csk_clone)(struct sock *newsk,
  1660. const struct request_sock *req);
  1661. void (*inet_conn_established)(struct sock *sk, struct sk_buff *skb);
  1662. int (*secmark_relabel_packet)(u32 secid);
  1663. void (*secmark_refcount_inc)(void);
  1664. void (*secmark_refcount_dec)(void);
  1665. void (*req_classify_flow)(const struct request_sock *req,
  1666. struct flowi *fl);
  1667. int (*tun_dev_alloc_security)(void **security);
  1668. void (*tun_dev_free_security)(void *security);
  1669. int (*tun_dev_create)(void);
  1670. int (*tun_dev_attach_queue)(void *security);
  1671. int (*tun_dev_attach)(struct sock *sk, void *security);
  1672. int (*tun_dev_open)(void *security);
  1673. int (*sctp_assoc_request)(struct sctp_endpoint *ep,
  1674. struct sk_buff *skb);
  1675. int (*sctp_bind_connect)(struct sock *sk, int optname,
  1676. struct sockaddr *address, int addrlen);
  1677. void (*sctp_sk_clone)(struct sctp_endpoint *ep, struct sock *sk,
  1678. struct sock *newsk);
  1679. #endif /* CONFIG_SECURITY_NETWORK */
  1680. #ifdef CONFIG_SECURITY_INFINIBAND
  1681. int (*ib_pkey_access)(void *sec, u64 subnet_prefix, u16 pkey);
  1682. int (*ib_endport_manage_subnet)(void *sec, const char *dev_name,
  1683. u8 port_num);
  1684. int (*ib_alloc_security)(void **sec);
  1685. void (*ib_free_security)(void *sec);
  1686. #endif /* CONFIG_SECURITY_INFINIBAND */
  1687. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  1688. int (*xfrm_policy_alloc_security)(struct xfrm_sec_ctx **ctxp,
  1689. struct xfrm_user_sec_ctx *sec_ctx,
  1690. gfp_t gfp);
  1691. int (*xfrm_policy_clone_security)(struct xfrm_sec_ctx *old_ctx,
  1692. struct xfrm_sec_ctx **new_ctx);
  1693. void (*xfrm_policy_free_security)(struct xfrm_sec_ctx *ctx);
  1694. int (*xfrm_policy_delete_security)(struct xfrm_sec_ctx *ctx);
  1695. int (*xfrm_state_alloc)(struct xfrm_state *x,
  1696. struct xfrm_user_sec_ctx *sec_ctx);
  1697. int (*xfrm_state_alloc_acquire)(struct xfrm_state *x,
  1698. struct xfrm_sec_ctx *polsec,
  1699. u32 secid);
  1700. void (*xfrm_state_free_security)(struct xfrm_state *x);
  1701. int (*xfrm_state_delete_security)(struct xfrm_state *x);
  1702. int (*xfrm_policy_lookup)(struct xfrm_sec_ctx *ctx, u32 fl_secid,
  1703. u8 dir);
  1704. int (*xfrm_state_pol_flow_match)(struct xfrm_state *x,
  1705. struct xfrm_policy *xp,
  1706. const struct flowi *fl);
  1707. int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall);
  1708. #endif /* CONFIG_SECURITY_NETWORK_XFRM */
  1709. /* key management security hooks */
  1710. #ifdef CONFIG_KEYS
  1711. int (*key_alloc)(struct key *key, const struct cred *cred,
  1712. unsigned long flags);
  1713. void (*key_free)(struct key *key);
  1714. int (*key_permission)(key_ref_t key_ref, const struct cred *cred,
  1715. unsigned perm);
  1716. int (*key_getsecurity)(struct key *key, char **_buffer);
  1717. #endif /* CONFIG_KEYS */
  1718. #ifdef CONFIG_AUDIT
  1719. int (*audit_rule_init)(u32 field, u32 op, char *rulestr,
  1720. void **lsmrule);
  1721. int (*audit_rule_known)(struct audit_krule *krule);
  1722. int (*audit_rule_match)(u32 secid, u32 field, u32 op, void *lsmrule,
  1723. struct audit_context *actx);
  1724. void (*audit_rule_free)(void *lsmrule);
  1725. #endif /* CONFIG_AUDIT */
  1726. #ifdef CONFIG_BPF_SYSCALL
  1727. int (*bpf)(int cmd, union bpf_attr *attr,
  1728. unsigned int size);
  1729. int (*bpf_map)(struct bpf_map *map, fmode_t fmode);
  1730. int (*bpf_prog)(struct bpf_prog *prog);
  1731. int (*bpf_map_alloc_security)(struct bpf_map *map);
  1732. void (*bpf_map_free_security)(struct bpf_map *map);
  1733. int (*bpf_prog_alloc_security)(struct bpf_prog_aux *aux);
  1734. void (*bpf_prog_free_security)(struct bpf_prog_aux *aux);
  1735. #endif /* CONFIG_BPF_SYSCALL */
  1736. };
  1737. struct security_hook_heads {
  1738. struct list_head binder_set_context_mgr;
  1739. struct list_head binder_transaction;
  1740. struct list_head binder_transfer_binder;
  1741. struct list_head binder_transfer_file;
  1742. struct list_head ptrace_access_check;
  1743. struct list_head ptrace_traceme;
  1744. struct list_head capget;
  1745. struct list_head capset;
  1746. struct list_head capable;
  1747. struct list_head quotactl;
  1748. struct list_head quota_on;
  1749. struct list_head syslog;
  1750. struct list_head settime;
  1751. struct list_head vm_enough_memory;
  1752. struct list_head bprm_set_creds;
  1753. struct list_head bprm_check_security;
  1754. struct list_head bprm_committing_creds;
  1755. struct list_head bprm_committed_creds;
  1756. struct list_head sb_alloc_security;
  1757. struct list_head sb_free_security;
  1758. struct list_head sb_copy_data;
  1759. struct list_head sb_remount;
  1760. struct list_head sb_kern_mount;
  1761. struct list_head sb_show_options;
  1762. struct list_head sb_statfs;
  1763. struct list_head sb_mount;
  1764. struct list_head sb_umount;
  1765. struct list_head sb_pivotroot;
  1766. struct list_head sb_set_mnt_opts;
  1767. struct list_head sb_clone_mnt_opts;
  1768. struct list_head sb_parse_opts_str;
  1769. struct list_head dentry_init_security;
  1770. struct list_head dentry_create_files_as;
  1771. #ifdef CONFIG_SECURITY_PATH
  1772. struct list_head path_unlink;
  1773. struct list_head path_mkdir;
  1774. struct list_head path_rmdir;
  1775. struct list_head path_mknod;
  1776. struct list_head path_truncate;
  1777. struct list_head path_symlink;
  1778. struct list_head path_link;
  1779. struct list_head path_rename;
  1780. struct list_head path_chmod;
  1781. struct list_head path_chown;
  1782. struct list_head path_chroot;
  1783. #endif
  1784. struct list_head inode_alloc_security;
  1785. struct list_head inode_free_security;
  1786. struct list_head inode_init_security;
  1787. struct list_head inode_create;
  1788. struct list_head inode_link;
  1789. struct list_head inode_unlink;
  1790. struct list_head inode_symlink;
  1791. struct list_head inode_mkdir;
  1792. struct list_head inode_rmdir;
  1793. struct list_head inode_mknod;
  1794. struct list_head inode_rename;
  1795. struct list_head inode_readlink;
  1796. struct list_head inode_follow_link;
  1797. struct list_head inode_permission;
  1798. struct list_head inode_setattr;
  1799. struct list_head inode_getattr;
  1800. struct list_head inode_setxattr;
  1801. struct list_head inode_post_setxattr;
  1802. struct list_head inode_getxattr;
  1803. struct list_head inode_listxattr;
  1804. struct list_head inode_removexattr;
  1805. struct list_head inode_need_killpriv;
  1806. struct list_head inode_killpriv;
  1807. struct list_head inode_getsecurity;
  1808. struct list_head inode_setsecurity;
  1809. struct list_head inode_listsecurity;
  1810. struct list_head inode_getsecid;
  1811. struct list_head inode_copy_up;
  1812. struct list_head inode_copy_up_xattr;
  1813. struct list_head file_permission;
  1814. struct list_head file_alloc_security;
  1815. struct list_head file_free_security;
  1816. struct list_head file_ioctl;
  1817. struct list_head mmap_addr;
  1818. struct list_head mmap_file;
  1819. struct list_head file_mprotect;
  1820. struct list_head file_lock;
  1821. struct list_head file_fcntl;
  1822. struct list_head file_set_fowner;
  1823. struct list_head file_send_sigiotask;
  1824. struct list_head file_receive;
  1825. struct list_head file_open;
  1826. struct list_head task_alloc;
  1827. struct list_head task_free;
  1828. struct list_head cred_alloc_blank;
  1829. struct list_head cred_free;
  1830. struct list_head cred_prepare;
  1831. struct list_head cred_transfer;
  1832. struct list_head kernel_act_as;
  1833. struct list_head kernel_create_files_as;
  1834. struct list_head kernel_read_file;
  1835. struct list_head kernel_post_read_file;
  1836. struct list_head kernel_module_request;
  1837. struct list_head task_fix_setuid;
  1838. struct list_head task_setpgid;
  1839. struct list_head task_getpgid;
  1840. struct list_head task_getsid;
  1841. struct list_head task_getsecid;
  1842. struct list_head task_setnice;
  1843. struct list_head task_setioprio;
  1844. struct list_head task_getioprio;
  1845. struct list_head task_prlimit;
  1846. struct list_head task_setrlimit;
  1847. struct list_head task_setscheduler;
  1848. struct list_head task_getscheduler;
  1849. struct list_head task_movememory;
  1850. struct list_head task_kill;
  1851. struct list_head task_prctl;
  1852. struct list_head task_to_inode;
  1853. struct list_head ipc_permission;
  1854. struct list_head ipc_getsecid;
  1855. struct list_head msg_msg_alloc_security;
  1856. struct list_head msg_msg_free_security;
  1857. struct list_head msg_queue_alloc_security;
  1858. struct list_head msg_queue_free_security;
  1859. struct list_head msg_queue_associate;
  1860. struct list_head msg_queue_msgctl;
  1861. struct list_head msg_queue_msgsnd;
  1862. struct list_head msg_queue_msgrcv;
  1863. struct list_head shm_alloc_security;
  1864. struct list_head shm_free_security;
  1865. struct list_head shm_associate;
  1866. struct list_head shm_shmctl;
  1867. struct list_head shm_shmat;
  1868. struct list_head sem_alloc_security;
  1869. struct list_head sem_free_security;
  1870. struct list_head sem_associate;
  1871. struct list_head sem_semctl;
  1872. struct list_head sem_semop;
  1873. struct list_head netlink_send;
  1874. struct list_head d_instantiate;
  1875. struct list_head getprocattr;
  1876. struct list_head setprocattr;
  1877. struct list_head ismaclabel;
  1878. struct list_head secid_to_secctx;
  1879. struct list_head secctx_to_secid;
  1880. struct list_head release_secctx;
  1881. struct list_head inode_invalidate_secctx;
  1882. struct list_head inode_notifysecctx;
  1883. struct list_head inode_setsecctx;
  1884. struct list_head inode_getsecctx;
  1885. #ifdef CONFIG_SECURITY_NETWORK
  1886. struct list_head unix_stream_connect;
  1887. struct list_head unix_may_send;
  1888. struct list_head socket_create;
  1889. struct list_head socket_post_create;
  1890. struct list_head socket_bind;
  1891. struct list_head socket_connect;
  1892. struct list_head socket_listen;
  1893. struct list_head socket_accept;
  1894. struct list_head socket_sendmsg;
  1895. struct list_head socket_recvmsg;
  1896. struct list_head socket_getsockname;
  1897. struct list_head socket_getpeername;
  1898. struct list_head socket_getsockopt;
  1899. struct list_head socket_setsockopt;
  1900. struct list_head socket_shutdown;
  1901. struct list_head socket_sock_rcv_skb;
  1902. struct list_head socket_getpeersec_stream;
  1903. struct list_head socket_getpeersec_dgram;
  1904. struct list_head sk_alloc_security;
  1905. struct list_head sk_free_security;
  1906. struct list_head sk_clone_security;
  1907. struct list_head sk_getsecid;
  1908. struct list_head sock_graft;
  1909. struct list_head inet_conn_request;
  1910. struct list_head inet_csk_clone;
  1911. struct list_head inet_conn_established;
  1912. struct list_head secmark_relabel_packet;
  1913. struct list_head secmark_refcount_inc;
  1914. struct list_head secmark_refcount_dec;
  1915. struct list_head req_classify_flow;
  1916. struct list_head tun_dev_alloc_security;
  1917. struct list_head tun_dev_free_security;
  1918. struct list_head tun_dev_create;
  1919. struct list_head tun_dev_attach_queue;
  1920. struct list_head tun_dev_attach;
  1921. struct list_head tun_dev_open;
  1922. struct list_head sctp_assoc_request;
  1923. struct list_head sctp_bind_connect;
  1924. struct list_head sctp_sk_clone;
  1925. #endif /* CONFIG_SECURITY_NETWORK */
  1926. #ifdef CONFIG_SECURITY_INFINIBAND
  1927. struct list_head ib_pkey_access;
  1928. struct list_head ib_endport_manage_subnet;
  1929. struct list_head ib_alloc_security;
  1930. struct list_head ib_free_security;
  1931. #endif /* CONFIG_SECURITY_INFINIBAND */
  1932. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  1933. struct list_head xfrm_policy_alloc_security;
  1934. struct list_head xfrm_policy_clone_security;
  1935. struct list_head xfrm_policy_free_security;
  1936. struct list_head xfrm_policy_delete_security;
  1937. struct list_head xfrm_state_alloc;
  1938. struct list_head xfrm_state_alloc_acquire;
  1939. struct list_head xfrm_state_free_security;
  1940. struct list_head xfrm_state_delete_security;
  1941. struct list_head xfrm_policy_lookup;
  1942. struct list_head xfrm_state_pol_flow_match;
  1943. struct list_head xfrm_decode_session;
  1944. #endif /* CONFIG_SECURITY_NETWORK_XFRM */
  1945. #ifdef CONFIG_KEYS
  1946. struct list_head key_alloc;
  1947. struct list_head key_free;
  1948. struct list_head key_permission;
  1949. struct list_head key_getsecurity;
  1950. #endif /* CONFIG_KEYS */
  1951. #ifdef CONFIG_AUDIT
  1952. struct list_head audit_rule_init;
  1953. struct list_head audit_rule_known;
  1954. struct list_head audit_rule_match;
  1955. struct list_head audit_rule_free;
  1956. #endif /* CONFIG_AUDIT */
  1957. #ifdef CONFIG_BPF_SYSCALL
  1958. struct list_head bpf;
  1959. struct list_head bpf_map;
  1960. struct list_head bpf_prog;
  1961. struct list_head bpf_map_alloc_security;
  1962. struct list_head bpf_map_free_security;
  1963. struct list_head bpf_prog_alloc_security;
  1964. struct list_head bpf_prog_free_security;
  1965. #endif /* CONFIG_BPF_SYSCALL */
  1966. } __randomize_layout;
  1967. /*
  1968. * Security module hook list structure.
  1969. * For use with generic list macros for common operations.
  1970. */
  1971. struct security_hook_list {
  1972. struct list_head list;
  1973. struct list_head *head;
  1974. union security_list_options hook;
  1975. char *lsm;
  1976. } __randomize_layout;
  1977. /*
  1978. * Initializing a security_hook_list structure takes
  1979. * up a lot of space in a source file. This macro takes
  1980. * care of the common case and reduces the amount of
  1981. * text involved.
  1982. */
  1983. #define LSM_HOOK_INIT(HEAD, HOOK) \
  1984. { .head = &security_hook_heads.HEAD, .hook = { .HEAD = HOOK } }
  1985. extern struct security_hook_heads security_hook_heads;
  1986. extern char *lsm_names;
  1987. extern void security_add_hooks(struct security_hook_list *hooks, int count,
  1988. char *lsm);
  1989. #ifdef CONFIG_SECURITY_SELINUX_DISABLE
  1990. /*
  1991. * Assuring the safety of deleting a security module is up to
  1992. * the security module involved. This may entail ordering the
  1993. * module's hook list in a particular way, refusing to disable
  1994. * the module once a policy is loaded or any number of other
  1995. * actions better imagined than described.
  1996. *
  1997. * The name of the configuration option reflects the only module
  1998. * that currently uses the mechanism. Any developer who thinks
  1999. * disabling their module is a good idea needs to be at least as
  2000. * careful as the SELinux team.
  2001. */
  2002. static inline void security_delete_hooks(struct security_hook_list *hooks,
  2003. int count)
  2004. {
  2005. int i;
  2006. for (i = 0; i < count; i++)
  2007. list_del_rcu(&hooks[i].list);
  2008. }
  2009. #endif /* CONFIG_SECURITY_SELINUX_DISABLE */
  2010. /* Currently required to handle SELinux runtime hook disable. */
  2011. #ifdef CONFIG_SECURITY_WRITABLE_HOOKS
  2012. #define __lsm_ro_after_init
  2013. #else
  2014. #define __lsm_ro_after_init __ro_after_init
  2015. #endif /* CONFIG_SECURITY_WRITABLE_HOOKS */
  2016. extern int __init security_module_enable(const char *module);
  2017. extern void __init capability_add_hooks(void);
  2018. #ifdef CONFIG_SECURITY_YAMA
  2019. extern void __init yama_add_hooks(void);
  2020. #else
  2021. static inline void __init yama_add_hooks(void) { }
  2022. #endif
  2023. #ifdef CONFIG_SECURITY_LOADPIN
  2024. void __init loadpin_add_hooks(void);
  2025. #else
  2026. static inline void loadpin_add_hooks(void) { };
  2027. #endif
  2028. #endif /* ! __LINUX_LSM_HOOKS_H */