lsm_hooks.h 90 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085
  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. * @cred_getsecid:
  555. * Retrieve the security identifier of the cred structure @c
  556. * @c contains the credentials, secid will be placed into @secid.
  557. * In case of failure, @secid will be set to zero.
  558. * @kernel_act_as:
  559. * Set the credentials for a kernel service to act as (subjective context).
  560. * @new points to the credentials to be modified.
  561. * @secid specifies the security ID to be set
  562. * The current task must be the one that nominated @secid.
  563. * Return 0 if successful.
  564. * @kernel_create_files_as:
  565. * Set the file creation context in a set of credentials to be the same as
  566. * the objective context of the specified inode.
  567. * @new points to the credentials to be modified.
  568. * @inode points to the inode to use as a reference.
  569. * The current task must be the one that nominated @inode.
  570. * Return 0 if successful.
  571. * @kernel_module_request:
  572. * Ability to trigger the kernel to automatically upcall to userspace for
  573. * userspace to load a kernel module with the given name.
  574. * @kmod_name name of the module requested by the kernel
  575. * Return 0 if successful.
  576. * @kernel_load_data:
  577. * Load data provided by userspace.
  578. * @id kernel load data identifier
  579. * Return 0 if permission is granted.
  580. * @kernel_read_file:
  581. * Read a file specified by userspace.
  582. * @file contains the file structure pointing to the file being read
  583. * by the kernel.
  584. * @id kernel read file identifier
  585. * Return 0 if permission is granted.
  586. * @kernel_post_read_file:
  587. * Read a file specified by userspace.
  588. * @file contains the file structure pointing to the file being read
  589. * by the kernel.
  590. * @buf pointer to buffer containing the file contents.
  591. * @size length of the file contents.
  592. * @id kernel read file identifier
  593. * Return 0 if permission is granted.
  594. * @task_fix_setuid:
  595. * Update the module's state after setting one or more of the user
  596. * identity attributes of the current process. The @flags parameter
  597. * indicates which of the set*uid system calls invoked this hook. If
  598. * @new is the set of credentials that will be installed. Modifications
  599. * should be made to this rather than to @current->cred.
  600. * @old is the set of credentials that are being replaces
  601. * @flags contains one of the LSM_SETID_* values.
  602. * Return 0 on success.
  603. * @task_setpgid:
  604. * Check permission before setting the process group identifier of the
  605. * process @p to @pgid.
  606. * @p contains the task_struct for process being modified.
  607. * @pgid contains the new pgid.
  608. * Return 0 if permission is granted.
  609. * @task_getpgid:
  610. * Check permission before getting the process group identifier of the
  611. * process @p.
  612. * @p contains the task_struct for the process.
  613. * Return 0 if permission is granted.
  614. * @task_getsid:
  615. * Check permission before getting the session identifier of the process
  616. * @p.
  617. * @p contains the task_struct for the process.
  618. * Return 0 if permission is granted.
  619. * @task_getsecid:
  620. * Retrieve the security identifier of the process @p.
  621. * @p contains the task_struct for the process and place is into @secid.
  622. * In case of failure, @secid will be set to zero.
  623. *
  624. * @task_setnice:
  625. * Check permission before setting the nice value of @p to @nice.
  626. * @p contains the task_struct of process.
  627. * @nice contains the new nice value.
  628. * Return 0 if permission is granted.
  629. * @task_setioprio
  630. * Check permission before setting the ioprio value of @p to @ioprio.
  631. * @p contains the task_struct of process.
  632. * @ioprio contains the new ioprio value
  633. * Return 0 if permission is granted.
  634. * @task_getioprio
  635. * Check permission before getting the ioprio value of @p.
  636. * @p contains the task_struct of process.
  637. * Return 0 if permission is granted.
  638. * @task_prlimit:
  639. * Check permission before getting and/or setting the resource limits of
  640. * another task.
  641. * @cred points to the cred structure for the current task.
  642. * @tcred points to the cred structure for the target task.
  643. * @flags contains the LSM_PRLIMIT_* flag bits indicating whether the
  644. * resource limits are being read, modified, or both.
  645. * Return 0 if permission is granted.
  646. * @task_setrlimit:
  647. * Check permission before setting the resource limits of process @p
  648. * for @resource to @new_rlim. The old resource limit values can
  649. * be examined by dereferencing (p->signal->rlim + resource).
  650. * @p points to the task_struct for the target task's group leader.
  651. * @resource contains the resource whose limit is being set.
  652. * @new_rlim contains the new limits for @resource.
  653. * Return 0 if permission is granted.
  654. * @task_setscheduler:
  655. * Check permission before setting scheduling policy and/or parameters of
  656. * process @p based on @policy and @lp.
  657. * @p contains the task_struct for process.
  658. * @policy contains the scheduling policy.
  659. * @lp contains the scheduling parameters.
  660. * Return 0 if permission is granted.
  661. * @task_getscheduler:
  662. * Check permission before obtaining scheduling information for process
  663. * @p.
  664. * @p contains the task_struct for process.
  665. * Return 0 if permission is granted.
  666. * @task_movememory
  667. * Check permission before moving memory owned by process @p.
  668. * @p contains the task_struct for process.
  669. * Return 0 if permission is granted.
  670. * @task_kill:
  671. * Check permission before sending signal @sig to @p. @info can be NULL,
  672. * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
  673. * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
  674. * from the kernel and should typically be permitted.
  675. * SIGIO signals are handled separately by the send_sigiotask hook in
  676. * file_security_ops.
  677. * @p contains the task_struct for process.
  678. * @info contains the signal information.
  679. * @sig contains the signal value.
  680. * @cred contains the cred of the process where the signal originated, or
  681. * NULL if the current task is the originator.
  682. * Return 0 if permission is granted.
  683. * @task_prctl:
  684. * Check permission before performing a process control operation on the
  685. * current process.
  686. * @option contains the operation.
  687. * @arg2 contains a argument.
  688. * @arg3 contains a argument.
  689. * @arg4 contains a argument.
  690. * @arg5 contains a argument.
  691. * Return -ENOSYS if no-one wanted to handle this op, any other value to
  692. * cause prctl() to return immediately with that value.
  693. * @task_to_inode:
  694. * Set the security attributes for an inode based on an associated task's
  695. * security attributes, e.g. for /proc/pid inodes.
  696. * @p contains the task_struct for the task.
  697. * @inode contains the inode structure for the inode.
  698. *
  699. * Security hooks for Netlink messaging.
  700. *
  701. * @netlink_send:
  702. * Save security information for a netlink message so that permission
  703. * checking can be performed when the message is processed. The security
  704. * information can be saved using the eff_cap field of the
  705. * netlink_skb_parms structure. Also may be used to provide fine
  706. * grained control over message transmission.
  707. * @sk associated sock of task sending the message.
  708. * @skb contains the sk_buff structure for the netlink message.
  709. * Return 0 if the information was successfully saved and message
  710. * is allowed to be transmitted.
  711. *
  712. * Security hooks for Unix domain networking.
  713. *
  714. * @unix_stream_connect:
  715. * Check permissions before establishing a Unix domain stream connection
  716. * between @sock and @other.
  717. * @sock contains the sock structure.
  718. * @other contains the peer sock structure.
  719. * @newsk contains the new sock structure.
  720. * Return 0 if permission is granted.
  721. * @unix_may_send:
  722. * Check permissions before connecting or sending datagrams from @sock to
  723. * @other.
  724. * @sock contains the socket structure.
  725. * @other contains the peer socket structure.
  726. * Return 0 if permission is granted.
  727. *
  728. * The @unix_stream_connect and @unix_may_send hooks were necessary because
  729. * Linux provides an alternative to the conventional file name space for Unix
  730. * domain sockets. Whereas binding and connecting to sockets in the file name
  731. * space is mediated by the typical file permissions (and caught by the mknod
  732. * and permission hooks in inode_security_ops), binding and connecting to
  733. * sockets in the abstract name space is completely unmediated. Sufficient
  734. * control of Unix domain sockets in the abstract name space isn't possible
  735. * using only the socket layer hooks, since we need to know the actual target
  736. * socket, which is not looked up until we are inside the af_unix code.
  737. *
  738. * Security hooks for socket operations.
  739. *
  740. * @socket_create:
  741. * Check permissions prior to creating a new socket.
  742. * @family contains the requested protocol family.
  743. * @type contains the requested communications type.
  744. * @protocol contains the requested protocol.
  745. * @kern set to 1 if a kernel socket.
  746. * Return 0 if permission is granted.
  747. * @socket_post_create:
  748. * This hook allows a module to update or allocate a per-socket security
  749. * structure. Note that the security field was not added directly to the
  750. * socket structure, but rather, the socket security information is stored
  751. * in the associated inode. Typically, the inode alloc_security hook will
  752. * allocate and and attach security information to
  753. * sock->inode->i_security. This hook may be used to update the
  754. * sock->inode->i_security field with additional information that wasn't
  755. * available when the inode was allocated.
  756. * @sock contains the newly created socket structure.
  757. * @family contains the requested protocol family.
  758. * @type contains the requested communications type.
  759. * @protocol contains the requested protocol.
  760. * @kern set to 1 if a kernel socket.
  761. * @socket_socketpair:
  762. * Check permissions before creating a fresh pair of sockets.
  763. * @socka contains the first socket structure.
  764. * @sockb contains the second socket structure.
  765. * Return 0 if permission is granted and the connection was established.
  766. * @socket_bind:
  767. * Check permission before socket protocol layer bind operation is
  768. * performed and the socket @sock is bound to the address specified in the
  769. * @address parameter.
  770. * @sock contains the socket structure.
  771. * @address contains the address to bind to.
  772. * @addrlen contains the length of address.
  773. * Return 0 if permission is granted.
  774. * @socket_connect:
  775. * Check permission before socket protocol layer connect operation
  776. * attempts to connect socket @sock to a remote address, @address.
  777. * @sock contains the socket structure.
  778. * @address contains the address of remote endpoint.
  779. * @addrlen contains the length of address.
  780. * Return 0 if permission is granted.
  781. * @socket_listen:
  782. * Check permission before socket protocol layer listen operation.
  783. * @sock contains the socket structure.
  784. * @backlog contains the maximum length for the pending connection queue.
  785. * Return 0 if permission is granted.
  786. * @socket_accept:
  787. * Check permission before accepting a new connection. Note that the new
  788. * socket, @newsock, has been created and some information copied to it,
  789. * but the accept operation has not actually been performed.
  790. * @sock contains the listening socket structure.
  791. * @newsock contains the newly created server socket for connection.
  792. * Return 0 if permission is granted.
  793. * @socket_sendmsg:
  794. * Check permission before transmitting a message to another socket.
  795. * @sock contains the socket structure.
  796. * @msg contains the message to be transmitted.
  797. * @size contains the size of message.
  798. * Return 0 if permission is granted.
  799. * @socket_recvmsg:
  800. * Check permission before receiving a message from a socket.
  801. * @sock contains the socket structure.
  802. * @msg contains the message structure.
  803. * @size contains the size of message structure.
  804. * @flags contains the operational flags.
  805. * Return 0 if permission is granted.
  806. * @socket_getsockname:
  807. * Check permission before the local address (name) of the socket object
  808. * @sock is retrieved.
  809. * @sock contains the socket structure.
  810. * Return 0 if permission is granted.
  811. * @socket_getpeername:
  812. * Check permission before the remote address (name) of a socket object
  813. * @sock is retrieved.
  814. * @sock contains the socket structure.
  815. * Return 0 if permission is granted.
  816. * @socket_getsockopt:
  817. * Check permissions before retrieving the options associated with socket
  818. * @sock.
  819. * @sock contains the socket structure.
  820. * @level contains the protocol level to retrieve option from.
  821. * @optname contains the name of option to retrieve.
  822. * Return 0 if permission is granted.
  823. * @socket_setsockopt:
  824. * Check permissions before setting the options associated with socket
  825. * @sock.
  826. * @sock contains the socket structure.
  827. * @level contains the protocol level to set options for.
  828. * @optname contains the name of the option to set.
  829. * Return 0 if permission is granted.
  830. * @socket_shutdown:
  831. * Checks permission before all or part of a connection on the socket
  832. * @sock is shut down.
  833. * @sock contains the socket structure.
  834. * @how contains the flag indicating how future sends and receives
  835. * are handled.
  836. * Return 0 if permission is granted.
  837. * @socket_sock_rcv_skb:
  838. * Check permissions on incoming network packets. This hook is distinct
  839. * from Netfilter's IP input hooks since it is the first time that the
  840. * incoming sk_buff @skb has been associated with a particular socket, @sk.
  841. * Must not sleep inside this hook because some callers hold spinlocks.
  842. * @sk contains the sock (not socket) associated with the incoming sk_buff.
  843. * @skb contains the incoming network data.
  844. * @socket_getpeersec_stream:
  845. * This hook allows the security module to provide peer socket security
  846. * state for unix or connected tcp sockets to userspace via getsockopt
  847. * SO_GETPEERSEC. For tcp sockets this can be meaningful if the
  848. * socket is associated with an ipsec SA.
  849. * @sock is the local socket.
  850. * @optval userspace memory where the security state is to be copied.
  851. * @optlen userspace int where the module should copy the actual length
  852. * of the security state.
  853. * @len as input is the maximum length to copy to userspace provided
  854. * by the caller.
  855. * Return 0 if all is well, otherwise, typical getsockopt return
  856. * values.
  857. * @socket_getpeersec_dgram:
  858. * This hook allows the security module to provide peer socket security
  859. * state for udp sockets on a per-packet basis to userspace via
  860. * getsockopt SO_GETPEERSEC. The application must first have indicated
  861. * the IP_PASSSEC option via getsockopt. It can then retrieve the
  862. * security state returned by this hook for a packet via the SCM_SECURITY
  863. * ancillary message type.
  864. * @skb is the skbuff for the packet being queried
  865. * @secdata is a pointer to a buffer in which to copy the security data
  866. * @seclen is the maximum length for @secdata
  867. * Return 0 on success, error on failure.
  868. * @sk_alloc_security:
  869. * Allocate and attach a security structure to the sk->sk_security field,
  870. * which is used to copy security attributes between local stream sockets.
  871. * @sk_free_security:
  872. * Deallocate security structure.
  873. * @sk_clone_security:
  874. * Clone/copy security structure.
  875. * @sk_getsecid:
  876. * Retrieve the LSM-specific secid for the sock to enable caching
  877. * of network authorizations.
  878. * @sock_graft:
  879. * Sets the socket's isec sid to the sock's sid.
  880. * @inet_conn_request:
  881. * Sets the openreq's sid to socket's sid with MLS portion taken
  882. * from peer sid.
  883. * @inet_csk_clone:
  884. * Sets the new child socket's sid to the openreq sid.
  885. * @inet_conn_established:
  886. * Sets the connection's peersid to the secmark on skb.
  887. * @secmark_relabel_packet:
  888. * check if the process should be allowed to relabel packets to
  889. * the given secid
  890. * @security_secmark_refcount_inc
  891. * tells the LSM to increment the number of secmark labeling rules loaded
  892. * @security_secmark_refcount_dec
  893. * tells the LSM to decrement the number of secmark labeling rules loaded
  894. * @req_classify_flow:
  895. * Sets the flow's sid to the openreq sid.
  896. * @tun_dev_alloc_security:
  897. * This hook allows a module to allocate a security structure for a TUN
  898. * device.
  899. * @security pointer to a security structure pointer.
  900. * Returns a zero on success, negative values on failure.
  901. * @tun_dev_free_security:
  902. * This hook allows a module to free the security structure for a TUN
  903. * device.
  904. * @security pointer to the TUN device's security structure
  905. * @tun_dev_create:
  906. * Check permissions prior to creating a new TUN device.
  907. * @tun_dev_attach_queue:
  908. * Check permissions prior to attaching to a TUN device queue.
  909. * @security pointer to the TUN device's security structure.
  910. * @tun_dev_attach:
  911. * This hook can be used by the module to update any security state
  912. * associated with the TUN device's sock structure.
  913. * @sk contains the existing sock structure.
  914. * @security pointer to the TUN device's security structure.
  915. * @tun_dev_open:
  916. * This hook can be used by the module to update any security state
  917. * associated with the TUN device's security structure.
  918. * @security pointer to the TUN devices's security structure.
  919. *
  920. * Security hooks for SCTP
  921. *
  922. * @sctp_assoc_request:
  923. * Passes the @ep and @chunk->skb of the association INIT packet to
  924. * the security module.
  925. * @ep pointer to sctp endpoint structure.
  926. * @skb pointer to skbuff of association packet.
  927. * Return 0 on success, error on failure.
  928. * @sctp_bind_connect:
  929. * Validiate permissions required for each address associated with sock
  930. * @sk. Depending on @optname, the addresses will be treated as either
  931. * for a connect or bind service. The @addrlen is calculated on each
  932. * ipv4 and ipv6 address using sizeof(struct sockaddr_in) or
  933. * sizeof(struct sockaddr_in6).
  934. * @sk pointer to sock structure.
  935. * @optname name of the option to validate.
  936. * @address list containing one or more ipv4/ipv6 addresses.
  937. * @addrlen total length of address(s).
  938. * Return 0 on success, error on failure.
  939. * @sctp_sk_clone:
  940. * Called whenever a new socket is created by accept(2) (i.e. a TCP
  941. * style socket) or when a socket is 'peeled off' e.g userspace
  942. * calls sctp_peeloff(3).
  943. * @ep pointer to current sctp endpoint structure.
  944. * @sk pointer to current sock structure.
  945. * @sk pointer to new sock structure.
  946. *
  947. * Security hooks for Infiniband
  948. *
  949. * @ib_pkey_access:
  950. * Check permission to access a pkey when modifing a QP.
  951. * @subnet_prefix the subnet prefix of the port being used.
  952. * @pkey the pkey to be accessed.
  953. * @sec pointer to a security structure.
  954. * @ib_endport_manage_subnet:
  955. * Check permissions to send and receive SMPs on a end port.
  956. * @dev_name the IB device name (i.e. mlx4_0).
  957. * @port_num the port number.
  958. * @sec pointer to a security structure.
  959. * @ib_alloc_security:
  960. * Allocate a security structure for Infiniband objects.
  961. * @sec pointer to a security structure pointer.
  962. * Returns 0 on success, non-zero on failure
  963. * @ib_free_security:
  964. * Deallocate an Infiniband security structure.
  965. * @sec contains the security structure to be freed.
  966. *
  967. * Security hooks for XFRM operations.
  968. *
  969. * @xfrm_policy_alloc_security:
  970. * @ctxp is a pointer to the xfrm_sec_ctx being added to Security Policy
  971. * Database used by the XFRM system.
  972. * @sec_ctx contains the security context information being provided by
  973. * the user-level policy update program (e.g., setkey).
  974. * Allocate a security structure to the xp->security field; the security
  975. * field is initialized to NULL when the xfrm_policy is allocated.
  976. * Return 0 if operation was successful (memory to allocate, legal context)
  977. * @gfp is to specify the context for the allocation
  978. * @xfrm_policy_clone_security:
  979. * @old_ctx contains an existing xfrm_sec_ctx.
  980. * @new_ctxp contains a new xfrm_sec_ctx being cloned from old.
  981. * Allocate a security structure in new_ctxp that contains the
  982. * information from the old_ctx structure.
  983. * Return 0 if operation was successful (memory to allocate).
  984. * @xfrm_policy_free_security:
  985. * @ctx contains the xfrm_sec_ctx
  986. * Deallocate xp->security.
  987. * @xfrm_policy_delete_security:
  988. * @ctx contains the xfrm_sec_ctx.
  989. * Authorize deletion of xp->security.
  990. * @xfrm_state_alloc:
  991. * @x contains the xfrm_state being added to the Security Association
  992. * Database by the XFRM system.
  993. * @sec_ctx contains the security context information being provided by
  994. * the user-level SA generation program (e.g., setkey or racoon).
  995. * Allocate a security structure to the x->security field; the security
  996. * field is initialized to NULL when the xfrm_state is allocated. Set the
  997. * context to correspond to sec_ctx. Return 0 if operation was successful
  998. * (memory to allocate, legal context).
  999. * @xfrm_state_alloc_acquire:
  1000. * @x contains the xfrm_state being added to the Security Association
  1001. * Database by the XFRM system.
  1002. * @polsec contains the policy's security context.
  1003. * @secid contains the secid from which to take the mls portion of the
  1004. * context.
  1005. * Allocate a security structure to the x->security field; the security
  1006. * field is initialized to NULL when the xfrm_state is allocated. Set the
  1007. * context to correspond to secid. Return 0 if operation was successful
  1008. * (memory to allocate, legal context).
  1009. * @xfrm_state_free_security:
  1010. * @x contains the xfrm_state.
  1011. * Deallocate x->security.
  1012. * @xfrm_state_delete_security:
  1013. * @x contains the xfrm_state.
  1014. * Authorize deletion of x->security.
  1015. * @xfrm_policy_lookup:
  1016. * @ctx contains the xfrm_sec_ctx for which the access control is being
  1017. * checked.
  1018. * @fl_secid contains the flow security label that is used to authorize
  1019. * access to the policy xp.
  1020. * @dir contains the direction of the flow (input or output).
  1021. * Check permission when a flow selects a xfrm_policy for processing
  1022. * XFRMs on a packet. The hook is called when selecting either a
  1023. * per-socket policy or a generic xfrm policy.
  1024. * Return 0 if permission is granted, -ESRCH otherwise, or -errno
  1025. * on other errors.
  1026. * @xfrm_state_pol_flow_match:
  1027. * @x contains the state to match.
  1028. * @xp contains the policy to check for a match.
  1029. * @fl contains the flow to check for a match.
  1030. * Return 1 if there is a match.
  1031. * @xfrm_decode_session:
  1032. * @skb points to skb to decode.
  1033. * @secid points to the flow key secid to set.
  1034. * @ckall says if all xfrms used should be checked for same secid.
  1035. * Return 0 if ckall is zero or all xfrms used have the same secid.
  1036. *
  1037. * Security hooks affecting all Key Management operations
  1038. *
  1039. * @key_alloc:
  1040. * Permit allocation of a key and assign security data. Note that key does
  1041. * not have a serial number assigned at this point.
  1042. * @key points to the key.
  1043. * @flags is the allocation flags
  1044. * Return 0 if permission is granted, -ve error otherwise.
  1045. * @key_free:
  1046. * Notification of destruction; free security data.
  1047. * @key points to the key.
  1048. * No return value.
  1049. * @key_permission:
  1050. * See whether a specific operational right is granted to a process on a
  1051. * key.
  1052. * @key_ref refers to the key (key pointer + possession attribute bit).
  1053. * @cred points to the credentials to provide the context against which to
  1054. * evaluate the security data on the key.
  1055. * @perm describes the combination of permissions required of this key.
  1056. * Return 0 if permission is granted, -ve error otherwise.
  1057. * @key_getsecurity:
  1058. * Get a textual representation of the security context attached to a key
  1059. * for the purposes of honouring KEYCTL_GETSECURITY. This function
  1060. * allocates the storage for the NUL-terminated string and the caller
  1061. * should free it.
  1062. * @key points to the key to be queried.
  1063. * @_buffer points to a pointer that should be set to point to the
  1064. * resulting string (if no label or an error occurs).
  1065. * Return the length of the string (including terminating NUL) or -ve if
  1066. * an error.
  1067. * May also return 0 (and a NULL buffer pointer) if there is no label.
  1068. *
  1069. * Security hooks affecting all System V IPC operations.
  1070. *
  1071. * @ipc_permission:
  1072. * Check permissions for access to IPC
  1073. * @ipcp contains the kernel IPC permission structure
  1074. * @flag contains the desired (requested) permission set
  1075. * Return 0 if permission is granted.
  1076. * @ipc_getsecid:
  1077. * Get the secid associated with the ipc object.
  1078. * @ipcp contains the kernel IPC permission structure.
  1079. * @secid contains a pointer to the location where result will be saved.
  1080. * In case of failure, @secid will be set to zero.
  1081. *
  1082. * Security hooks for individual messages held in System V IPC message queues
  1083. * @msg_msg_alloc_security:
  1084. * Allocate and attach a security structure to the msg->security field.
  1085. * The security field is initialized to NULL when the structure is first
  1086. * created.
  1087. * @msg contains the message structure to be modified.
  1088. * Return 0 if operation was successful and permission is granted.
  1089. * @msg_msg_free_security:
  1090. * Deallocate the security structure for this message.
  1091. * @msg contains the message structure to be modified.
  1092. *
  1093. * Security hooks for System V IPC Message Queues
  1094. *
  1095. * @msg_queue_alloc_security:
  1096. * Allocate and attach a security structure to the
  1097. * msq->q_perm.security field. The security field is initialized to
  1098. * NULL when the structure is first created.
  1099. * @msq contains the message queue structure to be modified.
  1100. * Return 0 if operation was successful and permission is granted.
  1101. * @msg_queue_free_security:
  1102. * Deallocate security structure for this message queue.
  1103. * @msq contains the message queue structure to be modified.
  1104. * @msg_queue_associate:
  1105. * Check permission when a message queue is requested through the
  1106. * msgget system call. This hook is only called when returning the
  1107. * message queue identifier for an existing message queue, not when a
  1108. * new message queue is created.
  1109. * @msq contains the message queue to act upon.
  1110. * @msqflg contains the operation control flags.
  1111. * Return 0 if permission is granted.
  1112. * @msg_queue_msgctl:
  1113. * Check permission when a message control operation specified by @cmd
  1114. * is to be performed on the message queue @msq.
  1115. * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
  1116. * @msq contains the message queue to act upon. May be NULL.
  1117. * @cmd contains the operation to be performed.
  1118. * Return 0 if permission is granted.
  1119. * @msg_queue_msgsnd:
  1120. * Check permission before a message, @msg, is enqueued on the message
  1121. * queue, @msq.
  1122. * @msq contains the message queue to send message to.
  1123. * @msg contains the message to be enqueued.
  1124. * @msqflg contains operational flags.
  1125. * Return 0 if permission is granted.
  1126. * @msg_queue_msgrcv:
  1127. * Check permission before a message, @msg, is removed from the message
  1128. * queue, @msq. The @target task structure contains a pointer to the
  1129. * process that will be receiving the message (not equal to the current
  1130. * process when inline receives are being performed).
  1131. * @msq contains the message queue to retrieve message from.
  1132. * @msg contains the message destination.
  1133. * @target contains the task structure for recipient process.
  1134. * @type contains the type of message requested.
  1135. * @mode contains the operational flags.
  1136. * Return 0 if permission is granted.
  1137. *
  1138. * Security hooks for System V Shared Memory Segments
  1139. *
  1140. * @shm_alloc_security:
  1141. * Allocate and attach a security structure to the shp->shm_perm.security
  1142. * field. The security field is initialized to NULL when the structure is
  1143. * first created.
  1144. * @shp contains the shared memory structure to be modified.
  1145. * Return 0 if operation was successful and permission is granted.
  1146. * @shm_free_security:
  1147. * Deallocate the security struct for this memory segment.
  1148. * @shp contains the shared memory structure to be modified.
  1149. * @shm_associate:
  1150. * Check permission when a shared memory region is requested through the
  1151. * shmget system call. This hook is only called when returning the shared
  1152. * memory region identifier for an existing region, not when a new shared
  1153. * memory region is created.
  1154. * @shp contains the shared memory structure to be modified.
  1155. * @shmflg contains the operation control flags.
  1156. * Return 0 if permission is granted.
  1157. * @shm_shmctl:
  1158. * Check permission when a shared memory control operation specified by
  1159. * @cmd is to be performed on the shared memory region @shp.
  1160. * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
  1161. * @shp contains shared memory structure to be modified.
  1162. * @cmd contains the operation to be performed.
  1163. * Return 0 if permission is granted.
  1164. * @shm_shmat:
  1165. * Check permissions prior to allowing the shmat system call to attach the
  1166. * shared memory segment @shp to the data segment of the calling process.
  1167. * The attaching address is specified by @shmaddr.
  1168. * @shp contains the shared memory structure to be modified.
  1169. * @shmaddr contains the address to attach memory region to.
  1170. * @shmflg contains the operational flags.
  1171. * Return 0 if permission is granted.
  1172. *
  1173. * Security hooks for System V Semaphores
  1174. *
  1175. * @sem_alloc_security:
  1176. * Allocate and attach a security structure to the sma->sem_perm.security
  1177. * field. The security field is initialized to NULL when the structure is
  1178. * first created.
  1179. * @sma contains the semaphore structure
  1180. * Return 0 if operation was successful and permission is granted.
  1181. * @sem_free_security:
  1182. * deallocate security struct for this semaphore
  1183. * @sma contains the semaphore structure.
  1184. * @sem_associate:
  1185. * Check permission when a semaphore is requested through the semget
  1186. * system call. This hook is only called when returning the semaphore
  1187. * identifier for an existing semaphore, not when a new one must be
  1188. * created.
  1189. * @sma contains the semaphore structure.
  1190. * @semflg contains the operation control flags.
  1191. * Return 0 if permission is granted.
  1192. * @sem_semctl:
  1193. * Check permission when a semaphore operation specified by @cmd is to be
  1194. * performed on the semaphore @sma. The @sma may be NULL, e.g. for
  1195. * IPC_INFO or SEM_INFO.
  1196. * @sma contains the semaphore structure. May be NULL.
  1197. * @cmd contains the operation to be performed.
  1198. * Return 0 if permission is granted.
  1199. * @sem_semop:
  1200. * Check permissions before performing operations on members of the
  1201. * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
  1202. * may be modified.
  1203. * @sma contains the semaphore structure.
  1204. * @sops contains the operations to perform.
  1205. * @nsops contains the number of operations to perform.
  1206. * @alter contains the flag indicating whether changes are to be made.
  1207. * Return 0 if permission is granted.
  1208. *
  1209. * @binder_set_context_mgr:
  1210. * Check whether @mgr is allowed to be the binder context manager.
  1211. * @mgr contains the task_struct for the task being registered.
  1212. * Return 0 if permission is granted.
  1213. * @binder_transaction:
  1214. * Check whether @from is allowed to invoke a binder transaction call
  1215. * to @to.
  1216. * @from contains the task_struct for the sending task.
  1217. * @to contains the task_struct for the receiving task.
  1218. * @binder_transfer_binder:
  1219. * Check whether @from is allowed to transfer a binder reference to @to.
  1220. * @from contains the task_struct for the sending task.
  1221. * @to contains the task_struct for the receiving task.
  1222. * @binder_transfer_file:
  1223. * Check whether @from is allowed to transfer @file to @to.
  1224. * @from contains the task_struct for the sending task.
  1225. * @file contains the struct file being transferred.
  1226. * @to contains the task_struct for the receiving task.
  1227. *
  1228. * @ptrace_access_check:
  1229. * Check permission before allowing the current process to trace the
  1230. * @child process.
  1231. * Security modules may also want to perform a process tracing check
  1232. * during an execve in the set_security or apply_creds hooks of
  1233. * tracing check during an execve in the bprm_set_creds hook of
  1234. * binprm_security_ops if the process is being traced and its security
  1235. * attributes would be changed by the execve.
  1236. * @child contains the task_struct structure for the target process.
  1237. * @mode contains the PTRACE_MODE flags indicating the form of access.
  1238. * Return 0 if permission is granted.
  1239. * @ptrace_traceme:
  1240. * Check that the @parent process has sufficient permission to trace the
  1241. * current process before allowing the current process to present itself
  1242. * to the @parent process for tracing.
  1243. * @parent contains the task_struct structure for debugger process.
  1244. * Return 0 if permission is granted.
  1245. * @capget:
  1246. * Get the @effective, @inheritable, and @permitted capability sets for
  1247. * the @target process. The hook may also perform permission checking to
  1248. * determine if the current process is allowed to see the capability sets
  1249. * of the @target process.
  1250. * @target contains the task_struct structure for target process.
  1251. * @effective contains the effective capability set.
  1252. * @inheritable contains the inheritable capability set.
  1253. * @permitted contains the permitted capability set.
  1254. * Return 0 if the capability sets were successfully obtained.
  1255. * @capset:
  1256. * Set the @effective, @inheritable, and @permitted capability sets for
  1257. * the current process.
  1258. * @new contains the new credentials structure for target process.
  1259. * @old contains the current credentials structure for target process.
  1260. * @effective contains the effective capability set.
  1261. * @inheritable contains the inheritable capability set.
  1262. * @permitted contains the permitted capability set.
  1263. * Return 0 and update @new if permission is granted.
  1264. * @capable:
  1265. * Check whether the @tsk process has the @cap capability in the indicated
  1266. * credentials.
  1267. * @cred contains the credentials to use.
  1268. * @ns contains the user namespace we want the capability in
  1269. * @cap contains the capability <include/linux/capability.h>.
  1270. * @audit contains whether to write an audit message or not
  1271. * Return 0 if the capability is granted for @tsk.
  1272. * @syslog:
  1273. * Check permission before accessing the kernel message ring or changing
  1274. * logging to the console.
  1275. * See the syslog(2) manual page for an explanation of the @type values.
  1276. * @type contains the type of action.
  1277. * @from_file indicates the context of action (if it came from /proc).
  1278. * Return 0 if permission is granted.
  1279. * @settime:
  1280. * Check permission to change the system time.
  1281. * struct timespec64 is defined in include/linux/time64.h and timezone
  1282. * is defined in include/linux/time.h
  1283. * @ts contains new time
  1284. * @tz contains new timezone
  1285. * Return 0 if permission is granted.
  1286. * @vm_enough_memory:
  1287. * Check permissions for allocating a new virtual mapping.
  1288. * @mm contains the mm struct it is being added to.
  1289. * @pages contains the number of pages.
  1290. * Return 0 if permission is granted.
  1291. *
  1292. * @ismaclabel:
  1293. * Check if the extended attribute specified by @name
  1294. * represents a MAC label. Returns 1 if name is a MAC
  1295. * attribute otherwise returns 0.
  1296. * @name full extended attribute name to check against
  1297. * LSM as a MAC label.
  1298. *
  1299. * @secid_to_secctx:
  1300. * Convert secid to security context. If secdata is NULL the length of
  1301. * the result will be returned in seclen, but no secdata will be returned.
  1302. * This does mean that the length could change between calls to check the
  1303. * length and the next call which actually allocates and returns the
  1304. * secdata.
  1305. * @secid contains the security ID.
  1306. * @secdata contains the pointer that stores the converted security
  1307. * context.
  1308. * @seclen pointer which contains the length of the data
  1309. * @secctx_to_secid:
  1310. * Convert security context to secid.
  1311. * @secid contains the pointer to the generated security ID.
  1312. * @secdata contains the security context.
  1313. *
  1314. * @release_secctx:
  1315. * Release the security context.
  1316. * @secdata contains the security context.
  1317. * @seclen contains the length of the security context.
  1318. *
  1319. * Security hooks for Audit
  1320. *
  1321. * @audit_rule_init:
  1322. * Allocate and initialize an LSM audit rule structure.
  1323. * @field contains the required Audit action.
  1324. * Fields flags are defined in include/linux/audit.h
  1325. * @op contains the operator the rule uses.
  1326. * @rulestr contains the context where the rule will be applied to.
  1327. * @lsmrule contains a pointer to receive the result.
  1328. * Return 0 if @lsmrule has been successfully set,
  1329. * -EINVAL in case of an invalid rule.
  1330. *
  1331. * @audit_rule_known:
  1332. * Specifies whether given @rule contains any fields related to
  1333. * current LSM.
  1334. * @rule contains the audit rule of interest.
  1335. * Return 1 in case of relation found, 0 otherwise.
  1336. *
  1337. * @audit_rule_match:
  1338. * Determine if given @secid matches a rule previously approved
  1339. * by @audit_rule_known.
  1340. * @secid contains the security id in question.
  1341. * @field contains the field which relates to current LSM.
  1342. * @op contains the operator that will be used for matching.
  1343. * @rule points to the audit rule that will be checked against.
  1344. * @actx points to the audit context associated with the check.
  1345. * Return 1 if secid matches the rule, 0 if it does not, -ERRNO on failure.
  1346. *
  1347. * @audit_rule_free:
  1348. * Deallocate the LSM audit rule structure previously allocated by
  1349. * audit_rule_init.
  1350. * @rule contains the allocated rule
  1351. *
  1352. * @inode_invalidate_secctx:
  1353. * Notify the security module that it must revalidate the security context
  1354. * of an inode.
  1355. *
  1356. * @inode_notifysecctx:
  1357. * Notify the security module of what the security context of an inode
  1358. * should be. Initializes the incore security context managed by the
  1359. * security module for this inode. Example usage: NFS client invokes
  1360. * this hook to initialize the security context in its incore inode to the
  1361. * value provided by the server for the file when the server returned the
  1362. * file's attributes to the client.
  1363. *
  1364. * Must be called with inode->i_mutex locked.
  1365. *
  1366. * @inode we wish to set the security context of.
  1367. * @ctx contains the string which we wish to set in the inode.
  1368. * @ctxlen contains the length of @ctx.
  1369. *
  1370. * @inode_setsecctx:
  1371. * Change the security context of an inode. Updates the
  1372. * incore security context managed by the security module and invokes the
  1373. * fs code as needed (via __vfs_setxattr_noperm) to update any backing
  1374. * xattrs that represent the context. Example usage: NFS server invokes
  1375. * this hook to change the security context in its incore inode and on the
  1376. * backing filesystem to a value provided by the client on a SETATTR
  1377. * operation.
  1378. *
  1379. * Must be called with inode->i_mutex locked.
  1380. *
  1381. * @dentry contains the inode we wish to set the security context of.
  1382. * @ctx contains the string which we wish to set in the inode.
  1383. * @ctxlen contains the length of @ctx.
  1384. *
  1385. * @inode_getsecctx:
  1386. * On success, returns 0 and fills out @ctx and @ctxlen with the security
  1387. * context for the given @inode.
  1388. *
  1389. * @inode we wish to get the security context of.
  1390. * @ctx is a pointer in which to place the allocated security context.
  1391. * @ctxlen points to the place to put the length of @ctx.
  1392. *
  1393. * Security hooks for using the eBPF maps and programs functionalities through
  1394. * eBPF syscalls.
  1395. *
  1396. * @bpf:
  1397. * Do a initial check for all bpf syscalls after the attribute is copied
  1398. * into the kernel. The actual security module can implement their own
  1399. * rules to check the specific cmd they need.
  1400. *
  1401. * @bpf_map:
  1402. * Do a check when the kernel generate and return a file descriptor for
  1403. * eBPF maps.
  1404. *
  1405. * @map: bpf map that we want to access
  1406. * @mask: the access flags
  1407. *
  1408. * @bpf_prog:
  1409. * Do a check when the kernel generate and return a file descriptor for
  1410. * eBPF programs.
  1411. *
  1412. * @prog: bpf prog that userspace want to use.
  1413. *
  1414. * @bpf_map_alloc_security:
  1415. * Initialize the security field inside bpf map.
  1416. *
  1417. * @bpf_map_free_security:
  1418. * Clean up the security information stored inside bpf map.
  1419. *
  1420. * @bpf_prog_alloc_security:
  1421. * Initialize the security field inside bpf program.
  1422. *
  1423. * @bpf_prog_free_security:
  1424. * Clean up the security information stored inside bpf prog.
  1425. *
  1426. */
  1427. union security_list_options {
  1428. int (*binder_set_context_mgr)(struct task_struct *mgr);
  1429. int (*binder_transaction)(struct task_struct *from,
  1430. struct task_struct *to);
  1431. int (*binder_transfer_binder)(struct task_struct *from,
  1432. struct task_struct *to);
  1433. int (*binder_transfer_file)(struct task_struct *from,
  1434. struct task_struct *to,
  1435. struct file *file);
  1436. int (*ptrace_access_check)(struct task_struct *child,
  1437. unsigned int mode);
  1438. int (*ptrace_traceme)(struct task_struct *parent);
  1439. int (*capget)(struct task_struct *target, kernel_cap_t *effective,
  1440. kernel_cap_t *inheritable, kernel_cap_t *permitted);
  1441. int (*capset)(struct cred *new, const struct cred *old,
  1442. const kernel_cap_t *effective,
  1443. const kernel_cap_t *inheritable,
  1444. const kernel_cap_t *permitted);
  1445. int (*capable)(const struct cred *cred, struct user_namespace *ns,
  1446. int cap, int audit);
  1447. int (*quotactl)(int cmds, int type, int id, struct super_block *sb);
  1448. int (*quota_on)(struct dentry *dentry);
  1449. int (*syslog)(int type);
  1450. int (*settime)(const struct timespec64 *ts, const struct timezone *tz);
  1451. int (*vm_enough_memory)(struct mm_struct *mm, long pages);
  1452. int (*bprm_set_creds)(struct linux_binprm *bprm);
  1453. int (*bprm_check_security)(struct linux_binprm *bprm);
  1454. void (*bprm_committing_creds)(struct linux_binprm *bprm);
  1455. void (*bprm_committed_creds)(struct linux_binprm *bprm);
  1456. int (*sb_alloc_security)(struct super_block *sb);
  1457. void (*sb_free_security)(struct super_block *sb);
  1458. int (*sb_copy_data)(char *orig, char *copy);
  1459. int (*sb_remount)(struct super_block *sb, void *data);
  1460. int (*sb_kern_mount)(struct super_block *sb, int flags, void *data);
  1461. int (*sb_show_options)(struct seq_file *m, struct super_block *sb);
  1462. int (*sb_statfs)(struct dentry *dentry);
  1463. int (*sb_mount)(const char *dev_name, const struct path *path,
  1464. const char *type, unsigned long flags, void *data);
  1465. int (*sb_umount)(struct vfsmount *mnt, int flags);
  1466. int (*sb_pivotroot)(const struct path *old_path, const struct path *new_path);
  1467. int (*sb_set_mnt_opts)(struct super_block *sb,
  1468. struct security_mnt_opts *opts,
  1469. unsigned long kern_flags,
  1470. unsigned long *set_kern_flags);
  1471. int (*sb_clone_mnt_opts)(const struct super_block *oldsb,
  1472. struct super_block *newsb,
  1473. unsigned long kern_flags,
  1474. unsigned long *set_kern_flags);
  1475. int (*sb_parse_opts_str)(char *options, struct security_mnt_opts *opts);
  1476. int (*dentry_init_security)(struct dentry *dentry, int mode,
  1477. const struct qstr *name, void **ctx,
  1478. u32 *ctxlen);
  1479. int (*dentry_create_files_as)(struct dentry *dentry, int mode,
  1480. struct qstr *name,
  1481. const struct cred *old,
  1482. struct cred *new);
  1483. #ifdef CONFIG_SECURITY_PATH
  1484. int (*path_unlink)(const struct path *dir, struct dentry *dentry);
  1485. int (*path_mkdir)(const struct path *dir, struct dentry *dentry,
  1486. umode_t mode);
  1487. int (*path_rmdir)(const struct path *dir, struct dentry *dentry);
  1488. int (*path_mknod)(const struct path *dir, struct dentry *dentry,
  1489. umode_t mode, unsigned int dev);
  1490. int (*path_truncate)(const struct path *path);
  1491. int (*path_symlink)(const struct path *dir, struct dentry *dentry,
  1492. const char *old_name);
  1493. int (*path_link)(struct dentry *old_dentry, const struct path *new_dir,
  1494. struct dentry *new_dentry);
  1495. int (*path_rename)(const struct path *old_dir, struct dentry *old_dentry,
  1496. const struct path *new_dir,
  1497. struct dentry *new_dentry);
  1498. int (*path_chmod)(const struct path *path, umode_t mode);
  1499. int (*path_chown)(const struct path *path, kuid_t uid, kgid_t gid);
  1500. int (*path_chroot)(const struct path *path);
  1501. #endif
  1502. int (*inode_alloc_security)(struct inode *inode);
  1503. void (*inode_free_security)(struct inode *inode);
  1504. int (*inode_init_security)(struct inode *inode, struct inode *dir,
  1505. const struct qstr *qstr,
  1506. const char **name, void **value,
  1507. size_t *len);
  1508. int (*inode_create)(struct inode *dir, struct dentry *dentry,
  1509. umode_t mode);
  1510. int (*inode_link)(struct dentry *old_dentry, struct inode *dir,
  1511. struct dentry *new_dentry);
  1512. int (*inode_unlink)(struct inode *dir, struct dentry *dentry);
  1513. int (*inode_symlink)(struct inode *dir, struct dentry *dentry,
  1514. const char *old_name);
  1515. int (*inode_mkdir)(struct inode *dir, struct dentry *dentry,
  1516. umode_t mode);
  1517. int (*inode_rmdir)(struct inode *dir, struct dentry *dentry);
  1518. int (*inode_mknod)(struct inode *dir, struct dentry *dentry,
  1519. umode_t mode, dev_t dev);
  1520. int (*inode_rename)(struct inode *old_dir, struct dentry *old_dentry,
  1521. struct inode *new_dir,
  1522. struct dentry *new_dentry);
  1523. int (*inode_readlink)(struct dentry *dentry);
  1524. int (*inode_follow_link)(struct dentry *dentry, struct inode *inode,
  1525. bool rcu);
  1526. int (*inode_permission)(struct inode *inode, int mask);
  1527. int (*inode_setattr)(struct dentry *dentry, struct iattr *attr);
  1528. int (*inode_getattr)(const struct path *path);
  1529. int (*inode_setxattr)(struct dentry *dentry, const char *name,
  1530. const void *value, size_t size, int flags);
  1531. void (*inode_post_setxattr)(struct dentry *dentry, const char *name,
  1532. const void *value, size_t size,
  1533. int flags);
  1534. int (*inode_getxattr)(struct dentry *dentry, const char *name);
  1535. int (*inode_listxattr)(struct dentry *dentry);
  1536. int (*inode_removexattr)(struct dentry *dentry, const char *name);
  1537. int (*inode_need_killpriv)(struct dentry *dentry);
  1538. int (*inode_killpriv)(struct dentry *dentry);
  1539. int (*inode_getsecurity)(struct inode *inode, const char *name,
  1540. void **buffer, bool alloc);
  1541. int (*inode_setsecurity)(struct inode *inode, const char *name,
  1542. const void *value, size_t size,
  1543. int flags);
  1544. int (*inode_listsecurity)(struct inode *inode, char *buffer,
  1545. size_t buffer_size);
  1546. void (*inode_getsecid)(struct inode *inode, u32 *secid);
  1547. int (*inode_copy_up)(struct dentry *src, struct cred **new);
  1548. int (*inode_copy_up_xattr)(const char *name);
  1549. int (*file_permission)(struct file *file, int mask);
  1550. int (*file_alloc_security)(struct file *file);
  1551. void (*file_free_security)(struct file *file);
  1552. int (*file_ioctl)(struct file *file, unsigned int cmd,
  1553. unsigned long arg);
  1554. int (*mmap_addr)(unsigned long addr);
  1555. int (*mmap_file)(struct file *file, unsigned long reqprot,
  1556. unsigned long prot, unsigned long flags);
  1557. int (*file_mprotect)(struct vm_area_struct *vma, unsigned long reqprot,
  1558. unsigned long prot);
  1559. int (*file_lock)(struct file *file, unsigned int cmd);
  1560. int (*file_fcntl)(struct file *file, unsigned int cmd,
  1561. unsigned long arg);
  1562. void (*file_set_fowner)(struct file *file);
  1563. int (*file_send_sigiotask)(struct task_struct *tsk,
  1564. struct fown_struct *fown, int sig);
  1565. int (*file_receive)(struct file *file);
  1566. int (*file_open)(struct file *file);
  1567. int (*task_alloc)(struct task_struct *task, unsigned long clone_flags);
  1568. void (*task_free)(struct task_struct *task);
  1569. int (*cred_alloc_blank)(struct cred *cred, gfp_t gfp);
  1570. void (*cred_free)(struct cred *cred);
  1571. int (*cred_prepare)(struct cred *new, const struct cred *old,
  1572. gfp_t gfp);
  1573. void (*cred_transfer)(struct cred *new, const struct cred *old);
  1574. void (*cred_getsecid)(const struct cred *c, u32 *secid);
  1575. int (*kernel_act_as)(struct cred *new, u32 secid);
  1576. int (*kernel_create_files_as)(struct cred *new, struct inode *inode);
  1577. int (*kernel_module_request)(char *kmod_name);
  1578. int (*kernel_load_data)(enum kernel_load_data_id id);
  1579. int (*kernel_read_file)(struct file *file, enum kernel_read_file_id id);
  1580. int (*kernel_post_read_file)(struct file *file, char *buf, loff_t size,
  1581. enum kernel_read_file_id id);
  1582. int (*task_fix_setuid)(struct cred *new, const struct cred *old,
  1583. int flags);
  1584. int (*task_setpgid)(struct task_struct *p, pid_t pgid);
  1585. int (*task_getpgid)(struct task_struct *p);
  1586. int (*task_getsid)(struct task_struct *p);
  1587. void (*task_getsecid)(struct task_struct *p, u32 *secid);
  1588. int (*task_setnice)(struct task_struct *p, int nice);
  1589. int (*task_setioprio)(struct task_struct *p, int ioprio);
  1590. int (*task_getioprio)(struct task_struct *p);
  1591. int (*task_prlimit)(const struct cred *cred, const struct cred *tcred,
  1592. unsigned int flags);
  1593. int (*task_setrlimit)(struct task_struct *p, unsigned int resource,
  1594. struct rlimit *new_rlim);
  1595. int (*task_setscheduler)(struct task_struct *p);
  1596. int (*task_getscheduler)(struct task_struct *p);
  1597. int (*task_movememory)(struct task_struct *p);
  1598. int (*task_kill)(struct task_struct *p, struct siginfo *info,
  1599. int sig, const struct cred *cred);
  1600. int (*task_prctl)(int option, unsigned long arg2, unsigned long arg3,
  1601. unsigned long arg4, unsigned long arg5);
  1602. void (*task_to_inode)(struct task_struct *p, struct inode *inode);
  1603. int (*ipc_permission)(struct kern_ipc_perm *ipcp, short flag);
  1604. void (*ipc_getsecid)(struct kern_ipc_perm *ipcp, u32 *secid);
  1605. int (*msg_msg_alloc_security)(struct msg_msg *msg);
  1606. void (*msg_msg_free_security)(struct msg_msg *msg);
  1607. int (*msg_queue_alloc_security)(struct kern_ipc_perm *msq);
  1608. void (*msg_queue_free_security)(struct kern_ipc_perm *msq);
  1609. int (*msg_queue_associate)(struct kern_ipc_perm *msq, int msqflg);
  1610. int (*msg_queue_msgctl)(struct kern_ipc_perm *msq, int cmd);
  1611. int (*msg_queue_msgsnd)(struct kern_ipc_perm *msq, struct msg_msg *msg,
  1612. int msqflg);
  1613. int (*msg_queue_msgrcv)(struct kern_ipc_perm *msq, struct msg_msg *msg,
  1614. struct task_struct *target, long type,
  1615. int mode);
  1616. int (*shm_alloc_security)(struct kern_ipc_perm *shp);
  1617. void (*shm_free_security)(struct kern_ipc_perm *shp);
  1618. int (*shm_associate)(struct kern_ipc_perm *shp, int shmflg);
  1619. int (*shm_shmctl)(struct kern_ipc_perm *shp, int cmd);
  1620. int (*shm_shmat)(struct kern_ipc_perm *shp, char __user *shmaddr,
  1621. int shmflg);
  1622. int (*sem_alloc_security)(struct kern_ipc_perm *sma);
  1623. void (*sem_free_security)(struct kern_ipc_perm *sma);
  1624. int (*sem_associate)(struct kern_ipc_perm *sma, int semflg);
  1625. int (*sem_semctl)(struct kern_ipc_perm *sma, int cmd);
  1626. int (*sem_semop)(struct kern_ipc_perm *sma, struct sembuf *sops,
  1627. unsigned nsops, int alter);
  1628. int (*netlink_send)(struct sock *sk, struct sk_buff *skb);
  1629. void (*d_instantiate)(struct dentry *dentry, struct inode *inode);
  1630. int (*getprocattr)(struct task_struct *p, char *name, char **value);
  1631. int (*setprocattr)(const char *name, void *value, size_t size);
  1632. int (*ismaclabel)(const char *name);
  1633. int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
  1634. int (*secctx_to_secid)(const char *secdata, u32 seclen, u32 *secid);
  1635. void (*release_secctx)(char *secdata, u32 seclen);
  1636. void (*inode_invalidate_secctx)(struct inode *inode);
  1637. int (*inode_notifysecctx)(struct inode *inode, void *ctx, u32 ctxlen);
  1638. int (*inode_setsecctx)(struct dentry *dentry, void *ctx, u32 ctxlen);
  1639. int (*inode_getsecctx)(struct inode *inode, void **ctx, u32 *ctxlen);
  1640. #ifdef CONFIG_SECURITY_NETWORK
  1641. int (*unix_stream_connect)(struct sock *sock, struct sock *other,
  1642. struct sock *newsk);
  1643. int (*unix_may_send)(struct socket *sock, struct socket *other);
  1644. int (*socket_create)(int family, int type, int protocol, int kern);
  1645. int (*socket_post_create)(struct socket *sock, int family, int type,
  1646. int protocol, int kern);
  1647. int (*socket_socketpair)(struct socket *socka, struct socket *sockb);
  1648. int (*socket_bind)(struct socket *sock, struct sockaddr *address,
  1649. int addrlen);
  1650. int (*socket_connect)(struct socket *sock, struct sockaddr *address,
  1651. int addrlen);
  1652. int (*socket_listen)(struct socket *sock, int backlog);
  1653. int (*socket_accept)(struct socket *sock, struct socket *newsock);
  1654. int (*socket_sendmsg)(struct socket *sock, struct msghdr *msg,
  1655. int size);
  1656. int (*socket_recvmsg)(struct socket *sock, struct msghdr *msg,
  1657. int size, int flags);
  1658. int (*socket_getsockname)(struct socket *sock);
  1659. int (*socket_getpeername)(struct socket *sock);
  1660. int (*socket_getsockopt)(struct socket *sock, int level, int optname);
  1661. int (*socket_setsockopt)(struct socket *sock, int level, int optname);
  1662. int (*socket_shutdown)(struct socket *sock, int how);
  1663. int (*socket_sock_rcv_skb)(struct sock *sk, struct sk_buff *skb);
  1664. int (*socket_getpeersec_stream)(struct socket *sock,
  1665. char __user *optval,
  1666. int __user *optlen, unsigned len);
  1667. int (*socket_getpeersec_dgram)(struct socket *sock,
  1668. struct sk_buff *skb, u32 *secid);
  1669. int (*sk_alloc_security)(struct sock *sk, int family, gfp_t priority);
  1670. void (*sk_free_security)(struct sock *sk);
  1671. void (*sk_clone_security)(const struct sock *sk, struct sock *newsk);
  1672. void (*sk_getsecid)(struct sock *sk, u32 *secid);
  1673. void (*sock_graft)(struct sock *sk, struct socket *parent);
  1674. int (*inet_conn_request)(struct sock *sk, struct sk_buff *skb,
  1675. struct request_sock *req);
  1676. void (*inet_csk_clone)(struct sock *newsk,
  1677. const struct request_sock *req);
  1678. void (*inet_conn_established)(struct sock *sk, struct sk_buff *skb);
  1679. int (*secmark_relabel_packet)(u32 secid);
  1680. void (*secmark_refcount_inc)(void);
  1681. void (*secmark_refcount_dec)(void);
  1682. void (*req_classify_flow)(const struct request_sock *req,
  1683. struct flowi *fl);
  1684. int (*tun_dev_alloc_security)(void **security);
  1685. void (*tun_dev_free_security)(void *security);
  1686. int (*tun_dev_create)(void);
  1687. int (*tun_dev_attach_queue)(void *security);
  1688. int (*tun_dev_attach)(struct sock *sk, void *security);
  1689. int (*tun_dev_open)(void *security);
  1690. int (*sctp_assoc_request)(struct sctp_endpoint *ep,
  1691. struct sk_buff *skb);
  1692. int (*sctp_bind_connect)(struct sock *sk, int optname,
  1693. struct sockaddr *address, int addrlen);
  1694. void (*sctp_sk_clone)(struct sctp_endpoint *ep, struct sock *sk,
  1695. struct sock *newsk);
  1696. #endif /* CONFIG_SECURITY_NETWORK */
  1697. #ifdef CONFIG_SECURITY_INFINIBAND
  1698. int (*ib_pkey_access)(void *sec, u64 subnet_prefix, u16 pkey);
  1699. int (*ib_endport_manage_subnet)(void *sec, const char *dev_name,
  1700. u8 port_num);
  1701. int (*ib_alloc_security)(void **sec);
  1702. void (*ib_free_security)(void *sec);
  1703. #endif /* CONFIG_SECURITY_INFINIBAND */
  1704. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  1705. int (*xfrm_policy_alloc_security)(struct xfrm_sec_ctx **ctxp,
  1706. struct xfrm_user_sec_ctx *sec_ctx,
  1707. gfp_t gfp);
  1708. int (*xfrm_policy_clone_security)(struct xfrm_sec_ctx *old_ctx,
  1709. struct xfrm_sec_ctx **new_ctx);
  1710. void (*xfrm_policy_free_security)(struct xfrm_sec_ctx *ctx);
  1711. int (*xfrm_policy_delete_security)(struct xfrm_sec_ctx *ctx);
  1712. int (*xfrm_state_alloc)(struct xfrm_state *x,
  1713. struct xfrm_user_sec_ctx *sec_ctx);
  1714. int (*xfrm_state_alloc_acquire)(struct xfrm_state *x,
  1715. struct xfrm_sec_ctx *polsec,
  1716. u32 secid);
  1717. void (*xfrm_state_free_security)(struct xfrm_state *x);
  1718. int (*xfrm_state_delete_security)(struct xfrm_state *x);
  1719. int (*xfrm_policy_lookup)(struct xfrm_sec_ctx *ctx, u32 fl_secid,
  1720. u8 dir);
  1721. int (*xfrm_state_pol_flow_match)(struct xfrm_state *x,
  1722. struct xfrm_policy *xp,
  1723. const struct flowi *fl);
  1724. int (*xfrm_decode_session)(struct sk_buff *skb, u32 *secid, int ckall);
  1725. #endif /* CONFIG_SECURITY_NETWORK_XFRM */
  1726. /* key management security hooks */
  1727. #ifdef CONFIG_KEYS
  1728. int (*key_alloc)(struct key *key, const struct cred *cred,
  1729. unsigned long flags);
  1730. void (*key_free)(struct key *key);
  1731. int (*key_permission)(key_ref_t key_ref, const struct cred *cred,
  1732. unsigned perm);
  1733. int (*key_getsecurity)(struct key *key, char **_buffer);
  1734. #endif /* CONFIG_KEYS */
  1735. #ifdef CONFIG_AUDIT
  1736. int (*audit_rule_init)(u32 field, u32 op, char *rulestr,
  1737. void **lsmrule);
  1738. int (*audit_rule_known)(struct audit_krule *krule);
  1739. int (*audit_rule_match)(u32 secid, u32 field, u32 op, void *lsmrule,
  1740. struct audit_context *actx);
  1741. void (*audit_rule_free)(void *lsmrule);
  1742. #endif /* CONFIG_AUDIT */
  1743. #ifdef CONFIG_BPF_SYSCALL
  1744. int (*bpf)(int cmd, union bpf_attr *attr,
  1745. unsigned int size);
  1746. int (*bpf_map)(struct bpf_map *map, fmode_t fmode);
  1747. int (*bpf_prog)(struct bpf_prog *prog);
  1748. int (*bpf_map_alloc_security)(struct bpf_map *map);
  1749. void (*bpf_map_free_security)(struct bpf_map *map);
  1750. int (*bpf_prog_alloc_security)(struct bpf_prog_aux *aux);
  1751. void (*bpf_prog_free_security)(struct bpf_prog_aux *aux);
  1752. #endif /* CONFIG_BPF_SYSCALL */
  1753. };
  1754. struct security_hook_heads {
  1755. struct hlist_head binder_set_context_mgr;
  1756. struct hlist_head binder_transaction;
  1757. struct hlist_head binder_transfer_binder;
  1758. struct hlist_head binder_transfer_file;
  1759. struct hlist_head ptrace_access_check;
  1760. struct hlist_head ptrace_traceme;
  1761. struct hlist_head capget;
  1762. struct hlist_head capset;
  1763. struct hlist_head capable;
  1764. struct hlist_head quotactl;
  1765. struct hlist_head quota_on;
  1766. struct hlist_head syslog;
  1767. struct hlist_head settime;
  1768. struct hlist_head vm_enough_memory;
  1769. struct hlist_head bprm_set_creds;
  1770. struct hlist_head bprm_check_security;
  1771. struct hlist_head bprm_committing_creds;
  1772. struct hlist_head bprm_committed_creds;
  1773. struct hlist_head sb_alloc_security;
  1774. struct hlist_head sb_free_security;
  1775. struct hlist_head sb_copy_data;
  1776. struct hlist_head sb_remount;
  1777. struct hlist_head sb_kern_mount;
  1778. struct hlist_head sb_show_options;
  1779. struct hlist_head sb_statfs;
  1780. struct hlist_head sb_mount;
  1781. struct hlist_head sb_umount;
  1782. struct hlist_head sb_pivotroot;
  1783. struct hlist_head sb_set_mnt_opts;
  1784. struct hlist_head sb_clone_mnt_opts;
  1785. struct hlist_head sb_parse_opts_str;
  1786. struct hlist_head dentry_init_security;
  1787. struct hlist_head dentry_create_files_as;
  1788. #ifdef CONFIG_SECURITY_PATH
  1789. struct hlist_head path_unlink;
  1790. struct hlist_head path_mkdir;
  1791. struct hlist_head path_rmdir;
  1792. struct hlist_head path_mknod;
  1793. struct hlist_head path_truncate;
  1794. struct hlist_head path_symlink;
  1795. struct hlist_head path_link;
  1796. struct hlist_head path_rename;
  1797. struct hlist_head path_chmod;
  1798. struct hlist_head path_chown;
  1799. struct hlist_head path_chroot;
  1800. #endif
  1801. struct hlist_head inode_alloc_security;
  1802. struct hlist_head inode_free_security;
  1803. struct hlist_head inode_init_security;
  1804. struct hlist_head inode_create;
  1805. struct hlist_head inode_link;
  1806. struct hlist_head inode_unlink;
  1807. struct hlist_head inode_symlink;
  1808. struct hlist_head inode_mkdir;
  1809. struct hlist_head inode_rmdir;
  1810. struct hlist_head inode_mknod;
  1811. struct hlist_head inode_rename;
  1812. struct hlist_head inode_readlink;
  1813. struct hlist_head inode_follow_link;
  1814. struct hlist_head inode_permission;
  1815. struct hlist_head inode_setattr;
  1816. struct hlist_head inode_getattr;
  1817. struct hlist_head inode_setxattr;
  1818. struct hlist_head inode_post_setxattr;
  1819. struct hlist_head inode_getxattr;
  1820. struct hlist_head inode_listxattr;
  1821. struct hlist_head inode_removexattr;
  1822. struct hlist_head inode_need_killpriv;
  1823. struct hlist_head inode_killpriv;
  1824. struct hlist_head inode_getsecurity;
  1825. struct hlist_head inode_setsecurity;
  1826. struct hlist_head inode_listsecurity;
  1827. struct hlist_head inode_getsecid;
  1828. struct hlist_head inode_copy_up;
  1829. struct hlist_head inode_copy_up_xattr;
  1830. struct hlist_head file_permission;
  1831. struct hlist_head file_alloc_security;
  1832. struct hlist_head file_free_security;
  1833. struct hlist_head file_ioctl;
  1834. struct hlist_head mmap_addr;
  1835. struct hlist_head mmap_file;
  1836. struct hlist_head file_mprotect;
  1837. struct hlist_head file_lock;
  1838. struct hlist_head file_fcntl;
  1839. struct hlist_head file_set_fowner;
  1840. struct hlist_head file_send_sigiotask;
  1841. struct hlist_head file_receive;
  1842. struct hlist_head file_open;
  1843. struct hlist_head task_alloc;
  1844. struct hlist_head task_free;
  1845. struct hlist_head cred_alloc_blank;
  1846. struct hlist_head cred_free;
  1847. struct hlist_head cred_prepare;
  1848. struct hlist_head cred_transfer;
  1849. struct hlist_head cred_getsecid;
  1850. struct hlist_head kernel_act_as;
  1851. struct hlist_head kernel_create_files_as;
  1852. struct hlist_head kernel_load_data;
  1853. struct hlist_head kernel_read_file;
  1854. struct hlist_head kernel_post_read_file;
  1855. struct hlist_head kernel_module_request;
  1856. struct hlist_head task_fix_setuid;
  1857. struct hlist_head task_setpgid;
  1858. struct hlist_head task_getpgid;
  1859. struct hlist_head task_getsid;
  1860. struct hlist_head task_getsecid;
  1861. struct hlist_head task_setnice;
  1862. struct hlist_head task_setioprio;
  1863. struct hlist_head task_getioprio;
  1864. struct hlist_head task_prlimit;
  1865. struct hlist_head task_setrlimit;
  1866. struct hlist_head task_setscheduler;
  1867. struct hlist_head task_getscheduler;
  1868. struct hlist_head task_movememory;
  1869. struct hlist_head task_kill;
  1870. struct hlist_head task_prctl;
  1871. struct hlist_head task_to_inode;
  1872. struct hlist_head ipc_permission;
  1873. struct hlist_head ipc_getsecid;
  1874. struct hlist_head msg_msg_alloc_security;
  1875. struct hlist_head msg_msg_free_security;
  1876. struct hlist_head msg_queue_alloc_security;
  1877. struct hlist_head msg_queue_free_security;
  1878. struct hlist_head msg_queue_associate;
  1879. struct hlist_head msg_queue_msgctl;
  1880. struct hlist_head msg_queue_msgsnd;
  1881. struct hlist_head msg_queue_msgrcv;
  1882. struct hlist_head shm_alloc_security;
  1883. struct hlist_head shm_free_security;
  1884. struct hlist_head shm_associate;
  1885. struct hlist_head shm_shmctl;
  1886. struct hlist_head shm_shmat;
  1887. struct hlist_head sem_alloc_security;
  1888. struct hlist_head sem_free_security;
  1889. struct hlist_head sem_associate;
  1890. struct hlist_head sem_semctl;
  1891. struct hlist_head sem_semop;
  1892. struct hlist_head netlink_send;
  1893. struct hlist_head d_instantiate;
  1894. struct hlist_head getprocattr;
  1895. struct hlist_head setprocattr;
  1896. struct hlist_head ismaclabel;
  1897. struct hlist_head secid_to_secctx;
  1898. struct hlist_head secctx_to_secid;
  1899. struct hlist_head release_secctx;
  1900. struct hlist_head inode_invalidate_secctx;
  1901. struct hlist_head inode_notifysecctx;
  1902. struct hlist_head inode_setsecctx;
  1903. struct hlist_head inode_getsecctx;
  1904. #ifdef CONFIG_SECURITY_NETWORK
  1905. struct hlist_head unix_stream_connect;
  1906. struct hlist_head unix_may_send;
  1907. struct hlist_head socket_create;
  1908. struct hlist_head socket_post_create;
  1909. struct hlist_head socket_socketpair;
  1910. struct hlist_head socket_bind;
  1911. struct hlist_head socket_connect;
  1912. struct hlist_head socket_listen;
  1913. struct hlist_head socket_accept;
  1914. struct hlist_head socket_sendmsg;
  1915. struct hlist_head socket_recvmsg;
  1916. struct hlist_head socket_getsockname;
  1917. struct hlist_head socket_getpeername;
  1918. struct hlist_head socket_getsockopt;
  1919. struct hlist_head socket_setsockopt;
  1920. struct hlist_head socket_shutdown;
  1921. struct hlist_head socket_sock_rcv_skb;
  1922. struct hlist_head socket_getpeersec_stream;
  1923. struct hlist_head socket_getpeersec_dgram;
  1924. struct hlist_head sk_alloc_security;
  1925. struct hlist_head sk_free_security;
  1926. struct hlist_head sk_clone_security;
  1927. struct hlist_head sk_getsecid;
  1928. struct hlist_head sock_graft;
  1929. struct hlist_head inet_conn_request;
  1930. struct hlist_head inet_csk_clone;
  1931. struct hlist_head inet_conn_established;
  1932. struct hlist_head secmark_relabel_packet;
  1933. struct hlist_head secmark_refcount_inc;
  1934. struct hlist_head secmark_refcount_dec;
  1935. struct hlist_head req_classify_flow;
  1936. struct hlist_head tun_dev_alloc_security;
  1937. struct hlist_head tun_dev_free_security;
  1938. struct hlist_head tun_dev_create;
  1939. struct hlist_head tun_dev_attach_queue;
  1940. struct hlist_head tun_dev_attach;
  1941. struct hlist_head tun_dev_open;
  1942. struct hlist_head sctp_assoc_request;
  1943. struct hlist_head sctp_bind_connect;
  1944. struct hlist_head sctp_sk_clone;
  1945. #endif /* CONFIG_SECURITY_NETWORK */
  1946. #ifdef CONFIG_SECURITY_INFINIBAND
  1947. struct hlist_head ib_pkey_access;
  1948. struct hlist_head ib_endport_manage_subnet;
  1949. struct hlist_head ib_alloc_security;
  1950. struct hlist_head ib_free_security;
  1951. #endif /* CONFIG_SECURITY_INFINIBAND */
  1952. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  1953. struct hlist_head xfrm_policy_alloc_security;
  1954. struct hlist_head xfrm_policy_clone_security;
  1955. struct hlist_head xfrm_policy_free_security;
  1956. struct hlist_head xfrm_policy_delete_security;
  1957. struct hlist_head xfrm_state_alloc;
  1958. struct hlist_head xfrm_state_alloc_acquire;
  1959. struct hlist_head xfrm_state_free_security;
  1960. struct hlist_head xfrm_state_delete_security;
  1961. struct hlist_head xfrm_policy_lookup;
  1962. struct hlist_head xfrm_state_pol_flow_match;
  1963. struct hlist_head xfrm_decode_session;
  1964. #endif /* CONFIG_SECURITY_NETWORK_XFRM */
  1965. #ifdef CONFIG_KEYS
  1966. struct hlist_head key_alloc;
  1967. struct hlist_head key_free;
  1968. struct hlist_head key_permission;
  1969. struct hlist_head key_getsecurity;
  1970. #endif /* CONFIG_KEYS */
  1971. #ifdef CONFIG_AUDIT
  1972. struct hlist_head audit_rule_init;
  1973. struct hlist_head audit_rule_known;
  1974. struct hlist_head audit_rule_match;
  1975. struct hlist_head audit_rule_free;
  1976. #endif /* CONFIG_AUDIT */
  1977. #ifdef CONFIG_BPF_SYSCALL
  1978. struct hlist_head bpf;
  1979. struct hlist_head bpf_map;
  1980. struct hlist_head bpf_prog;
  1981. struct hlist_head bpf_map_alloc_security;
  1982. struct hlist_head bpf_map_free_security;
  1983. struct hlist_head bpf_prog_alloc_security;
  1984. struct hlist_head bpf_prog_free_security;
  1985. #endif /* CONFIG_BPF_SYSCALL */
  1986. } __randomize_layout;
  1987. /*
  1988. * Security module hook list structure.
  1989. * For use with generic list macros for common operations.
  1990. */
  1991. struct security_hook_list {
  1992. struct hlist_node list;
  1993. struct hlist_head *head;
  1994. union security_list_options hook;
  1995. char *lsm;
  1996. } __randomize_layout;
  1997. /*
  1998. * Initializing a security_hook_list structure takes
  1999. * up a lot of space in a source file. This macro takes
  2000. * care of the common case and reduces the amount of
  2001. * text involved.
  2002. */
  2003. #define LSM_HOOK_INIT(HEAD, HOOK) \
  2004. { .head = &security_hook_heads.HEAD, .hook = { .HEAD = HOOK } }
  2005. extern struct security_hook_heads security_hook_heads;
  2006. extern char *lsm_names;
  2007. extern void security_add_hooks(struct security_hook_list *hooks, int count,
  2008. char *lsm);
  2009. #ifdef CONFIG_SECURITY_SELINUX_DISABLE
  2010. /*
  2011. * Assuring the safety of deleting a security module is up to
  2012. * the security module involved. This may entail ordering the
  2013. * module's hook list in a particular way, refusing to disable
  2014. * the module once a policy is loaded or any number of other
  2015. * actions better imagined than described.
  2016. *
  2017. * The name of the configuration option reflects the only module
  2018. * that currently uses the mechanism. Any developer who thinks
  2019. * disabling their module is a good idea needs to be at least as
  2020. * careful as the SELinux team.
  2021. */
  2022. static inline void security_delete_hooks(struct security_hook_list *hooks,
  2023. int count)
  2024. {
  2025. int i;
  2026. for (i = 0; i < count; i++)
  2027. hlist_del_rcu(&hooks[i].list);
  2028. }
  2029. #endif /* CONFIG_SECURITY_SELINUX_DISABLE */
  2030. /* Currently required to handle SELinux runtime hook disable. */
  2031. #ifdef CONFIG_SECURITY_WRITABLE_HOOKS
  2032. #define __lsm_ro_after_init
  2033. #else
  2034. #define __lsm_ro_after_init __ro_after_init
  2035. #endif /* CONFIG_SECURITY_WRITABLE_HOOKS */
  2036. extern int __init security_module_enable(const char *module);
  2037. extern void __init capability_add_hooks(void);
  2038. #ifdef CONFIG_SECURITY_YAMA
  2039. extern void __init yama_add_hooks(void);
  2040. #else
  2041. static inline void __init yama_add_hooks(void) { }
  2042. #endif
  2043. #ifdef CONFIG_SECURITY_LOADPIN
  2044. void __init loadpin_add_hooks(void);
  2045. #else
  2046. static inline void loadpin_add_hooks(void) { };
  2047. #endif
  2048. #endif /* ! __LINUX_LSM_HOOKS_H */