security.h 103 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145
  1. /*
  2. * Linux Security plug
  3. *
  4. * Copyright (C) 2001 WireX Communications, Inc <chris@wirex.com>
  5. * Copyright (C) 2001 Greg Kroah-Hartman <greg@kroah.com>
  6. * Copyright (C) 2001 Networks Associates Technology, Inc <ssmalley@nai.com>
  7. * Copyright (C) 2001 James Morris <jmorris@intercode.com.au>
  8. * Copyright (C) 2001 Silicon Graphics, Inc. (Trust Technology Group)
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * Due to this file being licensed under the GPL there is controversy over
  16. * whether this permits you to write a module that #includes this file
  17. * without placing your module under the GPL. Please consult a lawyer for
  18. * advice before doing this.
  19. *
  20. */
  21. #ifndef __LINUX_SECURITY_H
  22. #define __LINUX_SECURITY_H
  23. #include <linux/fs.h>
  24. #include <linux/binfmts.h>
  25. #include <linux/signal.h>
  26. #include <linux/resource.h>
  27. #include <linux/sem.h>
  28. #include <linux/shm.h>
  29. #include <linux/msg.h>
  30. #include <linux/sched.h>
  31. #include <linux/key.h>
  32. struct ctl_table;
  33. /*
  34. * These functions are in security/capability.c and are used
  35. * as the default capabilities functions
  36. */
  37. extern int cap_capable (struct task_struct *tsk, int cap);
  38. extern int cap_settime (struct timespec *ts, struct timezone *tz);
  39. extern int cap_ptrace (struct task_struct *parent, struct task_struct *child);
  40. extern int cap_capget (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
  41. extern int cap_capset_check (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
  42. extern void cap_capset_set (struct task_struct *target, kernel_cap_t *effective, kernel_cap_t *inheritable, kernel_cap_t *permitted);
  43. extern int cap_bprm_set_security (struct linux_binprm *bprm);
  44. extern void cap_bprm_apply_creds (struct linux_binprm *bprm, int unsafe);
  45. extern int cap_bprm_secureexec(struct linux_binprm *bprm);
  46. extern int cap_inode_setxattr(struct dentry *dentry, char *name, void *value, size_t size, int flags);
  47. extern int cap_inode_removexattr(struct dentry *dentry, char *name);
  48. extern int cap_task_post_setuid (uid_t old_ruid, uid_t old_euid, uid_t old_suid, int flags);
  49. extern void cap_task_reparent_to_init (struct task_struct *p);
  50. extern int cap_syslog (int type);
  51. extern int cap_vm_enough_memory (long pages);
  52. struct msghdr;
  53. struct sk_buff;
  54. struct sock;
  55. struct sockaddr;
  56. struct socket;
  57. struct flowi;
  58. struct dst_entry;
  59. struct xfrm_selector;
  60. struct xfrm_policy;
  61. struct xfrm_state;
  62. struct xfrm_user_sec_ctx;
  63. extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
  64. extern int cap_netlink_recv(struct sk_buff *skb, int cap);
  65. /*
  66. * Values used in the task_security_ops calls
  67. */
  68. /* setuid or setgid, id0 == uid or gid */
  69. #define LSM_SETID_ID 1
  70. /* setreuid or setregid, id0 == real, id1 == eff */
  71. #define LSM_SETID_RE 2
  72. /* setresuid or setresgid, id0 == real, id1 == eff, uid2 == saved */
  73. #define LSM_SETID_RES 4
  74. /* setfsuid or setfsgid, id0 == fsuid or fsgid */
  75. #define LSM_SETID_FS 8
  76. /* forward declares to avoid warnings */
  77. struct nfsctl_arg;
  78. struct sched_param;
  79. struct swap_info_struct;
  80. /* bprm_apply_creds unsafe reasons */
  81. #define LSM_UNSAFE_SHARE 1
  82. #define LSM_UNSAFE_PTRACE 2
  83. #define LSM_UNSAFE_PTRACE_CAP 4
  84. #ifdef CONFIG_SECURITY
  85. /**
  86. * struct security_operations - main security structure
  87. *
  88. * Security hooks for program execution operations.
  89. *
  90. * @bprm_alloc_security:
  91. * Allocate and attach a security structure to the @bprm->security field.
  92. * The security field is initialized to NULL when the bprm structure is
  93. * allocated.
  94. * @bprm contains the linux_binprm structure to be modified.
  95. * Return 0 if operation was successful.
  96. * @bprm_free_security:
  97. * @bprm contains the linux_binprm structure to be modified.
  98. * Deallocate and clear the @bprm->security field.
  99. * @bprm_apply_creds:
  100. * Compute and set the security attributes of a process being transformed
  101. * by an execve operation based on the old attributes (current->security)
  102. * and the information saved in @bprm->security by the set_security hook.
  103. * Since this hook function (and its caller) are void, this hook can not
  104. * return an error. However, it can leave the security attributes of the
  105. * process unchanged if an access failure occurs at this point.
  106. * bprm_apply_creds is called under task_lock. @unsafe indicates various
  107. * reasons why it may be unsafe to change security state.
  108. * @bprm contains the linux_binprm structure.
  109. * @bprm_post_apply_creds:
  110. * Runs after bprm_apply_creds with the task_lock dropped, so that
  111. * functions which cannot be called safely under the task_lock can
  112. * be used. This hook is a good place to perform state changes on
  113. * the process such as closing open file descriptors to which access
  114. * is no longer granted if the attributes were changed.
  115. * Note that a security module might need to save state between
  116. * bprm_apply_creds and bprm_post_apply_creds to store the decision
  117. * on whether the process may proceed.
  118. * @bprm contains the linux_binprm structure.
  119. * @bprm_set_security:
  120. * Save security information in the bprm->security field, typically based
  121. * on information about the bprm->file, for later use by the apply_creds
  122. * hook. This hook may also optionally check permissions (e.g. for
  123. * transitions between security domains).
  124. * This hook may be called multiple times during a single execve, e.g. for
  125. * interpreters. The hook can tell whether it has already been called by
  126. * checking to see if @bprm->security is non-NULL. If so, then the hook
  127. * may decide either to retain the security information saved earlier or
  128. * to replace it.
  129. * @bprm contains the linux_binprm structure.
  130. * Return 0 if the hook is successful and permission is granted.
  131. * @bprm_check_security:
  132. * This hook mediates the point when a search for a binary handler will
  133. * begin. It allows a check the @bprm->security value which is set in
  134. * the preceding set_security call. The primary difference from
  135. * set_security is that the argv list and envp list are reliably
  136. * available in @bprm. This hook may be called multiple times
  137. * during a single execve; and in each pass set_security is called
  138. * first.
  139. * @bprm contains the linux_binprm structure.
  140. * Return 0 if the hook is successful and permission is granted.
  141. * @bprm_secureexec:
  142. * Return a boolean value (0 or 1) indicating whether a "secure exec"
  143. * is required. The flag is passed in the auxiliary table
  144. * on the initial stack to the ELF interpreter to indicate whether libc
  145. * should enable secure mode.
  146. * @bprm contains the linux_binprm structure.
  147. *
  148. * Security hooks for filesystem operations.
  149. *
  150. * @sb_alloc_security:
  151. * Allocate and attach a security structure to the sb->s_security field.
  152. * The s_security field is initialized to NULL when the structure is
  153. * allocated.
  154. * @sb contains the super_block structure to be modified.
  155. * Return 0 if operation was successful.
  156. * @sb_free_security:
  157. * Deallocate and clear the sb->s_security field.
  158. * @sb contains the super_block structure to be modified.
  159. * @sb_statfs:
  160. * Check permission before obtaining filesystem statistics for the @mnt
  161. * mountpoint.
  162. * @dentry is a handle on the superblock for the filesystem.
  163. * Return 0 if permission is granted.
  164. * @sb_mount:
  165. * Check permission before an object specified by @dev_name is mounted on
  166. * the mount point named by @nd. For an ordinary mount, @dev_name
  167. * identifies a device if the file system type requires a device. For a
  168. * remount (@flags & MS_REMOUNT), @dev_name is irrelevant. For a
  169. * loopback/bind mount (@flags & MS_BIND), @dev_name identifies the
  170. * pathname of the object being mounted.
  171. * @dev_name contains the name for object being mounted.
  172. * @nd contains the nameidata structure for mount point object.
  173. * @type contains the filesystem type.
  174. * @flags contains the mount flags.
  175. * @data contains the filesystem-specific data.
  176. * Return 0 if permission is granted.
  177. * @sb_copy_data:
  178. * Allow mount option data to be copied prior to parsing by the filesystem,
  179. * so that the security module can extract security-specific mount
  180. * options cleanly (a filesystem may modify the data e.g. with strsep()).
  181. * This also allows the original mount data to be stripped of security-
  182. * specific options to avoid having to make filesystems aware of them.
  183. * @type the type of filesystem being mounted.
  184. * @orig the original mount data copied from userspace.
  185. * @copy copied data which will be passed to the security module.
  186. * Returns 0 if the copy was successful.
  187. * @sb_check_sb:
  188. * Check permission before the device with superblock @mnt->sb is mounted
  189. * on the mount point named by @nd.
  190. * @mnt contains the vfsmount for device being mounted.
  191. * @nd contains the nameidata object for the mount point.
  192. * Return 0 if permission is granted.
  193. * @sb_umount:
  194. * Check permission before the @mnt file system is unmounted.
  195. * @mnt contains the mounted file system.
  196. * @flags contains the unmount flags, e.g. MNT_FORCE.
  197. * Return 0 if permission is granted.
  198. * @sb_umount_close:
  199. * Close any files in the @mnt mounted filesystem that are held open by
  200. * the security module. This hook is called during an umount operation
  201. * prior to checking whether the filesystem is still busy.
  202. * @mnt contains the mounted filesystem.
  203. * @sb_umount_busy:
  204. * Handle a failed umount of the @mnt mounted filesystem, e.g. re-opening
  205. * any files that were closed by umount_close. This hook is called during
  206. * an umount operation if the umount fails after a call to the
  207. * umount_close hook.
  208. * @mnt contains the mounted filesystem.
  209. * @sb_post_remount:
  210. * Update the security module's state when a filesystem is remounted.
  211. * This hook is only called if the remount was successful.
  212. * @mnt contains the mounted file system.
  213. * @flags contains the new filesystem flags.
  214. * @data contains the filesystem-specific data.
  215. * @sb_post_mountroot:
  216. * Update the security module's state when the root filesystem is mounted.
  217. * This hook is only called if the mount was successful.
  218. * @sb_post_addmount:
  219. * Update the security module's state when a filesystem is mounted.
  220. * This hook is called any time a mount is successfully grafetd to
  221. * the tree.
  222. * @mnt contains the mounted filesystem.
  223. * @mountpoint_nd contains the nameidata structure for the mount point.
  224. * @sb_pivotroot:
  225. * Check permission before pivoting the root filesystem.
  226. * @old_nd contains the nameidata structure for the new location of the current root (put_old).
  227. * @new_nd contains the nameidata structure for the new root (new_root).
  228. * Return 0 if permission is granted.
  229. * @sb_post_pivotroot:
  230. * Update module state after a successful pivot.
  231. * @old_nd contains the nameidata structure for the old root.
  232. * @new_nd contains the nameidata structure for the new root.
  233. *
  234. * Security hooks for inode operations.
  235. *
  236. * @inode_alloc_security:
  237. * Allocate and attach a security structure to @inode->i_security. The
  238. * i_security field is initialized to NULL when the inode structure is
  239. * allocated.
  240. * @inode contains the inode structure.
  241. * Return 0 if operation was successful.
  242. * @inode_free_security:
  243. * @inode contains the inode structure.
  244. * Deallocate the inode security structure and set @inode->i_security to
  245. * NULL.
  246. * @inode_init_security:
  247. * Obtain the security attribute name suffix and value to set on a newly
  248. * created inode and set up the incore security field for the new inode.
  249. * This hook is called by the fs code as part of the inode creation
  250. * transaction and provides for atomic labeling of the inode, unlike
  251. * the post_create/mkdir/... hooks called by the VFS. The hook function
  252. * is expected to allocate the name and value via kmalloc, with the caller
  253. * being responsible for calling kfree after using them.
  254. * If the security module does not use security attributes or does
  255. * not wish to put a security attribute on this particular inode,
  256. * then it should return -EOPNOTSUPP to skip this processing.
  257. * @inode contains the inode structure of the newly created inode.
  258. * @dir contains the inode structure of the parent directory.
  259. * @name will be set to the allocated name suffix (e.g. selinux).
  260. * @value will be set to the allocated attribute value.
  261. * @len will be set to the length of the value.
  262. * Returns 0 if @name and @value have been successfully set,
  263. * -EOPNOTSUPP if no security attribute is needed, or
  264. * -ENOMEM on memory allocation failure.
  265. * @inode_create:
  266. * Check permission to create a regular file.
  267. * @dir contains inode structure of the parent of the new file.
  268. * @dentry contains the dentry structure for the file to be created.
  269. * @mode contains the file mode of the file to be created.
  270. * Return 0 if permission is granted.
  271. * @inode_link:
  272. * Check permission before creating a new hard link to a file.
  273. * @old_dentry contains the dentry structure for an existing link to the file.
  274. * @dir contains the inode structure of the parent directory of the new link.
  275. * @new_dentry contains the dentry structure for the new link.
  276. * Return 0 if permission is granted.
  277. * @inode_unlink:
  278. * Check the permission to remove a hard link to a file.
  279. * @dir contains the inode structure of parent directory of the file.
  280. * @dentry contains the dentry structure for file to be unlinked.
  281. * Return 0 if permission is granted.
  282. * @inode_symlink:
  283. * Check the permission to create a symbolic link to a file.
  284. * @dir contains the inode structure of parent directory of the symbolic link.
  285. * @dentry contains the dentry structure of the symbolic link.
  286. * @old_name contains the pathname of file.
  287. * Return 0 if permission is granted.
  288. * @inode_mkdir:
  289. * Check permissions to create a new directory in the existing directory
  290. * associated with inode strcture @dir.
  291. * @dir containst the inode structure of parent of the directory to be created.
  292. * @dentry contains the dentry structure of new directory.
  293. * @mode contains the mode of new directory.
  294. * Return 0 if permission is granted.
  295. * @inode_rmdir:
  296. * Check the permission to remove a directory.
  297. * @dir contains the inode structure of parent of the directory to be removed.
  298. * @dentry contains the dentry structure of directory to be removed.
  299. * Return 0 if permission is granted.
  300. * @inode_mknod:
  301. * Check permissions when creating a special file (or a socket or a fifo
  302. * file created via the mknod system call). Note that if mknod operation
  303. * is being done for a regular file, then the create hook will be called
  304. * and not this hook.
  305. * @dir contains the inode structure of parent of the new file.
  306. * @dentry contains the dentry structure of the new file.
  307. * @mode contains the mode of the new file.
  308. * @dev contains the the device number.
  309. * Return 0 if permission is granted.
  310. * @inode_rename:
  311. * Check for permission to rename a file or directory.
  312. * @old_dir contains the inode structure for parent of the old link.
  313. * @old_dentry contains the dentry structure of the old link.
  314. * @new_dir contains the inode structure for parent of the new link.
  315. * @new_dentry contains the dentry structure of the new link.
  316. * Return 0 if permission is granted.
  317. * @inode_readlink:
  318. * Check the permission to read the symbolic link.
  319. * @dentry contains the dentry structure for the file link.
  320. * Return 0 if permission is granted.
  321. * @inode_follow_link:
  322. * Check permission to follow a symbolic link when looking up a pathname.
  323. * @dentry contains the dentry structure for the link.
  324. * @nd contains the nameidata structure for the parent directory.
  325. * Return 0 if permission is granted.
  326. * @inode_permission:
  327. * Check permission before accessing an inode. This hook is called by the
  328. * existing Linux permission function, so a security module can use it to
  329. * provide additional checking for existing Linux permission checks.
  330. * Notice that this hook is called when a file is opened (as well as many
  331. * other operations), whereas the file_security_ops permission hook is
  332. * called when the actual read/write operations are performed.
  333. * @inode contains the inode structure to check.
  334. * @mask contains the permission mask.
  335. * @nd contains the nameidata (may be NULL).
  336. * Return 0 if permission is granted.
  337. * @inode_setattr:
  338. * Check permission before setting file attributes. Note that the kernel
  339. * call to notify_change is performed from several locations, whenever
  340. * file attributes change (such as when a file is truncated, chown/chmod
  341. * operations, transferring disk quotas, etc).
  342. * @dentry contains the dentry structure for the file.
  343. * @attr is the iattr structure containing the new file attributes.
  344. * Return 0 if permission is granted.
  345. * @inode_getattr:
  346. * Check permission before obtaining file attributes.
  347. * @mnt is the vfsmount where the dentry was looked up
  348. * @dentry contains the dentry structure for the file.
  349. * Return 0 if permission is granted.
  350. * @inode_delete:
  351. * @inode contains the inode structure for deleted inode.
  352. * This hook is called when a deleted inode is released (i.e. an inode
  353. * with no hard links has its use count drop to zero). A security module
  354. * can use this hook to release any persistent label associated with the
  355. * inode.
  356. * @inode_setxattr:
  357. * Check permission before setting the extended attributes
  358. * @value identified by @name for @dentry.
  359. * Return 0 if permission is granted.
  360. * @inode_post_setxattr:
  361. * Update inode security field after successful setxattr operation.
  362. * @value identified by @name for @dentry.
  363. * @inode_getxattr:
  364. * Check permission before obtaining the extended attributes
  365. * identified by @name for @dentry.
  366. * Return 0 if permission is granted.
  367. * @inode_listxattr:
  368. * Check permission before obtaining the list of extended attribute
  369. * names for @dentry.
  370. * Return 0 if permission is granted.
  371. * @inode_removexattr:
  372. * Check permission before removing the extended attribute
  373. * identified by @name for @dentry.
  374. * Return 0 if permission is granted.
  375. * @inode_getsecurity:
  376. * Copy the extended attribute representation of the security label
  377. * associated with @name for @inode into @buffer. @buffer may be
  378. * NULL to request the size of the buffer required. @size indicates
  379. * the size of @buffer in bytes. Note that @name is the remainder
  380. * of the attribute name after the security. prefix has been removed.
  381. * @err is the return value from the preceding fs getxattr call,
  382. * and can be used by the security module to determine whether it
  383. * should try and canonicalize the attribute value.
  384. * Return number of bytes used/required on success.
  385. * @inode_setsecurity:
  386. * Set the security label associated with @name for @inode from the
  387. * extended attribute value @value. @size indicates the size of the
  388. * @value in bytes. @flags may be XATTR_CREATE, XATTR_REPLACE, or 0.
  389. * Note that @name is the remainder of the attribute name after the
  390. * security. prefix has been removed.
  391. * Return 0 on success.
  392. * @inode_listsecurity:
  393. * Copy the extended attribute names for the security labels
  394. * associated with @inode into @buffer. The maximum size of @buffer
  395. * is specified by @buffer_size. @buffer may be NULL to request
  396. * the size of the buffer required.
  397. * Returns number of bytes used/required on success.
  398. *
  399. * Security hooks for file operations
  400. *
  401. * @file_permission:
  402. * Check file permissions before accessing an open file. This hook is
  403. * called by various operations that read or write files. A security
  404. * module can use this hook to perform additional checking on these
  405. * operations, e.g. to revalidate permissions on use to support privilege
  406. * bracketing or policy changes. Notice that this hook is used when the
  407. * actual read/write operations are performed, whereas the
  408. * inode_security_ops hook is called when a file is opened (as well as
  409. * many other operations).
  410. * Caveat: Although this hook can be used to revalidate permissions for
  411. * various system call operations that read or write files, it does not
  412. * address the revalidation of permissions for memory-mapped files.
  413. * Security modules must handle this separately if they need such
  414. * revalidation.
  415. * @file contains the file structure being accessed.
  416. * @mask contains the requested permissions.
  417. * Return 0 if permission is granted.
  418. * @file_alloc_security:
  419. * Allocate and attach a security structure to the file->f_security field.
  420. * The security field is initialized to NULL when the structure is first
  421. * created.
  422. * @file contains the file structure to secure.
  423. * Return 0 if the hook is successful and permission is granted.
  424. * @file_free_security:
  425. * Deallocate and free any security structures stored in file->f_security.
  426. * @file contains the file structure being modified.
  427. * @file_ioctl:
  428. * @file contains the file structure.
  429. * @cmd contains the operation to perform.
  430. * @arg contains the operational arguments.
  431. * Check permission for an ioctl operation on @file. Note that @arg can
  432. * sometimes represents a user space pointer; in other cases, it may be a
  433. * simple integer value. When @arg represents a user space pointer, it
  434. * should never be used by the security module.
  435. * Return 0 if permission is granted.
  436. * @file_mmap :
  437. * Check permissions for a mmap operation. The @file may be NULL, e.g.
  438. * if mapping anonymous memory.
  439. * @file contains the file structure for file to map (may be NULL).
  440. * @reqprot contains the protection requested by the application.
  441. * @prot contains the protection that will be applied by the kernel.
  442. * @flags contains the operational flags.
  443. * Return 0 if permission is granted.
  444. * @file_mprotect:
  445. * Check permissions before changing memory access permissions.
  446. * @vma contains the memory region to modify.
  447. * @reqprot contains the protection requested by the application.
  448. * @prot contains the protection that will be applied by the kernel.
  449. * Return 0 if permission is granted.
  450. * @file_lock:
  451. * Check permission before performing file locking operations.
  452. * Note: this hook mediates both flock and fcntl style locks.
  453. * @file contains the file structure.
  454. * @cmd contains the posix-translated lock operation to perform
  455. * (e.g. F_RDLCK, F_WRLCK).
  456. * Return 0 if permission is granted.
  457. * @file_fcntl:
  458. * Check permission before allowing the file operation specified by @cmd
  459. * from being performed on the file @file. Note that @arg can sometimes
  460. * represents a user space pointer; in other cases, it may be a simple
  461. * integer value. When @arg represents a user space pointer, it should
  462. * never be used by the security module.
  463. * @file contains the file structure.
  464. * @cmd contains the operation to be performed.
  465. * @arg contains the operational arguments.
  466. * Return 0 if permission is granted.
  467. * @file_set_fowner:
  468. * Save owner security information (typically from current->security) in
  469. * file->f_security for later use by the send_sigiotask hook.
  470. * @file contains the file structure to update.
  471. * Return 0 on success.
  472. * @file_send_sigiotask:
  473. * Check permission for the file owner @fown to send SIGIO or SIGURG to the
  474. * process @tsk. Note that this hook is sometimes called from interrupt.
  475. * Note that the fown_struct, @fown, is never outside the context of a
  476. * struct file, so the file structure (and associated security information)
  477. * can always be obtained:
  478. * (struct file *)((long)fown - offsetof(struct file,f_owner));
  479. * @tsk contains the structure of task receiving signal.
  480. * @fown contains the file owner information.
  481. * @sig is the signal that will be sent. When 0, kernel sends SIGIO.
  482. * Return 0 if permission is granted.
  483. * @file_receive:
  484. * This hook allows security modules to control the ability of a process
  485. * to receive an open file descriptor via socket IPC.
  486. * @file contains the file structure being received.
  487. * Return 0 if permission is granted.
  488. *
  489. * Security hooks for task operations.
  490. *
  491. * @task_create:
  492. * Check permission before creating a child process. See the clone(2)
  493. * manual page for definitions of the @clone_flags.
  494. * @clone_flags contains the flags indicating what should be shared.
  495. * Return 0 if permission is granted.
  496. * @task_alloc_security:
  497. * @p contains the task_struct for child process.
  498. * Allocate and attach a security structure to the p->security field. The
  499. * security field is initialized to NULL when the task structure is
  500. * allocated.
  501. * Return 0 if operation was successful.
  502. * @task_free_security:
  503. * @p contains the task_struct for process.
  504. * Deallocate and clear the p->security field.
  505. * @task_setuid:
  506. * Check permission before setting one or more of the user identity
  507. * attributes of the current process. The @flags parameter indicates
  508. * which of the set*uid system calls invoked this hook and how to
  509. * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
  510. * definitions at the beginning of this file for the @flags values and
  511. * their meanings.
  512. * @id0 contains a uid.
  513. * @id1 contains a uid.
  514. * @id2 contains a uid.
  515. * @flags contains one of the LSM_SETID_* values.
  516. * Return 0 if permission is granted.
  517. * @task_post_setuid:
  518. * Update the module's state after setting one or more of the user
  519. * identity attributes of the current process. The @flags parameter
  520. * indicates which of the set*uid system calls invoked this hook. If
  521. * @flags is LSM_SETID_FS, then @old_ruid is the old fs uid and the other
  522. * parameters are not used.
  523. * @old_ruid contains the old real uid (or fs uid if LSM_SETID_FS).
  524. * @old_euid contains the old effective uid (or -1 if LSM_SETID_FS).
  525. * @old_suid contains the old saved uid (or -1 if LSM_SETID_FS).
  526. * @flags contains one of the LSM_SETID_* values.
  527. * Return 0 on success.
  528. * @task_setgid:
  529. * Check permission before setting one or more of the group identity
  530. * attributes of the current process. The @flags parameter indicates
  531. * which of the set*gid system calls invoked this hook and how to
  532. * interpret the @id0, @id1, and @id2 parameters. See the LSM_SETID
  533. * definitions at the beginning of this file for the @flags values and
  534. * their meanings.
  535. * @id0 contains a gid.
  536. * @id1 contains a gid.
  537. * @id2 contains a gid.
  538. * @flags contains one of the LSM_SETID_* values.
  539. * Return 0 if permission is granted.
  540. * @task_setpgid:
  541. * Check permission before setting the process group identifier of the
  542. * process @p to @pgid.
  543. * @p contains the task_struct for process being modified.
  544. * @pgid contains the new pgid.
  545. * Return 0 if permission is granted.
  546. * @task_getpgid:
  547. * Check permission before getting the process group identifier of the
  548. * process @p.
  549. * @p contains the task_struct for the process.
  550. * Return 0 if permission is granted.
  551. * @task_getsid:
  552. * Check permission before getting the session identifier of the process
  553. * @p.
  554. * @p contains the task_struct for the process.
  555. * Return 0 if permission is granted.
  556. * @task_getsecid:
  557. * Retrieve the security identifier of the process @p.
  558. * @p contains the task_struct for the process and place is into @secid.
  559. * @task_setgroups:
  560. * Check permission before setting the supplementary group set of the
  561. * current process.
  562. * @group_info contains the new group information.
  563. * Return 0 if permission is granted.
  564. * @task_setnice:
  565. * Check permission before setting the nice value of @p to @nice.
  566. * @p contains the task_struct of process.
  567. * @nice contains the new nice value.
  568. * Return 0 if permission is granted.
  569. * @task_setioprio
  570. * Check permission before setting the ioprio value of @p to @ioprio.
  571. * @p contains the task_struct of process.
  572. * @ioprio contains the new ioprio value
  573. * Return 0 if permission is granted.
  574. * @task_getioprio
  575. * Check permission before getting the ioprio value of @p.
  576. * @p contains the task_struct of process.
  577. * Return 0 if permission is granted.
  578. * @task_setrlimit:
  579. * Check permission before setting the resource limits of the current
  580. * process for @resource to @new_rlim. The old resource limit values can
  581. * be examined by dereferencing (current->signal->rlim + resource).
  582. * @resource contains the resource whose limit is being set.
  583. * @new_rlim contains the new limits for @resource.
  584. * Return 0 if permission is granted.
  585. * @task_setscheduler:
  586. * Check permission before setting scheduling policy and/or parameters of
  587. * process @p based on @policy and @lp.
  588. * @p contains the task_struct for process.
  589. * @policy contains the scheduling policy.
  590. * @lp contains the scheduling parameters.
  591. * Return 0 if permission is granted.
  592. * @task_getscheduler:
  593. * Check permission before obtaining scheduling information for process
  594. * @p.
  595. * @p contains the task_struct for process.
  596. * Return 0 if permission is granted.
  597. * @task_movememory
  598. * Check permission before moving memory owned by process @p.
  599. * @p contains the task_struct for process.
  600. * Return 0 if permission is granted.
  601. * @task_kill:
  602. * Check permission before sending signal @sig to @p. @info can be NULL,
  603. * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
  604. * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
  605. * from the kernel and should typically be permitted.
  606. * SIGIO signals are handled separately by the send_sigiotask hook in
  607. * file_security_ops.
  608. * @p contains the task_struct for process.
  609. * @info contains the signal information.
  610. * @sig contains the signal value.
  611. * @secid contains the sid of the process where the signal originated
  612. * Return 0 if permission is granted.
  613. * @task_wait:
  614. * Check permission before allowing a process to reap a child process @p
  615. * and collect its status information.
  616. * @p contains the task_struct for process.
  617. * Return 0 if permission is granted.
  618. * @task_prctl:
  619. * Check permission before performing a process control operation on the
  620. * current process.
  621. * @option contains the operation.
  622. * @arg2 contains a argument.
  623. * @arg3 contains a argument.
  624. * @arg4 contains a argument.
  625. * @arg5 contains a argument.
  626. * Return 0 if permission is granted.
  627. * @task_reparent_to_init:
  628. * Set the security attributes in @p->security for a kernel thread that
  629. * is being reparented to the init task.
  630. * @p contains the task_struct for the kernel thread.
  631. * @task_to_inode:
  632. * Set the security attributes for an inode based on an associated task's
  633. * security attributes, e.g. for /proc/pid inodes.
  634. * @p contains the task_struct for the task.
  635. * @inode contains the inode structure for the inode.
  636. *
  637. * Security hooks for Netlink messaging.
  638. *
  639. * @netlink_send:
  640. * Save security information for a netlink message so that permission
  641. * checking can be performed when the message is processed. The security
  642. * information can be saved using the eff_cap field of the
  643. * netlink_skb_parms structure. Also may be used to provide fine
  644. * grained control over message transmission.
  645. * @sk associated sock of task sending the message.,
  646. * @skb contains the sk_buff structure for the netlink message.
  647. * Return 0 if the information was successfully saved and message
  648. * is allowed to be transmitted.
  649. * @netlink_recv:
  650. * Check permission before processing the received netlink message in
  651. * @skb.
  652. * @skb contains the sk_buff structure for the netlink message.
  653. * @cap indicates the capability required
  654. * Return 0 if permission is granted.
  655. *
  656. * Security hooks for Unix domain networking.
  657. *
  658. * @unix_stream_connect:
  659. * Check permissions before establishing a Unix domain stream connection
  660. * between @sock and @other.
  661. * @sock contains the socket structure.
  662. * @other contains the peer socket structure.
  663. * Return 0 if permission is granted.
  664. * @unix_may_send:
  665. * Check permissions before connecting or sending datagrams from @sock to
  666. * @other.
  667. * @sock contains the socket structure.
  668. * @sock contains the peer socket structure.
  669. * Return 0 if permission is granted.
  670. *
  671. * The @unix_stream_connect and @unix_may_send hooks were necessary because
  672. * Linux provides an alternative to the conventional file name space for Unix
  673. * domain sockets. Whereas binding and connecting to sockets in the file name
  674. * space is mediated by the typical file permissions (and caught by the mknod
  675. * and permission hooks in inode_security_ops), binding and connecting to
  676. * sockets in the abstract name space is completely unmediated. Sufficient
  677. * control of Unix domain sockets in the abstract name space isn't possible
  678. * using only the socket layer hooks, since we need to know the actual target
  679. * socket, which is not looked up until we are inside the af_unix code.
  680. *
  681. * Security hooks for socket operations.
  682. *
  683. * @socket_create:
  684. * Check permissions prior to creating a new socket.
  685. * @family contains the requested protocol family.
  686. * @type contains the requested communications type.
  687. * @protocol contains the requested protocol.
  688. * @kern set to 1 if a kernel socket.
  689. * Return 0 if permission is granted.
  690. * @socket_post_create:
  691. * This hook allows a module to update or allocate a per-socket security
  692. * structure. Note that the security field was not added directly to the
  693. * socket structure, but rather, the socket security information is stored
  694. * in the associated inode. Typically, the inode alloc_security hook will
  695. * allocate and and attach security information to
  696. * sock->inode->i_security. This hook may be used to update the
  697. * sock->inode->i_security field with additional information that wasn't
  698. * available when the inode was allocated.
  699. * @sock contains the newly created socket structure.
  700. * @family contains the requested protocol family.
  701. * @type contains the requested communications type.
  702. * @protocol contains the requested protocol.
  703. * @kern set to 1 if a kernel socket.
  704. * @socket_bind:
  705. * Check permission before socket protocol layer bind operation is
  706. * performed and the socket @sock is bound to the address specified in the
  707. * @address parameter.
  708. * @sock contains the socket structure.
  709. * @address contains the address to bind to.
  710. * @addrlen contains the length of address.
  711. * Return 0 if permission is granted.
  712. * @socket_connect:
  713. * Check permission before socket protocol layer connect operation
  714. * attempts to connect socket @sock to a remote address, @address.
  715. * @sock contains the socket structure.
  716. * @address contains the address of remote endpoint.
  717. * @addrlen contains the length of address.
  718. * Return 0 if permission is granted.
  719. * @socket_listen:
  720. * Check permission before socket protocol layer listen operation.
  721. * @sock contains the socket structure.
  722. * @backlog contains the maximum length for the pending connection queue.
  723. * Return 0 if permission is granted.
  724. * @socket_accept:
  725. * Check permission before accepting a new connection. Note that the new
  726. * socket, @newsock, has been created and some information copied to it,
  727. * but the accept operation has not actually been performed.
  728. * @sock contains the listening socket structure.
  729. * @newsock contains the newly created server socket for connection.
  730. * Return 0 if permission is granted.
  731. * @socket_post_accept:
  732. * This hook allows a security module to copy security
  733. * information into the newly created socket's inode.
  734. * @sock contains the listening socket structure.
  735. * @newsock contains the newly created server socket for connection.
  736. * @socket_sendmsg:
  737. * Check permission before transmitting a message to another socket.
  738. * @sock contains the socket structure.
  739. * @msg contains the message to be transmitted.
  740. * @size contains the size of message.
  741. * Return 0 if permission is granted.
  742. * @socket_recvmsg:
  743. * Check permission before receiving a message from a socket.
  744. * @sock contains the socket structure.
  745. * @msg contains the message structure.
  746. * @size contains the size of message structure.
  747. * @flags contains the operational flags.
  748. * Return 0 if permission is granted.
  749. * @socket_getsockname:
  750. * Check permission before the local address (name) of the socket object
  751. * @sock is retrieved.
  752. * @sock contains the socket structure.
  753. * Return 0 if permission is granted.
  754. * @socket_getpeername:
  755. * Check permission before the remote address (name) of a socket object
  756. * @sock is retrieved.
  757. * @sock contains the socket structure.
  758. * Return 0 if permission is granted.
  759. * @socket_getsockopt:
  760. * Check permissions before retrieving the options associated with socket
  761. * @sock.
  762. * @sock contains the socket structure.
  763. * @level contains the protocol level to retrieve option from.
  764. * @optname contains the name of option to retrieve.
  765. * Return 0 if permission is granted.
  766. * @socket_setsockopt:
  767. * Check permissions before setting the options associated with socket
  768. * @sock.
  769. * @sock contains the socket structure.
  770. * @level contains the protocol level to set options for.
  771. * @optname contains the name of the option to set.
  772. * Return 0 if permission is granted.
  773. * @socket_shutdown:
  774. * Checks permission before all or part of a connection on the socket
  775. * @sock is shut down.
  776. * @sock contains the socket structure.
  777. * @how contains the flag indicating how future sends and receives are handled.
  778. * Return 0 if permission is granted.
  779. * @socket_sock_rcv_skb:
  780. * Check permissions on incoming network packets. This hook is distinct
  781. * from Netfilter's IP input hooks since it is the first time that the
  782. * incoming sk_buff @skb has been associated with a particular socket, @sk.
  783. * @sk contains the sock (not socket) associated with the incoming sk_buff.
  784. * @skb contains the incoming network data.
  785. * @socket_getpeersec:
  786. * This hook allows the security module to provide peer socket security
  787. * state to userspace via getsockopt SO_GETPEERSEC.
  788. * @sock is the local socket.
  789. * @optval userspace memory where the security state is to be copied.
  790. * @optlen userspace int where the module should copy the actual length
  791. * of the security state.
  792. * @len as input is the maximum length to copy to userspace provided
  793. * by the caller.
  794. * Return 0 if all is well, otherwise, typical getsockopt return
  795. * values.
  796. * @sk_alloc_security:
  797. * Allocate and attach a security structure to the sk->sk_security field,
  798. * which is used to copy security attributes between local stream sockets.
  799. * @sk_free_security:
  800. * Deallocate security structure.
  801. * @sk_getsid:
  802. * Retrieve the LSM-specific sid for the sock to enable caching of network
  803. * authorizations.
  804. *
  805. * Security hooks for XFRM operations.
  806. *
  807. * @xfrm_policy_alloc_security:
  808. * @xp contains the xfrm_policy being added to Security Policy Database
  809. * used by the XFRM system.
  810. * @sec_ctx contains the security context information being provided by
  811. * the user-level policy update program (e.g., setkey).
  812. * Allocate a security structure to the xp->security field.
  813. * The security field is initialized to NULL when the xfrm_policy is
  814. * allocated.
  815. * Return 0 if operation was successful (memory to allocate, legal context)
  816. * @xfrm_policy_clone_security:
  817. * @old contains an existing xfrm_policy in the SPD.
  818. * @new contains a new xfrm_policy being cloned from old.
  819. * Allocate a security structure to the new->security field
  820. * that contains the information from the old->security field.
  821. * Return 0 if operation was successful (memory to allocate).
  822. * @xfrm_policy_free_security:
  823. * @xp contains the xfrm_policy
  824. * Deallocate xp->security.
  825. * @xfrm_policy_delete_security:
  826. * @xp contains the xfrm_policy.
  827. * Authorize deletion of xp->security.
  828. * @xfrm_state_alloc_security:
  829. * @x contains the xfrm_state being added to the Security Association
  830. * Database by the XFRM system.
  831. * @sec_ctx contains the security context information being provided by
  832. * the user-level SA generation program (e.g., setkey or racoon).
  833. * Allocate a security structure to the x->security field. The
  834. * security field is initialized to NULL when the xfrm_state is
  835. * allocated.
  836. * Return 0 if operation was successful (memory to allocate, legal context).
  837. * @xfrm_state_free_security:
  838. * @x contains the xfrm_state.
  839. * Deallocate x->security.
  840. * @xfrm_state_delete_security:
  841. * @x contains the xfrm_state.
  842. * Authorize deletion of x->security.
  843. * @xfrm_policy_lookup:
  844. * @xp contains the xfrm_policy for which the access control is being
  845. * checked.
  846. * @sk_sid contains the sock security label that is used to authorize
  847. * access to the policy xp.
  848. * @dir contains the direction of the flow (input or output).
  849. * Check permission when a sock selects a xfrm_policy for processing
  850. * XFRMs on a packet. The hook is called when selecting either a
  851. * per-socket policy or a generic xfrm policy.
  852. * Return 0 if permission is granted.
  853. *
  854. * Security hooks affecting all Key Management operations
  855. *
  856. * @key_alloc:
  857. * Permit allocation of a key and assign security data. Note that key does
  858. * not have a serial number assigned at this point.
  859. * @key points to the key.
  860. * @flags is the allocation flags
  861. * Return 0 if permission is granted, -ve error otherwise.
  862. * @key_free:
  863. * Notification of destruction; free security data.
  864. * @key points to the key.
  865. * No return value.
  866. * @key_permission:
  867. * See whether a specific operational right is granted to a process on a
  868. * key.
  869. * @key_ref refers to the key (key pointer + possession attribute bit).
  870. * @context points to the process to provide the context against which to
  871. * evaluate the security data on the key.
  872. * @perm describes the combination of permissions required of this key.
  873. * Return 1 if permission granted, 0 if permission denied and -ve it the
  874. * normal permissions model should be effected.
  875. *
  876. * Security hooks affecting all System V IPC operations.
  877. *
  878. * @ipc_permission:
  879. * Check permissions for access to IPC
  880. * @ipcp contains the kernel IPC permission structure
  881. * @flag contains the desired (requested) permission set
  882. * Return 0 if permission is granted.
  883. *
  884. * Security hooks for individual messages held in System V IPC message queues
  885. * @msg_msg_alloc_security:
  886. * Allocate and attach a security structure to the msg->security field.
  887. * The security field is initialized to NULL when the structure is first
  888. * created.
  889. * @msg contains the message structure to be modified.
  890. * Return 0 if operation was successful and permission is granted.
  891. * @msg_msg_free_security:
  892. * Deallocate the security structure for this message.
  893. * @msg contains the message structure to be modified.
  894. *
  895. * Security hooks for System V IPC Message Queues
  896. *
  897. * @msg_queue_alloc_security:
  898. * Allocate and attach a security structure to the
  899. * msq->q_perm.security field. The security field is initialized to
  900. * NULL when the structure is first created.
  901. * @msq contains the message queue structure to be modified.
  902. * Return 0 if operation was successful and permission is granted.
  903. * @msg_queue_free_security:
  904. * Deallocate security structure for this message queue.
  905. * @msq contains the message queue structure to be modified.
  906. * @msg_queue_associate:
  907. * Check permission when a message queue is requested through the
  908. * msgget system call. This hook is only called when returning the
  909. * message queue identifier for an existing message queue, not when a
  910. * new message queue is created.
  911. * @msq contains the message queue to act upon.
  912. * @msqflg contains the operation control flags.
  913. * Return 0 if permission is granted.
  914. * @msg_queue_msgctl:
  915. * Check permission when a message control operation specified by @cmd
  916. * is to be performed on the message queue @msq.
  917. * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
  918. * @msq contains the message queue to act upon. May be NULL.
  919. * @cmd contains the operation to be performed.
  920. * Return 0 if permission is granted.
  921. * @msg_queue_msgsnd:
  922. * Check permission before a message, @msg, is enqueued on the message
  923. * queue, @msq.
  924. * @msq contains the message queue to send message to.
  925. * @msg contains the message to be enqueued.
  926. * @msqflg contains operational flags.
  927. * Return 0 if permission is granted.
  928. * @msg_queue_msgrcv:
  929. * Check permission before a message, @msg, is removed from the message
  930. * queue, @msq. The @target task structure contains a pointer to the
  931. * process that will be receiving the message (not equal to the current
  932. * process when inline receives are being performed).
  933. * @msq contains the message queue to retrieve message from.
  934. * @msg contains the message destination.
  935. * @target contains the task structure for recipient process.
  936. * @type contains the type of message requested.
  937. * @mode contains the operational flags.
  938. * Return 0 if permission is granted.
  939. *
  940. * Security hooks for System V Shared Memory Segments
  941. *
  942. * @shm_alloc_security:
  943. * Allocate and attach a security structure to the shp->shm_perm.security
  944. * field. The security field is initialized to NULL when the structure is
  945. * first created.
  946. * @shp contains the shared memory structure to be modified.
  947. * Return 0 if operation was successful and permission is granted.
  948. * @shm_free_security:
  949. * Deallocate the security struct for this memory segment.
  950. * @shp contains the shared memory structure to be modified.
  951. * @shm_associate:
  952. * Check permission when a shared memory region is requested through the
  953. * shmget system call. This hook is only called when returning the shared
  954. * memory region identifier for an existing region, not when a new shared
  955. * memory region is created.
  956. * @shp contains the shared memory structure to be modified.
  957. * @shmflg contains the operation control flags.
  958. * Return 0 if permission is granted.
  959. * @shm_shmctl:
  960. * Check permission when a shared memory control operation specified by
  961. * @cmd is to be performed on the shared memory region @shp.
  962. * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
  963. * @shp contains shared memory structure to be modified.
  964. * @cmd contains the operation to be performed.
  965. * Return 0 if permission is granted.
  966. * @shm_shmat:
  967. * Check permissions prior to allowing the shmat system call to attach the
  968. * shared memory segment @shp to the data segment of the calling process.
  969. * The attaching address is specified by @shmaddr.
  970. * @shp contains the shared memory structure to be modified.
  971. * @shmaddr contains the address to attach memory region to.
  972. * @shmflg contains the operational flags.
  973. * Return 0 if permission is granted.
  974. *
  975. * Security hooks for System V Semaphores
  976. *
  977. * @sem_alloc_security:
  978. * Allocate and attach a security structure to the sma->sem_perm.security
  979. * field. The security field is initialized to NULL when the structure is
  980. * first created.
  981. * @sma contains the semaphore structure
  982. * Return 0 if operation was successful and permission is granted.
  983. * @sem_free_security:
  984. * deallocate security struct for this semaphore
  985. * @sma contains the semaphore structure.
  986. * @sem_associate:
  987. * Check permission when a semaphore is requested through the semget
  988. * system call. This hook is only called when returning the semaphore
  989. * identifier for an existing semaphore, not when a new one must be
  990. * created.
  991. * @sma contains the semaphore structure.
  992. * @semflg contains the operation control flags.
  993. * Return 0 if permission is granted.
  994. * @sem_semctl:
  995. * Check permission when a semaphore operation specified by @cmd is to be
  996. * performed on the semaphore @sma. The @sma may be NULL, e.g. for
  997. * IPC_INFO or SEM_INFO.
  998. * @sma contains the semaphore structure. May be NULL.
  999. * @cmd contains the operation to be performed.
  1000. * Return 0 if permission is granted.
  1001. * @sem_semop
  1002. * Check permissions before performing operations on members of the
  1003. * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
  1004. * may be modified.
  1005. * @sma contains the semaphore structure.
  1006. * @sops contains the operations to perform.
  1007. * @nsops contains the number of operations to perform.
  1008. * @alter contains the flag indicating whether changes are to be made.
  1009. * Return 0 if permission is granted.
  1010. *
  1011. * @ptrace:
  1012. * Check permission before allowing the @parent process to trace the
  1013. * @child process.
  1014. * Security modules may also want to perform a process tracing check
  1015. * during an execve in the set_security or apply_creds hooks of
  1016. * binprm_security_ops if the process is being traced and its security
  1017. * attributes would be changed by the execve.
  1018. * @parent contains the task_struct structure for parent process.
  1019. * @child contains the task_struct structure for child process.
  1020. * Return 0 if permission is granted.
  1021. * @capget:
  1022. * Get the @effective, @inheritable, and @permitted capability sets for
  1023. * the @target process. The hook may also perform permission checking to
  1024. * determine if the current process is allowed to see the capability sets
  1025. * of the @target process.
  1026. * @target contains the task_struct structure for target process.
  1027. * @effective contains the effective capability set.
  1028. * @inheritable contains the inheritable capability set.
  1029. * @permitted contains the permitted capability set.
  1030. * Return 0 if the capability sets were successfully obtained.
  1031. * @capset_check:
  1032. * Check permission before setting the @effective, @inheritable, and
  1033. * @permitted capability sets for the @target process.
  1034. * Caveat: @target is also set to current if a set of processes is
  1035. * specified (i.e. all processes other than current and init or a
  1036. * particular process group). Hence, the capset_set hook may need to
  1037. * revalidate permission to the actual target process.
  1038. * @target contains the task_struct structure for target process.
  1039. * @effective contains the effective capability set.
  1040. * @inheritable contains the inheritable capability set.
  1041. * @permitted contains the permitted capability set.
  1042. * Return 0 if permission is granted.
  1043. * @capset_set:
  1044. * Set the @effective, @inheritable, and @permitted capability sets for
  1045. * the @target process. Since capset_check cannot always check permission
  1046. * to the real @target process, this hook may also perform permission
  1047. * checking to determine if the current process is allowed to set the
  1048. * capability sets of the @target process. However, this hook has no way
  1049. * of returning an error due to the structure of the sys_capset code.
  1050. * @target contains the task_struct structure for target process.
  1051. * @effective contains the effective capability set.
  1052. * @inheritable contains the inheritable capability set.
  1053. * @permitted contains the permitted capability set.
  1054. * @capable:
  1055. * Check whether the @tsk process has the @cap capability.
  1056. * @tsk contains the task_struct for the process.
  1057. * @cap contains the capability <include/linux/capability.h>.
  1058. * Return 0 if the capability is granted for @tsk.
  1059. * @acct:
  1060. * Check permission before enabling or disabling process accounting. If
  1061. * accounting is being enabled, then @file refers to the open file used to
  1062. * store accounting records. If accounting is being disabled, then @file
  1063. * is NULL.
  1064. * @file contains the file structure for the accounting file (may be NULL).
  1065. * Return 0 if permission is granted.
  1066. * @sysctl:
  1067. * Check permission before accessing the @table sysctl variable in the
  1068. * manner specified by @op.
  1069. * @table contains the ctl_table structure for the sysctl variable.
  1070. * @op contains the operation (001 = search, 002 = write, 004 = read).
  1071. * Return 0 if permission is granted.
  1072. * @syslog:
  1073. * Check permission before accessing the kernel message ring or changing
  1074. * logging to the console.
  1075. * See the syslog(2) manual page for an explanation of the @type values.
  1076. * @type contains the type of action.
  1077. * Return 0 if permission is granted.
  1078. * @settime:
  1079. * Check permission to change the system time.
  1080. * struct timespec and timezone are defined in include/linux/time.h
  1081. * @ts contains new time
  1082. * @tz contains new timezone
  1083. * Return 0 if permission is granted.
  1084. * @vm_enough_memory:
  1085. * Check permissions for allocating a new virtual mapping.
  1086. * @pages contains the number of pages.
  1087. * Return 0 if permission is granted.
  1088. *
  1089. * @register_security:
  1090. * allow module stacking.
  1091. * @name contains the name of the security module being stacked.
  1092. * @ops contains a pointer to the struct security_operations of the module to stack.
  1093. * @unregister_security:
  1094. * remove a stacked module.
  1095. * @name contains the name of the security module being unstacked.
  1096. * @ops contains a pointer to the struct security_operations of the module to unstack.
  1097. *
  1098. * @secid_to_secctx:
  1099. * Convert secid to security context.
  1100. * @secid contains the security ID.
  1101. * @secdata contains the pointer that stores the converted security context.
  1102. *
  1103. * @release_secctx:
  1104. * Release the security context.
  1105. * @secdata contains the security context.
  1106. * @seclen contains the length of the security context.
  1107. *
  1108. * This is the main security structure.
  1109. */
  1110. struct security_operations {
  1111. int (*ptrace) (struct task_struct * parent, struct task_struct * child);
  1112. int (*capget) (struct task_struct * target,
  1113. kernel_cap_t * effective,
  1114. kernel_cap_t * inheritable, kernel_cap_t * permitted);
  1115. int (*capset_check) (struct task_struct * target,
  1116. kernel_cap_t * effective,
  1117. kernel_cap_t * inheritable,
  1118. kernel_cap_t * permitted);
  1119. void (*capset_set) (struct task_struct * target,
  1120. kernel_cap_t * effective,
  1121. kernel_cap_t * inheritable,
  1122. kernel_cap_t * permitted);
  1123. int (*capable) (struct task_struct * tsk, int cap);
  1124. int (*acct) (struct file * file);
  1125. int (*sysctl) (struct ctl_table * table, int op);
  1126. int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
  1127. int (*quota_on) (struct dentry * dentry);
  1128. int (*syslog) (int type);
  1129. int (*settime) (struct timespec *ts, struct timezone *tz);
  1130. int (*vm_enough_memory) (long pages);
  1131. int (*bprm_alloc_security) (struct linux_binprm * bprm);
  1132. void (*bprm_free_security) (struct linux_binprm * bprm);
  1133. void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
  1134. void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
  1135. int (*bprm_set_security) (struct linux_binprm * bprm);
  1136. int (*bprm_check_security) (struct linux_binprm * bprm);
  1137. int (*bprm_secureexec) (struct linux_binprm * bprm);
  1138. int (*sb_alloc_security) (struct super_block * sb);
  1139. void (*sb_free_security) (struct super_block * sb);
  1140. int (*sb_copy_data)(struct file_system_type *type,
  1141. void *orig, void *copy);
  1142. int (*sb_kern_mount) (struct super_block *sb, void *data);
  1143. int (*sb_statfs) (struct dentry *dentry);
  1144. int (*sb_mount) (char *dev_name, struct nameidata * nd,
  1145. char *type, unsigned long flags, void *data);
  1146. int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
  1147. int (*sb_umount) (struct vfsmount * mnt, int flags);
  1148. void (*sb_umount_close) (struct vfsmount * mnt);
  1149. void (*sb_umount_busy) (struct vfsmount * mnt);
  1150. void (*sb_post_remount) (struct vfsmount * mnt,
  1151. unsigned long flags, void *data);
  1152. void (*sb_post_mountroot) (void);
  1153. void (*sb_post_addmount) (struct vfsmount * mnt,
  1154. struct nameidata * mountpoint_nd);
  1155. int (*sb_pivotroot) (struct nameidata * old_nd,
  1156. struct nameidata * new_nd);
  1157. void (*sb_post_pivotroot) (struct nameidata * old_nd,
  1158. struct nameidata * new_nd);
  1159. int (*inode_alloc_security) (struct inode *inode);
  1160. void (*inode_free_security) (struct inode *inode);
  1161. int (*inode_init_security) (struct inode *inode, struct inode *dir,
  1162. char **name, void **value, size_t *len);
  1163. int (*inode_create) (struct inode *dir,
  1164. struct dentry *dentry, int mode);
  1165. int (*inode_link) (struct dentry *old_dentry,
  1166. struct inode *dir, struct dentry *new_dentry);
  1167. int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
  1168. int (*inode_symlink) (struct inode *dir,
  1169. struct dentry *dentry, const char *old_name);
  1170. int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
  1171. int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
  1172. int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
  1173. int mode, dev_t dev);
  1174. int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
  1175. struct inode *new_dir, struct dentry *new_dentry);
  1176. int (*inode_readlink) (struct dentry *dentry);
  1177. int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
  1178. int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
  1179. int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
  1180. int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
  1181. void (*inode_delete) (struct inode *inode);
  1182. int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
  1183. size_t size, int flags);
  1184. void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
  1185. size_t size, int flags);
  1186. int (*inode_getxattr) (struct dentry *dentry, char *name);
  1187. int (*inode_listxattr) (struct dentry *dentry);
  1188. int (*inode_removexattr) (struct dentry *dentry, char *name);
  1189. const char *(*inode_xattr_getsuffix) (void);
  1190. int (*inode_getsecurity)(const struct inode *inode, const char *name, void *buffer, size_t size, int err);
  1191. int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
  1192. int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
  1193. int (*file_permission) (struct file * file, int mask);
  1194. int (*file_alloc_security) (struct file * file);
  1195. void (*file_free_security) (struct file * file);
  1196. int (*file_ioctl) (struct file * file, unsigned int cmd,
  1197. unsigned long arg);
  1198. int (*file_mmap) (struct file * file,
  1199. unsigned long reqprot,
  1200. unsigned long prot, unsigned long flags);
  1201. int (*file_mprotect) (struct vm_area_struct * vma,
  1202. unsigned long reqprot,
  1203. unsigned long prot);
  1204. int (*file_lock) (struct file * file, unsigned int cmd);
  1205. int (*file_fcntl) (struct file * file, unsigned int cmd,
  1206. unsigned long arg);
  1207. int (*file_set_fowner) (struct file * file);
  1208. int (*file_send_sigiotask) (struct task_struct * tsk,
  1209. struct fown_struct * fown, int sig);
  1210. int (*file_receive) (struct file * file);
  1211. int (*task_create) (unsigned long clone_flags);
  1212. int (*task_alloc_security) (struct task_struct * p);
  1213. void (*task_free_security) (struct task_struct * p);
  1214. int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
  1215. int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
  1216. uid_t old_euid, uid_t old_suid, int flags);
  1217. int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
  1218. int (*task_setpgid) (struct task_struct * p, pid_t pgid);
  1219. int (*task_getpgid) (struct task_struct * p);
  1220. int (*task_getsid) (struct task_struct * p);
  1221. void (*task_getsecid) (struct task_struct * p, u32 * secid);
  1222. int (*task_setgroups) (struct group_info *group_info);
  1223. int (*task_setnice) (struct task_struct * p, int nice);
  1224. int (*task_setioprio) (struct task_struct * p, int ioprio);
  1225. int (*task_getioprio) (struct task_struct * p);
  1226. int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
  1227. int (*task_setscheduler) (struct task_struct * p, int policy,
  1228. struct sched_param * lp);
  1229. int (*task_getscheduler) (struct task_struct * p);
  1230. int (*task_movememory) (struct task_struct * p);
  1231. int (*task_kill) (struct task_struct * p,
  1232. struct siginfo * info, int sig, u32 secid);
  1233. int (*task_wait) (struct task_struct * p);
  1234. int (*task_prctl) (int option, unsigned long arg2,
  1235. unsigned long arg3, unsigned long arg4,
  1236. unsigned long arg5);
  1237. void (*task_reparent_to_init) (struct task_struct * p);
  1238. void (*task_to_inode)(struct task_struct *p, struct inode *inode);
  1239. int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
  1240. int (*msg_msg_alloc_security) (struct msg_msg * msg);
  1241. void (*msg_msg_free_security) (struct msg_msg * msg);
  1242. int (*msg_queue_alloc_security) (struct msg_queue * msq);
  1243. void (*msg_queue_free_security) (struct msg_queue * msq);
  1244. int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
  1245. int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
  1246. int (*msg_queue_msgsnd) (struct msg_queue * msq,
  1247. struct msg_msg * msg, int msqflg);
  1248. int (*msg_queue_msgrcv) (struct msg_queue * msq,
  1249. struct msg_msg * msg,
  1250. struct task_struct * target,
  1251. long type, int mode);
  1252. int (*shm_alloc_security) (struct shmid_kernel * shp);
  1253. void (*shm_free_security) (struct shmid_kernel * shp);
  1254. int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
  1255. int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
  1256. int (*shm_shmat) (struct shmid_kernel * shp,
  1257. char __user *shmaddr, int shmflg);
  1258. int (*sem_alloc_security) (struct sem_array * sma);
  1259. void (*sem_free_security) (struct sem_array * sma);
  1260. int (*sem_associate) (struct sem_array * sma, int semflg);
  1261. int (*sem_semctl) (struct sem_array * sma, int cmd);
  1262. int (*sem_semop) (struct sem_array * sma,
  1263. struct sembuf * sops, unsigned nsops, int alter);
  1264. int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
  1265. int (*netlink_recv) (struct sk_buff * skb, int cap);
  1266. /* allow module stacking */
  1267. int (*register_security) (const char *name,
  1268. struct security_operations *ops);
  1269. int (*unregister_security) (const char *name,
  1270. struct security_operations *ops);
  1271. void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
  1272. int (*getprocattr)(struct task_struct *p, char *name, void *value, size_t size);
  1273. int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
  1274. int (*secid_to_secctx)(u32 secid, char **secdata, u32 *seclen);
  1275. void (*release_secctx)(char *secdata, u32 seclen);
  1276. #ifdef CONFIG_SECURITY_NETWORK
  1277. int (*unix_stream_connect) (struct socket * sock,
  1278. struct socket * other, struct sock * newsk);
  1279. int (*unix_may_send) (struct socket * sock, struct socket * other);
  1280. int (*socket_create) (int family, int type, int protocol, int kern);
  1281. void (*socket_post_create) (struct socket * sock, int family,
  1282. int type, int protocol, int kern);
  1283. int (*socket_bind) (struct socket * sock,
  1284. struct sockaddr * address, int addrlen);
  1285. int (*socket_connect) (struct socket * sock,
  1286. struct sockaddr * address, int addrlen);
  1287. int (*socket_listen) (struct socket * sock, int backlog);
  1288. int (*socket_accept) (struct socket * sock, struct socket * newsock);
  1289. void (*socket_post_accept) (struct socket * sock,
  1290. struct socket * newsock);
  1291. int (*socket_sendmsg) (struct socket * sock,
  1292. struct msghdr * msg, int size);
  1293. int (*socket_recvmsg) (struct socket * sock,
  1294. struct msghdr * msg, int size, int flags);
  1295. int (*socket_getsockname) (struct socket * sock);
  1296. int (*socket_getpeername) (struct socket * sock);
  1297. int (*socket_getsockopt) (struct socket * sock, int level, int optname);
  1298. int (*socket_setsockopt) (struct socket * sock, int level, int optname);
  1299. int (*socket_shutdown) (struct socket * sock, int how);
  1300. int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
  1301. int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
  1302. int (*socket_getpeersec_dgram) (struct socket *sock, struct sk_buff *skb, u32 *secid);
  1303. int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
  1304. void (*sk_free_security) (struct sock *sk);
  1305. unsigned int (*sk_getsid) (struct sock *sk, struct flowi *fl, u8 dir);
  1306. #endif /* CONFIG_SECURITY_NETWORK */
  1307. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  1308. int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx);
  1309. int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
  1310. void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
  1311. int (*xfrm_policy_delete_security) (struct xfrm_policy *xp);
  1312. int (*xfrm_state_alloc_security) (struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
  1313. void (*xfrm_state_free_security) (struct xfrm_state *x);
  1314. int (*xfrm_state_delete_security) (struct xfrm_state *x);
  1315. int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 sk_sid, u8 dir);
  1316. #endif /* CONFIG_SECURITY_NETWORK_XFRM */
  1317. /* key management security hooks */
  1318. #ifdef CONFIG_KEYS
  1319. int (*key_alloc)(struct key *key, struct task_struct *tsk, unsigned long flags);
  1320. void (*key_free)(struct key *key);
  1321. int (*key_permission)(key_ref_t key_ref,
  1322. struct task_struct *context,
  1323. key_perm_t perm);
  1324. #endif /* CONFIG_KEYS */
  1325. };
  1326. /* global variables */
  1327. extern struct security_operations *security_ops;
  1328. /* inline stuff */
  1329. static inline int security_ptrace (struct task_struct * parent, struct task_struct * child)
  1330. {
  1331. return security_ops->ptrace (parent, child);
  1332. }
  1333. static inline int security_capget (struct task_struct *target,
  1334. kernel_cap_t *effective,
  1335. kernel_cap_t *inheritable,
  1336. kernel_cap_t *permitted)
  1337. {
  1338. return security_ops->capget (target, effective, inheritable, permitted);
  1339. }
  1340. static inline int security_capset_check (struct task_struct *target,
  1341. kernel_cap_t *effective,
  1342. kernel_cap_t *inheritable,
  1343. kernel_cap_t *permitted)
  1344. {
  1345. return security_ops->capset_check (target, effective, inheritable, permitted);
  1346. }
  1347. static inline void security_capset_set (struct task_struct *target,
  1348. kernel_cap_t *effective,
  1349. kernel_cap_t *inheritable,
  1350. kernel_cap_t *permitted)
  1351. {
  1352. security_ops->capset_set (target, effective, inheritable, permitted);
  1353. }
  1354. static inline int security_capable(struct task_struct *tsk, int cap)
  1355. {
  1356. return security_ops->capable(tsk, cap);
  1357. }
  1358. static inline int security_acct (struct file *file)
  1359. {
  1360. return security_ops->acct (file);
  1361. }
  1362. static inline int security_sysctl(struct ctl_table *table, int op)
  1363. {
  1364. return security_ops->sysctl(table, op);
  1365. }
  1366. static inline int security_quotactl (int cmds, int type, int id,
  1367. struct super_block *sb)
  1368. {
  1369. return security_ops->quotactl (cmds, type, id, sb);
  1370. }
  1371. static inline int security_quota_on (struct dentry * dentry)
  1372. {
  1373. return security_ops->quota_on (dentry);
  1374. }
  1375. static inline int security_syslog(int type)
  1376. {
  1377. return security_ops->syslog(type);
  1378. }
  1379. static inline int security_settime(struct timespec *ts, struct timezone *tz)
  1380. {
  1381. return security_ops->settime(ts, tz);
  1382. }
  1383. static inline int security_vm_enough_memory(long pages)
  1384. {
  1385. return security_ops->vm_enough_memory(pages);
  1386. }
  1387. static inline int security_bprm_alloc (struct linux_binprm *bprm)
  1388. {
  1389. return security_ops->bprm_alloc_security (bprm);
  1390. }
  1391. static inline void security_bprm_free (struct linux_binprm *bprm)
  1392. {
  1393. security_ops->bprm_free_security (bprm);
  1394. }
  1395. static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
  1396. {
  1397. security_ops->bprm_apply_creds (bprm, unsafe);
  1398. }
  1399. static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
  1400. {
  1401. security_ops->bprm_post_apply_creds (bprm);
  1402. }
  1403. static inline int security_bprm_set (struct linux_binprm *bprm)
  1404. {
  1405. return security_ops->bprm_set_security (bprm);
  1406. }
  1407. static inline int security_bprm_check (struct linux_binprm *bprm)
  1408. {
  1409. return security_ops->bprm_check_security (bprm);
  1410. }
  1411. static inline int security_bprm_secureexec (struct linux_binprm *bprm)
  1412. {
  1413. return security_ops->bprm_secureexec (bprm);
  1414. }
  1415. static inline int security_sb_alloc (struct super_block *sb)
  1416. {
  1417. return security_ops->sb_alloc_security (sb);
  1418. }
  1419. static inline void security_sb_free (struct super_block *sb)
  1420. {
  1421. security_ops->sb_free_security (sb);
  1422. }
  1423. static inline int security_sb_copy_data (struct file_system_type *type,
  1424. void *orig, void *copy)
  1425. {
  1426. return security_ops->sb_copy_data (type, orig, copy);
  1427. }
  1428. static inline int security_sb_kern_mount (struct super_block *sb, void *data)
  1429. {
  1430. return security_ops->sb_kern_mount (sb, data);
  1431. }
  1432. static inline int security_sb_statfs (struct dentry *dentry)
  1433. {
  1434. return security_ops->sb_statfs (dentry);
  1435. }
  1436. static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
  1437. char *type, unsigned long flags,
  1438. void *data)
  1439. {
  1440. return security_ops->sb_mount (dev_name, nd, type, flags, data);
  1441. }
  1442. static inline int security_sb_check_sb (struct vfsmount *mnt,
  1443. struct nameidata *nd)
  1444. {
  1445. return security_ops->sb_check_sb (mnt, nd);
  1446. }
  1447. static inline int security_sb_umount (struct vfsmount *mnt, int flags)
  1448. {
  1449. return security_ops->sb_umount (mnt, flags);
  1450. }
  1451. static inline void security_sb_umount_close (struct vfsmount *mnt)
  1452. {
  1453. security_ops->sb_umount_close (mnt);
  1454. }
  1455. static inline void security_sb_umount_busy (struct vfsmount *mnt)
  1456. {
  1457. security_ops->sb_umount_busy (mnt);
  1458. }
  1459. static inline void security_sb_post_remount (struct vfsmount *mnt,
  1460. unsigned long flags, void *data)
  1461. {
  1462. security_ops->sb_post_remount (mnt, flags, data);
  1463. }
  1464. static inline void security_sb_post_mountroot (void)
  1465. {
  1466. security_ops->sb_post_mountroot ();
  1467. }
  1468. static inline void security_sb_post_addmount (struct vfsmount *mnt,
  1469. struct nameidata *mountpoint_nd)
  1470. {
  1471. security_ops->sb_post_addmount (mnt, mountpoint_nd);
  1472. }
  1473. static inline int security_sb_pivotroot (struct nameidata *old_nd,
  1474. struct nameidata *new_nd)
  1475. {
  1476. return security_ops->sb_pivotroot (old_nd, new_nd);
  1477. }
  1478. static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
  1479. struct nameidata *new_nd)
  1480. {
  1481. security_ops->sb_post_pivotroot (old_nd, new_nd);
  1482. }
  1483. static inline int security_inode_alloc (struct inode *inode)
  1484. {
  1485. return security_ops->inode_alloc_security (inode);
  1486. }
  1487. static inline void security_inode_free (struct inode *inode)
  1488. {
  1489. security_ops->inode_free_security (inode);
  1490. }
  1491. static inline int security_inode_init_security (struct inode *inode,
  1492. struct inode *dir,
  1493. char **name,
  1494. void **value,
  1495. size_t *len)
  1496. {
  1497. if (unlikely (IS_PRIVATE (inode)))
  1498. return -EOPNOTSUPP;
  1499. return security_ops->inode_init_security (inode, dir, name, value, len);
  1500. }
  1501. static inline int security_inode_create (struct inode *dir,
  1502. struct dentry *dentry,
  1503. int mode)
  1504. {
  1505. if (unlikely (IS_PRIVATE (dir)))
  1506. return 0;
  1507. return security_ops->inode_create (dir, dentry, mode);
  1508. }
  1509. static inline int security_inode_link (struct dentry *old_dentry,
  1510. struct inode *dir,
  1511. struct dentry *new_dentry)
  1512. {
  1513. if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
  1514. return 0;
  1515. return security_ops->inode_link (old_dentry, dir, new_dentry);
  1516. }
  1517. static inline int security_inode_unlink (struct inode *dir,
  1518. struct dentry *dentry)
  1519. {
  1520. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1521. return 0;
  1522. return security_ops->inode_unlink (dir, dentry);
  1523. }
  1524. static inline int security_inode_symlink (struct inode *dir,
  1525. struct dentry *dentry,
  1526. const char *old_name)
  1527. {
  1528. if (unlikely (IS_PRIVATE (dir)))
  1529. return 0;
  1530. return security_ops->inode_symlink (dir, dentry, old_name);
  1531. }
  1532. static inline int security_inode_mkdir (struct inode *dir,
  1533. struct dentry *dentry,
  1534. int mode)
  1535. {
  1536. if (unlikely (IS_PRIVATE (dir)))
  1537. return 0;
  1538. return security_ops->inode_mkdir (dir, dentry, mode);
  1539. }
  1540. static inline int security_inode_rmdir (struct inode *dir,
  1541. struct dentry *dentry)
  1542. {
  1543. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1544. return 0;
  1545. return security_ops->inode_rmdir (dir, dentry);
  1546. }
  1547. static inline int security_inode_mknod (struct inode *dir,
  1548. struct dentry *dentry,
  1549. int mode, dev_t dev)
  1550. {
  1551. if (unlikely (IS_PRIVATE (dir)))
  1552. return 0;
  1553. return security_ops->inode_mknod (dir, dentry, mode, dev);
  1554. }
  1555. static inline int security_inode_rename (struct inode *old_dir,
  1556. struct dentry *old_dentry,
  1557. struct inode *new_dir,
  1558. struct dentry *new_dentry)
  1559. {
  1560. if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
  1561. (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
  1562. return 0;
  1563. return security_ops->inode_rename (old_dir, old_dentry,
  1564. new_dir, new_dentry);
  1565. }
  1566. static inline int security_inode_readlink (struct dentry *dentry)
  1567. {
  1568. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1569. return 0;
  1570. return security_ops->inode_readlink (dentry);
  1571. }
  1572. static inline int security_inode_follow_link (struct dentry *dentry,
  1573. struct nameidata *nd)
  1574. {
  1575. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1576. return 0;
  1577. return security_ops->inode_follow_link (dentry, nd);
  1578. }
  1579. static inline int security_inode_permission (struct inode *inode, int mask,
  1580. struct nameidata *nd)
  1581. {
  1582. if (unlikely (IS_PRIVATE (inode)))
  1583. return 0;
  1584. return security_ops->inode_permission (inode, mask, nd);
  1585. }
  1586. static inline int security_inode_setattr (struct dentry *dentry,
  1587. struct iattr *attr)
  1588. {
  1589. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1590. return 0;
  1591. return security_ops->inode_setattr (dentry, attr);
  1592. }
  1593. static inline int security_inode_getattr (struct vfsmount *mnt,
  1594. struct dentry *dentry)
  1595. {
  1596. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1597. return 0;
  1598. return security_ops->inode_getattr (mnt, dentry);
  1599. }
  1600. static inline void security_inode_delete (struct inode *inode)
  1601. {
  1602. if (unlikely (IS_PRIVATE (inode)))
  1603. return;
  1604. security_ops->inode_delete (inode);
  1605. }
  1606. static inline int security_inode_setxattr (struct dentry *dentry, char *name,
  1607. void *value, size_t size, int flags)
  1608. {
  1609. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1610. return 0;
  1611. return security_ops->inode_setxattr (dentry, name, value, size, flags);
  1612. }
  1613. static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
  1614. void *value, size_t size, int flags)
  1615. {
  1616. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1617. return;
  1618. security_ops->inode_post_setxattr (dentry, name, value, size, flags);
  1619. }
  1620. static inline int security_inode_getxattr (struct dentry *dentry, char *name)
  1621. {
  1622. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1623. return 0;
  1624. return security_ops->inode_getxattr (dentry, name);
  1625. }
  1626. static inline int security_inode_listxattr (struct dentry *dentry)
  1627. {
  1628. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1629. return 0;
  1630. return security_ops->inode_listxattr (dentry);
  1631. }
  1632. static inline int security_inode_removexattr (struct dentry *dentry, char *name)
  1633. {
  1634. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1635. return 0;
  1636. return security_ops->inode_removexattr (dentry, name);
  1637. }
  1638. static inline const char *security_inode_xattr_getsuffix(void)
  1639. {
  1640. return security_ops->inode_xattr_getsuffix();
  1641. }
  1642. static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
  1643. {
  1644. if (unlikely (IS_PRIVATE (inode)))
  1645. return 0;
  1646. return security_ops->inode_getsecurity(inode, name, buffer, size, err);
  1647. }
  1648. static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
  1649. {
  1650. if (unlikely (IS_PRIVATE (inode)))
  1651. return 0;
  1652. return security_ops->inode_setsecurity(inode, name, value, size, flags);
  1653. }
  1654. static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
  1655. {
  1656. if (unlikely (IS_PRIVATE (inode)))
  1657. return 0;
  1658. return security_ops->inode_listsecurity(inode, buffer, buffer_size);
  1659. }
  1660. static inline int security_file_permission (struct file *file, int mask)
  1661. {
  1662. return security_ops->file_permission (file, mask);
  1663. }
  1664. static inline int security_file_alloc (struct file *file)
  1665. {
  1666. return security_ops->file_alloc_security (file);
  1667. }
  1668. static inline void security_file_free (struct file *file)
  1669. {
  1670. security_ops->file_free_security (file);
  1671. }
  1672. static inline int security_file_ioctl (struct file *file, unsigned int cmd,
  1673. unsigned long arg)
  1674. {
  1675. return security_ops->file_ioctl (file, cmd, arg);
  1676. }
  1677. static inline int security_file_mmap (struct file *file, unsigned long reqprot,
  1678. unsigned long prot,
  1679. unsigned long flags)
  1680. {
  1681. return security_ops->file_mmap (file, reqprot, prot, flags);
  1682. }
  1683. static inline int security_file_mprotect (struct vm_area_struct *vma,
  1684. unsigned long reqprot,
  1685. unsigned long prot)
  1686. {
  1687. return security_ops->file_mprotect (vma, reqprot, prot);
  1688. }
  1689. static inline int security_file_lock (struct file *file, unsigned int cmd)
  1690. {
  1691. return security_ops->file_lock (file, cmd);
  1692. }
  1693. static inline int security_file_fcntl (struct file *file, unsigned int cmd,
  1694. unsigned long arg)
  1695. {
  1696. return security_ops->file_fcntl (file, cmd, arg);
  1697. }
  1698. static inline int security_file_set_fowner (struct file *file)
  1699. {
  1700. return security_ops->file_set_fowner (file);
  1701. }
  1702. static inline int security_file_send_sigiotask (struct task_struct *tsk,
  1703. struct fown_struct *fown,
  1704. int sig)
  1705. {
  1706. return security_ops->file_send_sigiotask (tsk, fown, sig);
  1707. }
  1708. static inline int security_file_receive (struct file *file)
  1709. {
  1710. return security_ops->file_receive (file);
  1711. }
  1712. static inline int security_task_create (unsigned long clone_flags)
  1713. {
  1714. return security_ops->task_create (clone_flags);
  1715. }
  1716. static inline int security_task_alloc (struct task_struct *p)
  1717. {
  1718. return security_ops->task_alloc_security (p);
  1719. }
  1720. static inline void security_task_free (struct task_struct *p)
  1721. {
  1722. security_ops->task_free_security (p);
  1723. }
  1724. static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
  1725. int flags)
  1726. {
  1727. return security_ops->task_setuid (id0, id1, id2, flags);
  1728. }
  1729. static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
  1730. uid_t old_suid, int flags)
  1731. {
  1732. return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags);
  1733. }
  1734. static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
  1735. int flags)
  1736. {
  1737. return security_ops->task_setgid (id0, id1, id2, flags);
  1738. }
  1739. static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
  1740. {
  1741. return security_ops->task_setpgid (p, pgid);
  1742. }
  1743. static inline int security_task_getpgid (struct task_struct *p)
  1744. {
  1745. return security_ops->task_getpgid (p);
  1746. }
  1747. static inline int security_task_getsid (struct task_struct *p)
  1748. {
  1749. return security_ops->task_getsid (p);
  1750. }
  1751. static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
  1752. {
  1753. security_ops->task_getsecid (p, secid);
  1754. }
  1755. static inline int security_task_setgroups (struct group_info *group_info)
  1756. {
  1757. return security_ops->task_setgroups (group_info);
  1758. }
  1759. static inline int security_task_setnice (struct task_struct *p, int nice)
  1760. {
  1761. return security_ops->task_setnice (p, nice);
  1762. }
  1763. static inline int security_task_setioprio (struct task_struct *p, int ioprio)
  1764. {
  1765. return security_ops->task_setioprio (p, ioprio);
  1766. }
  1767. static inline int security_task_getioprio (struct task_struct *p)
  1768. {
  1769. return security_ops->task_getioprio (p);
  1770. }
  1771. static inline int security_task_setrlimit (unsigned int resource,
  1772. struct rlimit *new_rlim)
  1773. {
  1774. return security_ops->task_setrlimit (resource, new_rlim);
  1775. }
  1776. static inline int security_task_setscheduler (struct task_struct *p,
  1777. int policy,
  1778. struct sched_param *lp)
  1779. {
  1780. return security_ops->task_setscheduler (p, policy, lp);
  1781. }
  1782. static inline int security_task_getscheduler (struct task_struct *p)
  1783. {
  1784. return security_ops->task_getscheduler (p);
  1785. }
  1786. static inline int security_task_movememory (struct task_struct *p)
  1787. {
  1788. return security_ops->task_movememory (p);
  1789. }
  1790. static inline int security_task_kill (struct task_struct *p,
  1791. struct siginfo *info, int sig,
  1792. u32 secid)
  1793. {
  1794. return security_ops->task_kill (p, info, sig, secid);
  1795. }
  1796. static inline int security_task_wait (struct task_struct *p)
  1797. {
  1798. return security_ops->task_wait (p);
  1799. }
  1800. static inline int security_task_prctl (int option, unsigned long arg2,
  1801. unsigned long arg3,
  1802. unsigned long arg4,
  1803. unsigned long arg5)
  1804. {
  1805. return security_ops->task_prctl (option, arg2, arg3, arg4, arg5);
  1806. }
  1807. static inline void security_task_reparent_to_init (struct task_struct *p)
  1808. {
  1809. security_ops->task_reparent_to_init (p);
  1810. }
  1811. static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
  1812. {
  1813. security_ops->task_to_inode(p, inode);
  1814. }
  1815. static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
  1816. short flag)
  1817. {
  1818. return security_ops->ipc_permission (ipcp, flag);
  1819. }
  1820. static inline int security_msg_msg_alloc (struct msg_msg * msg)
  1821. {
  1822. return security_ops->msg_msg_alloc_security (msg);
  1823. }
  1824. static inline void security_msg_msg_free (struct msg_msg * msg)
  1825. {
  1826. security_ops->msg_msg_free_security(msg);
  1827. }
  1828. static inline int security_msg_queue_alloc (struct msg_queue *msq)
  1829. {
  1830. return security_ops->msg_queue_alloc_security (msq);
  1831. }
  1832. static inline void security_msg_queue_free (struct msg_queue *msq)
  1833. {
  1834. security_ops->msg_queue_free_security (msq);
  1835. }
  1836. static inline int security_msg_queue_associate (struct msg_queue * msq,
  1837. int msqflg)
  1838. {
  1839. return security_ops->msg_queue_associate (msq, msqflg);
  1840. }
  1841. static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
  1842. {
  1843. return security_ops->msg_queue_msgctl (msq, cmd);
  1844. }
  1845. static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
  1846. struct msg_msg * msg, int msqflg)
  1847. {
  1848. return security_ops->msg_queue_msgsnd (msq, msg, msqflg);
  1849. }
  1850. static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
  1851. struct msg_msg * msg,
  1852. struct task_struct * target,
  1853. long type, int mode)
  1854. {
  1855. return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode);
  1856. }
  1857. static inline int security_shm_alloc (struct shmid_kernel *shp)
  1858. {
  1859. return security_ops->shm_alloc_security (shp);
  1860. }
  1861. static inline void security_shm_free (struct shmid_kernel *shp)
  1862. {
  1863. security_ops->shm_free_security (shp);
  1864. }
  1865. static inline int security_shm_associate (struct shmid_kernel * shp,
  1866. int shmflg)
  1867. {
  1868. return security_ops->shm_associate(shp, shmflg);
  1869. }
  1870. static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
  1871. {
  1872. return security_ops->shm_shmctl (shp, cmd);
  1873. }
  1874. static inline int security_shm_shmat (struct shmid_kernel * shp,
  1875. char __user *shmaddr, int shmflg)
  1876. {
  1877. return security_ops->shm_shmat(shp, shmaddr, shmflg);
  1878. }
  1879. static inline int security_sem_alloc (struct sem_array *sma)
  1880. {
  1881. return security_ops->sem_alloc_security (sma);
  1882. }
  1883. static inline void security_sem_free (struct sem_array *sma)
  1884. {
  1885. security_ops->sem_free_security (sma);
  1886. }
  1887. static inline int security_sem_associate (struct sem_array * sma, int semflg)
  1888. {
  1889. return security_ops->sem_associate (sma, semflg);
  1890. }
  1891. static inline int security_sem_semctl (struct sem_array * sma, int cmd)
  1892. {
  1893. return security_ops->sem_semctl(sma, cmd);
  1894. }
  1895. static inline int security_sem_semop (struct sem_array * sma,
  1896. struct sembuf * sops, unsigned nsops,
  1897. int alter)
  1898. {
  1899. return security_ops->sem_semop(sma, sops, nsops, alter);
  1900. }
  1901. static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
  1902. {
  1903. if (unlikely (inode && IS_PRIVATE (inode)))
  1904. return;
  1905. security_ops->d_instantiate (dentry, inode);
  1906. }
  1907. static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
  1908. {
  1909. return security_ops->getprocattr(p, name, value, size);
  1910. }
  1911. static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
  1912. {
  1913. return security_ops->setprocattr(p, name, value, size);
  1914. }
  1915. static inline int security_netlink_send(struct sock *sk, struct sk_buff * skb)
  1916. {
  1917. return security_ops->netlink_send(sk, skb);
  1918. }
  1919. static inline int security_netlink_recv(struct sk_buff * skb, int cap)
  1920. {
  1921. return security_ops->netlink_recv(skb, cap);
  1922. }
  1923. static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
  1924. {
  1925. return security_ops->secid_to_secctx(secid, secdata, seclen);
  1926. }
  1927. static inline void security_release_secctx(char *secdata, u32 seclen)
  1928. {
  1929. return security_ops->release_secctx(secdata, seclen);
  1930. }
  1931. /* prototypes */
  1932. extern int security_init (void);
  1933. extern int register_security (struct security_operations *ops);
  1934. extern int unregister_security (struct security_operations *ops);
  1935. extern int mod_reg_security (const char *name, struct security_operations *ops);
  1936. extern int mod_unreg_security (const char *name, struct security_operations *ops);
  1937. extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
  1938. struct dentry *parent, void *data,
  1939. struct file_operations *fops);
  1940. extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
  1941. extern void securityfs_remove(struct dentry *dentry);
  1942. #else /* CONFIG_SECURITY */
  1943. /*
  1944. * This is the default capabilities functionality. Most of these functions
  1945. * are just stubbed out, but a few must call the proper capable code.
  1946. */
  1947. static inline int security_init(void)
  1948. {
  1949. return 0;
  1950. }
  1951. static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
  1952. {
  1953. return cap_ptrace (parent, child);
  1954. }
  1955. static inline int security_capget (struct task_struct *target,
  1956. kernel_cap_t *effective,
  1957. kernel_cap_t *inheritable,
  1958. kernel_cap_t *permitted)
  1959. {
  1960. return cap_capget (target, effective, inheritable, permitted);
  1961. }
  1962. static inline int security_capset_check (struct task_struct *target,
  1963. kernel_cap_t *effective,
  1964. kernel_cap_t *inheritable,
  1965. kernel_cap_t *permitted)
  1966. {
  1967. return cap_capset_check (target, effective, inheritable, permitted);
  1968. }
  1969. static inline void security_capset_set (struct task_struct *target,
  1970. kernel_cap_t *effective,
  1971. kernel_cap_t *inheritable,
  1972. kernel_cap_t *permitted)
  1973. {
  1974. cap_capset_set (target, effective, inheritable, permitted);
  1975. }
  1976. static inline int security_capable(struct task_struct *tsk, int cap)
  1977. {
  1978. return cap_capable(tsk, cap);
  1979. }
  1980. static inline int security_acct (struct file *file)
  1981. {
  1982. return 0;
  1983. }
  1984. static inline int security_sysctl(struct ctl_table *table, int op)
  1985. {
  1986. return 0;
  1987. }
  1988. static inline int security_quotactl (int cmds, int type, int id,
  1989. struct super_block * sb)
  1990. {
  1991. return 0;
  1992. }
  1993. static inline int security_quota_on (struct dentry * dentry)
  1994. {
  1995. return 0;
  1996. }
  1997. static inline int security_syslog(int type)
  1998. {
  1999. return cap_syslog(type);
  2000. }
  2001. static inline int security_settime(struct timespec *ts, struct timezone *tz)
  2002. {
  2003. return cap_settime(ts, tz);
  2004. }
  2005. static inline int security_vm_enough_memory(long pages)
  2006. {
  2007. return cap_vm_enough_memory(pages);
  2008. }
  2009. static inline int security_bprm_alloc (struct linux_binprm *bprm)
  2010. {
  2011. return 0;
  2012. }
  2013. static inline void security_bprm_free (struct linux_binprm *bprm)
  2014. { }
  2015. static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
  2016. {
  2017. cap_bprm_apply_creds (bprm, unsafe);
  2018. }
  2019. static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
  2020. {
  2021. return;
  2022. }
  2023. static inline int security_bprm_set (struct linux_binprm *bprm)
  2024. {
  2025. return cap_bprm_set_security (bprm);
  2026. }
  2027. static inline int security_bprm_check (struct linux_binprm *bprm)
  2028. {
  2029. return 0;
  2030. }
  2031. static inline int security_bprm_secureexec (struct linux_binprm *bprm)
  2032. {
  2033. return cap_bprm_secureexec(bprm);
  2034. }
  2035. static inline int security_sb_alloc (struct super_block *sb)
  2036. {
  2037. return 0;
  2038. }
  2039. static inline void security_sb_free (struct super_block *sb)
  2040. { }
  2041. static inline int security_sb_copy_data (struct file_system_type *type,
  2042. void *orig, void *copy)
  2043. {
  2044. return 0;
  2045. }
  2046. static inline int security_sb_kern_mount (struct super_block *sb, void *data)
  2047. {
  2048. return 0;
  2049. }
  2050. static inline int security_sb_statfs (struct dentry *dentry)
  2051. {
  2052. return 0;
  2053. }
  2054. static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
  2055. char *type, unsigned long flags,
  2056. void *data)
  2057. {
  2058. return 0;
  2059. }
  2060. static inline int security_sb_check_sb (struct vfsmount *mnt,
  2061. struct nameidata *nd)
  2062. {
  2063. return 0;
  2064. }
  2065. static inline int security_sb_umount (struct vfsmount *mnt, int flags)
  2066. {
  2067. return 0;
  2068. }
  2069. static inline void security_sb_umount_close (struct vfsmount *mnt)
  2070. { }
  2071. static inline void security_sb_umount_busy (struct vfsmount *mnt)
  2072. { }
  2073. static inline void security_sb_post_remount (struct vfsmount *mnt,
  2074. unsigned long flags, void *data)
  2075. { }
  2076. static inline void security_sb_post_mountroot (void)
  2077. { }
  2078. static inline void security_sb_post_addmount (struct vfsmount *mnt,
  2079. struct nameidata *mountpoint_nd)
  2080. { }
  2081. static inline int security_sb_pivotroot (struct nameidata *old_nd,
  2082. struct nameidata *new_nd)
  2083. {
  2084. return 0;
  2085. }
  2086. static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
  2087. struct nameidata *new_nd)
  2088. { }
  2089. static inline int security_inode_alloc (struct inode *inode)
  2090. {
  2091. return 0;
  2092. }
  2093. static inline void security_inode_free (struct inode *inode)
  2094. { }
  2095. static inline int security_inode_init_security (struct inode *inode,
  2096. struct inode *dir,
  2097. char **name,
  2098. void **value,
  2099. size_t *len)
  2100. {
  2101. return -EOPNOTSUPP;
  2102. }
  2103. static inline int security_inode_create (struct inode *dir,
  2104. struct dentry *dentry,
  2105. int mode)
  2106. {
  2107. return 0;
  2108. }
  2109. static inline int security_inode_link (struct dentry *old_dentry,
  2110. struct inode *dir,
  2111. struct dentry *new_dentry)
  2112. {
  2113. return 0;
  2114. }
  2115. static inline int security_inode_unlink (struct inode *dir,
  2116. struct dentry *dentry)
  2117. {
  2118. return 0;
  2119. }
  2120. static inline int security_inode_symlink (struct inode *dir,
  2121. struct dentry *dentry,
  2122. const char *old_name)
  2123. {
  2124. return 0;
  2125. }
  2126. static inline int security_inode_mkdir (struct inode *dir,
  2127. struct dentry *dentry,
  2128. int mode)
  2129. {
  2130. return 0;
  2131. }
  2132. static inline int security_inode_rmdir (struct inode *dir,
  2133. struct dentry *dentry)
  2134. {
  2135. return 0;
  2136. }
  2137. static inline int security_inode_mknod (struct inode *dir,
  2138. struct dentry *dentry,
  2139. int mode, dev_t dev)
  2140. {
  2141. return 0;
  2142. }
  2143. static inline int security_inode_rename (struct inode *old_dir,
  2144. struct dentry *old_dentry,
  2145. struct inode *new_dir,
  2146. struct dentry *new_dentry)
  2147. {
  2148. return 0;
  2149. }
  2150. static inline int security_inode_readlink (struct dentry *dentry)
  2151. {
  2152. return 0;
  2153. }
  2154. static inline int security_inode_follow_link (struct dentry *dentry,
  2155. struct nameidata *nd)
  2156. {
  2157. return 0;
  2158. }
  2159. static inline int security_inode_permission (struct inode *inode, int mask,
  2160. struct nameidata *nd)
  2161. {
  2162. return 0;
  2163. }
  2164. static inline int security_inode_setattr (struct dentry *dentry,
  2165. struct iattr *attr)
  2166. {
  2167. return 0;
  2168. }
  2169. static inline int security_inode_getattr (struct vfsmount *mnt,
  2170. struct dentry *dentry)
  2171. {
  2172. return 0;
  2173. }
  2174. static inline void security_inode_delete (struct inode *inode)
  2175. { }
  2176. static inline int security_inode_setxattr (struct dentry *dentry, char *name,
  2177. void *value, size_t size, int flags)
  2178. {
  2179. return cap_inode_setxattr(dentry, name, value, size, flags);
  2180. }
  2181. static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
  2182. void *value, size_t size, int flags)
  2183. { }
  2184. static inline int security_inode_getxattr (struct dentry *dentry, char *name)
  2185. {
  2186. return 0;
  2187. }
  2188. static inline int security_inode_listxattr (struct dentry *dentry)
  2189. {
  2190. return 0;
  2191. }
  2192. static inline int security_inode_removexattr (struct dentry *dentry, char *name)
  2193. {
  2194. return cap_inode_removexattr(dentry, name);
  2195. }
  2196. static inline const char *security_inode_xattr_getsuffix (void)
  2197. {
  2198. return NULL ;
  2199. }
  2200. static inline int security_inode_getsecurity(const struct inode *inode, const char *name, void *buffer, size_t size, int err)
  2201. {
  2202. return -EOPNOTSUPP;
  2203. }
  2204. static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
  2205. {
  2206. return -EOPNOTSUPP;
  2207. }
  2208. static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
  2209. {
  2210. return 0;
  2211. }
  2212. static inline int security_file_permission (struct file *file, int mask)
  2213. {
  2214. return 0;
  2215. }
  2216. static inline int security_file_alloc (struct file *file)
  2217. {
  2218. return 0;
  2219. }
  2220. static inline void security_file_free (struct file *file)
  2221. { }
  2222. static inline int security_file_ioctl (struct file *file, unsigned int cmd,
  2223. unsigned long arg)
  2224. {
  2225. return 0;
  2226. }
  2227. static inline int security_file_mmap (struct file *file, unsigned long reqprot,
  2228. unsigned long prot,
  2229. unsigned long flags)
  2230. {
  2231. return 0;
  2232. }
  2233. static inline int security_file_mprotect (struct vm_area_struct *vma,
  2234. unsigned long reqprot,
  2235. unsigned long prot)
  2236. {
  2237. return 0;
  2238. }
  2239. static inline int security_file_lock (struct file *file, unsigned int cmd)
  2240. {
  2241. return 0;
  2242. }
  2243. static inline int security_file_fcntl (struct file *file, unsigned int cmd,
  2244. unsigned long arg)
  2245. {
  2246. return 0;
  2247. }
  2248. static inline int security_file_set_fowner (struct file *file)
  2249. {
  2250. return 0;
  2251. }
  2252. static inline int security_file_send_sigiotask (struct task_struct *tsk,
  2253. struct fown_struct *fown,
  2254. int sig)
  2255. {
  2256. return 0;
  2257. }
  2258. static inline int security_file_receive (struct file *file)
  2259. {
  2260. return 0;
  2261. }
  2262. static inline int security_task_create (unsigned long clone_flags)
  2263. {
  2264. return 0;
  2265. }
  2266. static inline int security_task_alloc (struct task_struct *p)
  2267. {
  2268. return 0;
  2269. }
  2270. static inline void security_task_free (struct task_struct *p)
  2271. { }
  2272. static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
  2273. int flags)
  2274. {
  2275. return 0;
  2276. }
  2277. static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
  2278. uid_t old_suid, int flags)
  2279. {
  2280. return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
  2281. }
  2282. static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
  2283. int flags)
  2284. {
  2285. return 0;
  2286. }
  2287. static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
  2288. {
  2289. return 0;
  2290. }
  2291. static inline int security_task_getpgid (struct task_struct *p)
  2292. {
  2293. return 0;
  2294. }
  2295. static inline int security_task_getsid (struct task_struct *p)
  2296. {
  2297. return 0;
  2298. }
  2299. static inline void security_task_getsecid (struct task_struct *p, u32 *secid)
  2300. { }
  2301. static inline int security_task_setgroups (struct group_info *group_info)
  2302. {
  2303. return 0;
  2304. }
  2305. static inline int security_task_setnice (struct task_struct *p, int nice)
  2306. {
  2307. return 0;
  2308. }
  2309. static inline int security_task_setioprio (struct task_struct *p, int ioprio)
  2310. {
  2311. return 0;
  2312. }
  2313. static inline int security_task_getioprio (struct task_struct *p)
  2314. {
  2315. return 0;
  2316. }
  2317. static inline int security_task_setrlimit (unsigned int resource,
  2318. struct rlimit *new_rlim)
  2319. {
  2320. return 0;
  2321. }
  2322. static inline int security_task_setscheduler (struct task_struct *p,
  2323. int policy,
  2324. struct sched_param *lp)
  2325. {
  2326. return 0;
  2327. }
  2328. static inline int security_task_getscheduler (struct task_struct *p)
  2329. {
  2330. return 0;
  2331. }
  2332. static inline int security_task_movememory (struct task_struct *p)
  2333. {
  2334. return 0;
  2335. }
  2336. static inline int security_task_kill (struct task_struct *p,
  2337. struct siginfo *info, int sig,
  2338. u32 secid)
  2339. {
  2340. return 0;
  2341. }
  2342. static inline int security_task_wait (struct task_struct *p)
  2343. {
  2344. return 0;
  2345. }
  2346. static inline int security_task_prctl (int option, unsigned long arg2,
  2347. unsigned long arg3,
  2348. unsigned long arg4,
  2349. unsigned long arg5)
  2350. {
  2351. return 0;
  2352. }
  2353. static inline void security_task_reparent_to_init (struct task_struct *p)
  2354. {
  2355. cap_task_reparent_to_init (p);
  2356. }
  2357. static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
  2358. { }
  2359. static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
  2360. short flag)
  2361. {
  2362. return 0;
  2363. }
  2364. static inline int security_msg_msg_alloc (struct msg_msg * msg)
  2365. {
  2366. return 0;
  2367. }
  2368. static inline void security_msg_msg_free (struct msg_msg * msg)
  2369. { }
  2370. static inline int security_msg_queue_alloc (struct msg_queue *msq)
  2371. {
  2372. return 0;
  2373. }
  2374. static inline void security_msg_queue_free (struct msg_queue *msq)
  2375. { }
  2376. static inline int security_msg_queue_associate (struct msg_queue * msq,
  2377. int msqflg)
  2378. {
  2379. return 0;
  2380. }
  2381. static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
  2382. {
  2383. return 0;
  2384. }
  2385. static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
  2386. struct msg_msg * msg, int msqflg)
  2387. {
  2388. return 0;
  2389. }
  2390. static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
  2391. struct msg_msg * msg,
  2392. struct task_struct * target,
  2393. long type, int mode)
  2394. {
  2395. return 0;
  2396. }
  2397. static inline int security_shm_alloc (struct shmid_kernel *shp)
  2398. {
  2399. return 0;
  2400. }
  2401. static inline void security_shm_free (struct shmid_kernel *shp)
  2402. { }
  2403. static inline int security_shm_associate (struct shmid_kernel * shp,
  2404. int shmflg)
  2405. {
  2406. return 0;
  2407. }
  2408. static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
  2409. {
  2410. return 0;
  2411. }
  2412. static inline int security_shm_shmat (struct shmid_kernel * shp,
  2413. char __user *shmaddr, int shmflg)
  2414. {
  2415. return 0;
  2416. }
  2417. static inline int security_sem_alloc (struct sem_array *sma)
  2418. {
  2419. return 0;
  2420. }
  2421. static inline void security_sem_free (struct sem_array *sma)
  2422. { }
  2423. static inline int security_sem_associate (struct sem_array * sma, int semflg)
  2424. {
  2425. return 0;
  2426. }
  2427. static inline int security_sem_semctl (struct sem_array * sma, int cmd)
  2428. {
  2429. return 0;
  2430. }
  2431. static inline int security_sem_semop (struct sem_array * sma,
  2432. struct sembuf * sops, unsigned nsops,
  2433. int alter)
  2434. {
  2435. return 0;
  2436. }
  2437. static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
  2438. { }
  2439. static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
  2440. {
  2441. return -EINVAL;
  2442. }
  2443. static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
  2444. {
  2445. return -EINVAL;
  2446. }
  2447. static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
  2448. {
  2449. return cap_netlink_send (sk, skb);
  2450. }
  2451. static inline int security_netlink_recv (struct sk_buff *skb, int cap)
  2452. {
  2453. return cap_netlink_recv (skb, cap);
  2454. }
  2455. static inline struct dentry *securityfs_create_dir(const char *name,
  2456. struct dentry *parent)
  2457. {
  2458. return ERR_PTR(-ENODEV);
  2459. }
  2460. static inline struct dentry *securityfs_create_file(const char *name,
  2461. mode_t mode,
  2462. struct dentry *parent,
  2463. void *data,
  2464. struct file_operations *fops)
  2465. {
  2466. return ERR_PTR(-ENODEV);
  2467. }
  2468. static inline void securityfs_remove(struct dentry *dentry)
  2469. {
  2470. }
  2471. static inline int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
  2472. {
  2473. return -EOPNOTSUPP;
  2474. }
  2475. static inline void security_release_secctx(char *secdata, u32 seclen)
  2476. {
  2477. }
  2478. #endif /* CONFIG_SECURITY */
  2479. #ifdef CONFIG_SECURITY_NETWORK
  2480. static inline int security_unix_stream_connect(struct socket * sock,
  2481. struct socket * other,
  2482. struct sock * newsk)
  2483. {
  2484. return security_ops->unix_stream_connect(sock, other, newsk);
  2485. }
  2486. static inline int security_unix_may_send(struct socket * sock,
  2487. struct socket * other)
  2488. {
  2489. return security_ops->unix_may_send(sock, other);
  2490. }
  2491. static inline int security_socket_create (int family, int type,
  2492. int protocol, int kern)
  2493. {
  2494. return security_ops->socket_create(family, type, protocol, kern);
  2495. }
  2496. static inline void security_socket_post_create(struct socket * sock,
  2497. int family,
  2498. int type,
  2499. int protocol, int kern)
  2500. {
  2501. security_ops->socket_post_create(sock, family, type,
  2502. protocol, kern);
  2503. }
  2504. static inline int security_socket_bind(struct socket * sock,
  2505. struct sockaddr * address,
  2506. int addrlen)
  2507. {
  2508. return security_ops->socket_bind(sock, address, addrlen);
  2509. }
  2510. static inline int security_socket_connect(struct socket * sock,
  2511. struct sockaddr * address,
  2512. int addrlen)
  2513. {
  2514. return security_ops->socket_connect(sock, address, addrlen);
  2515. }
  2516. static inline int security_socket_listen(struct socket * sock, int backlog)
  2517. {
  2518. return security_ops->socket_listen(sock, backlog);
  2519. }
  2520. static inline int security_socket_accept(struct socket * sock,
  2521. struct socket * newsock)
  2522. {
  2523. return security_ops->socket_accept(sock, newsock);
  2524. }
  2525. static inline void security_socket_post_accept(struct socket * sock,
  2526. struct socket * newsock)
  2527. {
  2528. security_ops->socket_post_accept(sock, newsock);
  2529. }
  2530. static inline int security_socket_sendmsg(struct socket * sock,
  2531. struct msghdr * msg, int size)
  2532. {
  2533. return security_ops->socket_sendmsg(sock, msg, size);
  2534. }
  2535. static inline int security_socket_recvmsg(struct socket * sock,
  2536. struct msghdr * msg, int size,
  2537. int flags)
  2538. {
  2539. return security_ops->socket_recvmsg(sock, msg, size, flags);
  2540. }
  2541. static inline int security_socket_getsockname(struct socket * sock)
  2542. {
  2543. return security_ops->socket_getsockname(sock);
  2544. }
  2545. static inline int security_socket_getpeername(struct socket * sock)
  2546. {
  2547. return security_ops->socket_getpeername(sock);
  2548. }
  2549. static inline int security_socket_getsockopt(struct socket * sock,
  2550. int level, int optname)
  2551. {
  2552. return security_ops->socket_getsockopt(sock, level, optname);
  2553. }
  2554. static inline int security_socket_setsockopt(struct socket * sock,
  2555. int level, int optname)
  2556. {
  2557. return security_ops->socket_setsockopt(sock, level, optname);
  2558. }
  2559. static inline int security_socket_shutdown(struct socket * sock, int how)
  2560. {
  2561. return security_ops->socket_shutdown(sock, how);
  2562. }
  2563. static inline int security_sock_rcv_skb (struct sock * sk,
  2564. struct sk_buff * skb)
  2565. {
  2566. return security_ops->socket_sock_rcv_skb (sk, skb);
  2567. }
  2568. static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
  2569. int __user *optlen, unsigned len)
  2570. {
  2571. return security_ops->socket_getpeersec_stream(sock, optval, optlen, len);
  2572. }
  2573. static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
  2574. {
  2575. return security_ops->socket_getpeersec_dgram(sock, skb, secid);
  2576. }
  2577. static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
  2578. {
  2579. return security_ops->sk_alloc_security(sk, family, priority);
  2580. }
  2581. static inline void security_sk_free(struct sock *sk)
  2582. {
  2583. return security_ops->sk_free_security(sk);
  2584. }
  2585. static inline unsigned int security_sk_sid(struct sock *sk, struct flowi *fl, u8 dir)
  2586. {
  2587. return security_ops->sk_getsid(sk, fl, dir);
  2588. }
  2589. #else /* CONFIG_SECURITY_NETWORK */
  2590. static inline int security_unix_stream_connect(struct socket * sock,
  2591. struct socket * other,
  2592. struct sock * newsk)
  2593. {
  2594. return 0;
  2595. }
  2596. static inline int security_unix_may_send(struct socket * sock,
  2597. struct socket * other)
  2598. {
  2599. return 0;
  2600. }
  2601. static inline int security_socket_create (int family, int type,
  2602. int protocol, int kern)
  2603. {
  2604. return 0;
  2605. }
  2606. static inline void security_socket_post_create(struct socket * sock,
  2607. int family,
  2608. int type,
  2609. int protocol, int kern)
  2610. {
  2611. }
  2612. static inline int security_socket_bind(struct socket * sock,
  2613. struct sockaddr * address,
  2614. int addrlen)
  2615. {
  2616. return 0;
  2617. }
  2618. static inline int security_socket_connect(struct socket * sock,
  2619. struct sockaddr * address,
  2620. int addrlen)
  2621. {
  2622. return 0;
  2623. }
  2624. static inline int security_socket_listen(struct socket * sock, int backlog)
  2625. {
  2626. return 0;
  2627. }
  2628. static inline int security_socket_accept(struct socket * sock,
  2629. struct socket * newsock)
  2630. {
  2631. return 0;
  2632. }
  2633. static inline void security_socket_post_accept(struct socket * sock,
  2634. struct socket * newsock)
  2635. {
  2636. }
  2637. static inline int security_socket_sendmsg(struct socket * sock,
  2638. struct msghdr * msg, int size)
  2639. {
  2640. return 0;
  2641. }
  2642. static inline int security_socket_recvmsg(struct socket * sock,
  2643. struct msghdr * msg, int size,
  2644. int flags)
  2645. {
  2646. return 0;
  2647. }
  2648. static inline int security_socket_getsockname(struct socket * sock)
  2649. {
  2650. return 0;
  2651. }
  2652. static inline int security_socket_getpeername(struct socket * sock)
  2653. {
  2654. return 0;
  2655. }
  2656. static inline int security_socket_getsockopt(struct socket * sock,
  2657. int level, int optname)
  2658. {
  2659. return 0;
  2660. }
  2661. static inline int security_socket_setsockopt(struct socket * sock,
  2662. int level, int optname)
  2663. {
  2664. return 0;
  2665. }
  2666. static inline int security_socket_shutdown(struct socket * sock, int how)
  2667. {
  2668. return 0;
  2669. }
  2670. static inline int security_sock_rcv_skb (struct sock * sk,
  2671. struct sk_buff * skb)
  2672. {
  2673. return 0;
  2674. }
  2675. static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
  2676. int __user *optlen, unsigned len)
  2677. {
  2678. return -ENOPROTOOPT;
  2679. }
  2680. static inline int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
  2681. {
  2682. return -ENOPROTOOPT;
  2683. }
  2684. static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
  2685. {
  2686. return 0;
  2687. }
  2688. static inline void security_sk_free(struct sock *sk)
  2689. {
  2690. }
  2691. static inline unsigned int security_sk_sid(struct sock *sk, struct flowi *fl, u8 dir)
  2692. {
  2693. return 0;
  2694. }
  2695. #endif /* CONFIG_SECURITY_NETWORK */
  2696. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  2697. static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
  2698. {
  2699. return security_ops->xfrm_policy_alloc_security(xp, sec_ctx);
  2700. }
  2701. static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
  2702. {
  2703. return security_ops->xfrm_policy_clone_security(old, new);
  2704. }
  2705. static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
  2706. {
  2707. security_ops->xfrm_policy_free_security(xp);
  2708. }
  2709. static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
  2710. {
  2711. return security_ops->xfrm_policy_delete_security(xp);
  2712. }
  2713. static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx)
  2714. {
  2715. return security_ops->xfrm_state_alloc_security(x, sec_ctx);
  2716. }
  2717. static inline int security_xfrm_state_delete(struct xfrm_state *x)
  2718. {
  2719. return security_ops->xfrm_state_delete_security(x);
  2720. }
  2721. static inline void security_xfrm_state_free(struct xfrm_state *x)
  2722. {
  2723. security_ops->xfrm_state_free_security(x);
  2724. }
  2725. static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir)
  2726. {
  2727. return security_ops->xfrm_policy_lookup(xp, sk_sid, dir);
  2728. }
  2729. #else /* CONFIG_SECURITY_NETWORK_XFRM */
  2730. static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
  2731. {
  2732. return 0;
  2733. }
  2734. static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
  2735. {
  2736. return 0;
  2737. }
  2738. static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
  2739. {
  2740. }
  2741. static inline int security_xfrm_policy_delete(struct xfrm_policy *xp)
  2742. {
  2743. return 0;
  2744. }
  2745. static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx)
  2746. {
  2747. return 0;
  2748. }
  2749. static inline void security_xfrm_state_free(struct xfrm_state *x)
  2750. {
  2751. }
  2752. static inline int security_xfrm_state_delete(struct xfrm_state *x)
  2753. {
  2754. return 0;
  2755. }
  2756. static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir)
  2757. {
  2758. return 0;
  2759. }
  2760. #endif /* CONFIG_SECURITY_NETWORK_XFRM */
  2761. #ifdef CONFIG_KEYS
  2762. #ifdef CONFIG_SECURITY
  2763. static inline int security_key_alloc(struct key *key,
  2764. struct task_struct *tsk,
  2765. unsigned long flags)
  2766. {
  2767. return security_ops->key_alloc(key, tsk, flags);
  2768. }
  2769. static inline void security_key_free(struct key *key)
  2770. {
  2771. security_ops->key_free(key);
  2772. }
  2773. static inline int security_key_permission(key_ref_t key_ref,
  2774. struct task_struct *context,
  2775. key_perm_t perm)
  2776. {
  2777. return security_ops->key_permission(key_ref, context, perm);
  2778. }
  2779. #else
  2780. static inline int security_key_alloc(struct key *key,
  2781. struct task_struct *tsk,
  2782. unsigned long flags)
  2783. {
  2784. return 0;
  2785. }
  2786. static inline void security_key_free(struct key *key)
  2787. {
  2788. }
  2789. static inline int security_key_permission(key_ref_t key_ref,
  2790. struct task_struct *context,
  2791. key_perm_t perm)
  2792. {
  2793. return 0;
  2794. }
  2795. #endif
  2796. #endif /* CONFIG_KEYS */
  2797. #endif /* ! __LINUX_SECURITY_H */