security.h 100 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011
  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);
  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 @sb
  161. * filesystem.
  162. * @sb contains the super_block structure 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_setgroups:
  557. * Check permission before setting the supplementary group set of the
  558. * current process.
  559. * @group_info contains the new group information.
  560. * Return 0 if permission is granted.
  561. * @task_setnice:
  562. * Check permission before setting the nice value of @p to @nice.
  563. * @p contains the task_struct of process.
  564. * @nice contains the new nice value.
  565. * Return 0 if permission is granted.
  566. * @task_setrlimit:
  567. * Check permission before setting the resource limits of the current
  568. * process for @resource to @new_rlim. The old resource limit values can
  569. * be examined by dereferencing (current->signal->rlim + resource).
  570. * @resource contains the resource whose limit is being set.
  571. * @new_rlim contains the new limits for @resource.
  572. * Return 0 if permission is granted.
  573. * @task_setscheduler:
  574. * Check permission before setting scheduling policy and/or parameters of
  575. * process @p based on @policy and @lp.
  576. * @p contains the task_struct for process.
  577. * @policy contains the scheduling policy.
  578. * @lp contains the scheduling parameters.
  579. * Return 0 if permission is granted.
  580. * @task_getscheduler:
  581. * Check permission before obtaining scheduling information for process
  582. * @p.
  583. * @p contains the task_struct for process.
  584. * Return 0 if permission is granted.
  585. * @task_kill:
  586. * Check permission before sending signal @sig to @p. @info can be NULL,
  587. * the constant 1, or a pointer to a siginfo structure. If @info is 1 or
  588. * SI_FROMKERNEL(info) is true, then the signal should be viewed as coming
  589. * from the kernel and should typically be permitted.
  590. * SIGIO signals are handled separately by the send_sigiotask hook in
  591. * file_security_ops.
  592. * @p contains the task_struct for process.
  593. * @info contains the signal information.
  594. * @sig contains the signal value.
  595. * Return 0 if permission is granted.
  596. * @task_wait:
  597. * Check permission before allowing a process to reap a child process @p
  598. * and collect its status information.
  599. * @p contains the task_struct for process.
  600. * Return 0 if permission is granted.
  601. * @task_prctl:
  602. * Check permission before performing a process control operation on the
  603. * current process.
  604. * @option contains the operation.
  605. * @arg2 contains a argument.
  606. * @arg3 contains a argument.
  607. * @arg4 contains a argument.
  608. * @arg5 contains a argument.
  609. * Return 0 if permission is granted.
  610. * @task_reparent_to_init:
  611. * Set the security attributes in @p->security for a kernel thread that
  612. * is being reparented to the init task.
  613. * @p contains the task_struct for the kernel thread.
  614. * @task_to_inode:
  615. * Set the security attributes for an inode based on an associated task's
  616. * security attributes, e.g. for /proc/pid inodes.
  617. * @p contains the task_struct for the task.
  618. * @inode contains the inode structure for the inode.
  619. *
  620. * Security hooks for Netlink messaging.
  621. *
  622. * @netlink_send:
  623. * Save security information for a netlink message so that permission
  624. * checking can be performed when the message is processed. The security
  625. * information can be saved using the eff_cap field of the
  626. * netlink_skb_parms structure. Also may be used to provide fine
  627. * grained control over message transmission.
  628. * @sk associated sock of task sending the message.,
  629. * @skb contains the sk_buff structure for the netlink message.
  630. * Return 0 if the information was successfully saved and message
  631. * is allowed to be transmitted.
  632. * @netlink_recv:
  633. * Check permission before processing the received netlink message in
  634. * @skb.
  635. * @skb contains the sk_buff structure for the netlink message.
  636. * Return 0 if permission is granted.
  637. *
  638. * Security hooks for Unix domain networking.
  639. *
  640. * @unix_stream_connect:
  641. * Check permissions before establishing a Unix domain stream connection
  642. * between @sock and @other.
  643. * @sock contains the socket structure.
  644. * @other contains the peer socket structure.
  645. * Return 0 if permission is granted.
  646. * @unix_may_send:
  647. * Check permissions before connecting or sending datagrams from @sock to
  648. * @other.
  649. * @sock contains the socket structure.
  650. * @sock contains the peer socket structure.
  651. * Return 0 if permission is granted.
  652. *
  653. * The @unix_stream_connect and @unix_may_send hooks were necessary because
  654. * Linux provides an alternative to the conventional file name space for Unix
  655. * domain sockets. Whereas binding and connecting to sockets in the file name
  656. * space is mediated by the typical file permissions (and caught by the mknod
  657. * and permission hooks in inode_security_ops), binding and connecting to
  658. * sockets in the abstract name space is completely unmediated. Sufficient
  659. * control of Unix domain sockets in the abstract name space isn't possible
  660. * using only the socket layer hooks, since we need to know the actual target
  661. * socket, which is not looked up until we are inside the af_unix code.
  662. *
  663. * Security hooks for socket operations.
  664. *
  665. * @socket_create:
  666. * Check permissions prior to creating a new socket.
  667. * @family contains the requested protocol family.
  668. * @type contains the requested communications type.
  669. * @protocol contains the requested protocol.
  670. * @kern set to 1 if a kernel socket.
  671. * Return 0 if permission is granted.
  672. * @socket_post_create:
  673. * This hook allows a module to update or allocate a per-socket security
  674. * structure. Note that the security field was not added directly to the
  675. * socket structure, but rather, the socket security information is stored
  676. * in the associated inode. Typically, the inode alloc_security hook will
  677. * allocate and and attach security information to
  678. * sock->inode->i_security. This hook may be used to update the
  679. * sock->inode->i_security field with additional information that wasn't
  680. * available when the inode was allocated.
  681. * @sock contains the newly created socket structure.
  682. * @family contains the requested protocol family.
  683. * @type contains the requested communications type.
  684. * @protocol contains the requested protocol.
  685. * @kern set to 1 if a kernel socket.
  686. * @socket_bind:
  687. * Check permission before socket protocol layer bind operation is
  688. * performed and the socket @sock is bound to the address specified in the
  689. * @address parameter.
  690. * @sock contains the socket structure.
  691. * @address contains the address to bind to.
  692. * @addrlen contains the length of address.
  693. * Return 0 if permission is granted.
  694. * @socket_connect:
  695. * Check permission before socket protocol layer connect operation
  696. * attempts to connect socket @sock to a remote address, @address.
  697. * @sock contains the socket structure.
  698. * @address contains the address of remote endpoint.
  699. * @addrlen contains the length of address.
  700. * Return 0 if permission is granted.
  701. * @socket_listen:
  702. * Check permission before socket protocol layer listen operation.
  703. * @sock contains the socket structure.
  704. * @backlog contains the maximum length for the pending connection queue.
  705. * Return 0 if permission is granted.
  706. * @socket_accept:
  707. * Check permission before accepting a new connection. Note that the new
  708. * socket, @newsock, has been created and some information copied to it,
  709. * but the accept operation has not actually been performed.
  710. * @sock contains the listening socket structure.
  711. * @newsock contains the newly created server socket for connection.
  712. * Return 0 if permission is granted.
  713. * @socket_post_accept:
  714. * This hook allows a security module to copy security
  715. * information into the newly created socket's inode.
  716. * @sock contains the listening socket structure.
  717. * @newsock contains the newly created server socket for connection.
  718. * @socket_sendmsg:
  719. * Check permission before transmitting a message to another socket.
  720. * @sock contains the socket structure.
  721. * @msg contains the message to be transmitted.
  722. * @size contains the size of message.
  723. * Return 0 if permission is granted.
  724. * @socket_recvmsg:
  725. * Check permission before receiving a message from a socket.
  726. * @sock contains the socket structure.
  727. * @msg contains the message structure.
  728. * @size contains the size of message structure.
  729. * @flags contains the operational flags.
  730. * Return 0 if permission is granted.
  731. * @socket_getsockname:
  732. * Check permission before the local address (name) of the socket object
  733. * @sock is retrieved.
  734. * @sock contains the socket structure.
  735. * Return 0 if permission is granted.
  736. * @socket_getpeername:
  737. * Check permission before the remote address (name) of a socket object
  738. * @sock is retrieved.
  739. * @sock contains the socket structure.
  740. * Return 0 if permission is granted.
  741. * @socket_getsockopt:
  742. * Check permissions before retrieving the options associated with socket
  743. * @sock.
  744. * @sock contains the socket structure.
  745. * @level contains the protocol level to retrieve option from.
  746. * @optname contains the name of option to retrieve.
  747. * Return 0 if permission is granted.
  748. * @socket_setsockopt:
  749. * Check permissions before setting the options associated with socket
  750. * @sock.
  751. * @sock contains the socket structure.
  752. * @level contains the protocol level to set options for.
  753. * @optname contains the name of the option to set.
  754. * Return 0 if permission is granted.
  755. * @socket_shutdown:
  756. * Checks permission before all or part of a connection on the socket
  757. * @sock is shut down.
  758. * @sock contains the socket structure.
  759. * @how contains the flag indicating how future sends and receives are handled.
  760. * Return 0 if permission is granted.
  761. * @socket_sock_rcv_skb:
  762. * Check permissions on incoming network packets. This hook is distinct
  763. * from Netfilter's IP input hooks since it is the first time that the
  764. * incoming sk_buff @skb has been associated with a particular socket, @sk.
  765. * @sk contains the sock (not socket) associated with the incoming sk_buff.
  766. * @skb contains the incoming network data.
  767. * @socket_getpeersec:
  768. * This hook allows the security module to provide peer socket security
  769. * state to userspace via getsockopt SO_GETPEERSEC.
  770. * @sock is the local socket.
  771. * @optval userspace memory where the security state is to be copied.
  772. * @optlen userspace int where the module should copy the actual length
  773. * of the security state.
  774. * @len as input is the maximum length to copy to userspace provided
  775. * by the caller.
  776. * Return 0 if all is well, otherwise, typical getsockopt return
  777. * values.
  778. * @sk_alloc_security:
  779. * Allocate and attach a security structure to the sk->sk_security field,
  780. * which is used to copy security attributes between local stream sockets.
  781. * @sk_free_security:
  782. * Deallocate security structure.
  783. * @sk_getsid:
  784. * Retrieve the LSM-specific sid for the sock to enable caching of network
  785. * authorizations.
  786. *
  787. * Security hooks for XFRM operations.
  788. *
  789. * @xfrm_policy_alloc_security:
  790. * @xp contains the xfrm_policy being added to Security Policy Database
  791. * used by the XFRM system.
  792. * @sec_ctx contains the security context information being provided by
  793. * the user-level policy update program (e.g., setkey).
  794. * Allocate a security structure to the xp->selector.security field.
  795. * The security field is initialized to NULL when the xfrm_policy is
  796. * allocated.
  797. * Return 0 if operation was successful (memory to allocate, legal context)
  798. * @xfrm_policy_clone_security:
  799. * @old contains an existing xfrm_policy in the SPD.
  800. * @new contains a new xfrm_policy being cloned from old.
  801. * Allocate a security structure to the new->selector.security field
  802. * that contains the information from the old->selector.security field.
  803. * Return 0 if operation was successful (memory to allocate).
  804. * @xfrm_policy_free_security:
  805. * @xp contains the xfrm_policy
  806. * Deallocate xp->selector.security.
  807. * @xfrm_state_alloc_security:
  808. * @x contains the xfrm_state being added to the Security Association
  809. * Database by the XFRM system.
  810. * @sec_ctx contains the security context information being provided by
  811. * the user-level SA generation program (e.g., setkey or racoon).
  812. * Allocate a security structure to the x->sel.security field. The
  813. * security field is initialized to NULL when the xfrm_state is
  814. * allocated.
  815. * Return 0 if operation was successful (memory to allocate, legal context).
  816. * @xfrm_state_free_security:
  817. * @x contains the xfrm_state.
  818. * Deallocate x>sel.security.
  819. * @xfrm_policy_lookup:
  820. * @xp contains the xfrm_policy for which the access control is being
  821. * checked.
  822. * @sk_sid contains the sock security label that is used to authorize
  823. * access to the policy xp.
  824. * @dir contains the direction of the flow (input or output).
  825. * Check permission when a sock selects a xfrm_policy for processing
  826. * XFRMs on a packet. The hook is called when selecting either a
  827. * per-socket policy or a generic xfrm policy.
  828. * Return 0 if permission is granted.
  829. *
  830. * Security hooks affecting all Key Management operations
  831. *
  832. * @key_alloc:
  833. * Permit allocation of a key and assign security data. Note that key does
  834. * not have a serial number assigned at this point.
  835. * @key points to the key.
  836. * Return 0 if permission is granted, -ve error otherwise.
  837. * @key_free:
  838. * Notification of destruction; free security data.
  839. * @key points to the key.
  840. * No return value.
  841. * @key_permission:
  842. * See whether a specific operational right is granted to a process on a
  843. * key.
  844. * @key_ref refers to the key (key pointer + possession attribute bit).
  845. * @context points to the process to provide the context against which to
  846. * evaluate the security data on the key.
  847. * @perm describes the combination of permissions required of this key.
  848. * Return 1 if permission granted, 0 if permission denied and -ve it the
  849. * normal permissions model should be effected.
  850. *
  851. * Security hooks affecting all System V IPC operations.
  852. *
  853. * @ipc_permission:
  854. * Check permissions for access to IPC
  855. * @ipcp contains the kernel IPC permission structure
  856. * @flag contains the desired (requested) permission set
  857. * Return 0 if permission is granted.
  858. *
  859. * Security hooks for individual messages held in System V IPC message queues
  860. * @msg_msg_alloc_security:
  861. * Allocate and attach a security structure to the msg->security field.
  862. * The security field is initialized to NULL when the structure is first
  863. * created.
  864. * @msg contains the message structure to be modified.
  865. * Return 0 if operation was successful and permission is granted.
  866. * @msg_msg_free_security:
  867. * Deallocate the security structure for this message.
  868. * @msg contains the message structure to be modified.
  869. *
  870. * Security hooks for System V IPC Message Queues
  871. *
  872. * @msg_queue_alloc_security:
  873. * Allocate and attach a security structure to the
  874. * msq->q_perm.security field. The security field is initialized to
  875. * NULL when the structure is first created.
  876. * @msq contains the message queue structure to be modified.
  877. * Return 0 if operation was successful and permission is granted.
  878. * @msg_queue_free_security:
  879. * Deallocate security structure for this message queue.
  880. * @msq contains the message queue structure to be modified.
  881. * @msg_queue_associate:
  882. * Check permission when a message queue is requested through the
  883. * msgget system call. This hook is only called when returning the
  884. * message queue identifier for an existing message queue, not when a
  885. * new message queue is created.
  886. * @msq contains the message queue to act upon.
  887. * @msqflg contains the operation control flags.
  888. * Return 0 if permission is granted.
  889. * @msg_queue_msgctl:
  890. * Check permission when a message control operation specified by @cmd
  891. * is to be performed on the message queue @msq.
  892. * The @msq may be NULL, e.g. for IPC_INFO or MSG_INFO.
  893. * @msq contains the message queue to act upon. May be NULL.
  894. * @cmd contains the operation to be performed.
  895. * Return 0 if permission is granted.
  896. * @msg_queue_msgsnd:
  897. * Check permission before a message, @msg, is enqueued on the message
  898. * queue, @msq.
  899. * @msq contains the message queue to send message to.
  900. * @msg contains the message to be enqueued.
  901. * @msqflg contains operational flags.
  902. * Return 0 if permission is granted.
  903. * @msg_queue_msgrcv:
  904. * Check permission before a message, @msg, is removed from the message
  905. * queue, @msq. The @target task structure contains a pointer to the
  906. * process that will be receiving the message (not equal to the current
  907. * process when inline receives are being performed).
  908. * @msq contains the message queue to retrieve message from.
  909. * @msg contains the message destination.
  910. * @target contains the task structure for recipient process.
  911. * @type contains the type of message requested.
  912. * @mode contains the operational flags.
  913. * Return 0 if permission is granted.
  914. *
  915. * Security hooks for System V Shared Memory Segments
  916. *
  917. * @shm_alloc_security:
  918. * Allocate and attach a security structure to the shp->shm_perm.security
  919. * field. The security field is initialized to NULL when the structure is
  920. * first created.
  921. * @shp contains the shared memory structure to be modified.
  922. * Return 0 if operation was successful and permission is granted.
  923. * @shm_free_security:
  924. * Deallocate the security struct for this memory segment.
  925. * @shp contains the shared memory structure to be modified.
  926. * @shm_associate:
  927. * Check permission when a shared memory region is requested through the
  928. * shmget system call. This hook is only called when returning the shared
  929. * memory region identifier for an existing region, not when a new shared
  930. * memory region is created.
  931. * @shp contains the shared memory structure to be modified.
  932. * @shmflg contains the operation control flags.
  933. * Return 0 if permission is granted.
  934. * @shm_shmctl:
  935. * Check permission when a shared memory control operation specified by
  936. * @cmd is to be performed on the shared memory region @shp.
  937. * The @shp may be NULL, e.g. for IPC_INFO or SHM_INFO.
  938. * @shp contains shared memory structure to be modified.
  939. * @cmd contains the operation to be performed.
  940. * Return 0 if permission is granted.
  941. * @shm_shmat:
  942. * Check permissions prior to allowing the shmat system call to attach the
  943. * shared memory segment @shp to the data segment of the calling process.
  944. * The attaching address is specified by @shmaddr.
  945. * @shp contains the shared memory structure to be modified.
  946. * @shmaddr contains the address to attach memory region to.
  947. * @shmflg contains the operational flags.
  948. * Return 0 if permission is granted.
  949. *
  950. * Security hooks for System V Semaphores
  951. *
  952. * @sem_alloc_security:
  953. * Allocate and attach a security structure to the sma->sem_perm.security
  954. * field. The security field is initialized to NULL when the structure is
  955. * first created.
  956. * @sma contains the semaphore structure
  957. * Return 0 if operation was successful and permission is granted.
  958. * @sem_free_security:
  959. * deallocate security struct for this semaphore
  960. * @sma contains the semaphore structure.
  961. * @sem_associate:
  962. * Check permission when a semaphore is requested through the semget
  963. * system call. This hook is only called when returning the semaphore
  964. * identifier for an existing semaphore, not when a new one must be
  965. * created.
  966. * @sma contains the semaphore structure.
  967. * @semflg contains the operation control flags.
  968. * Return 0 if permission is granted.
  969. * @sem_semctl:
  970. * Check permission when a semaphore operation specified by @cmd is to be
  971. * performed on the semaphore @sma. The @sma may be NULL, e.g. for
  972. * IPC_INFO or SEM_INFO.
  973. * @sma contains the semaphore structure. May be NULL.
  974. * @cmd contains the operation to be performed.
  975. * Return 0 if permission is granted.
  976. * @sem_semop
  977. * Check permissions before performing operations on members of the
  978. * semaphore set @sma. If the @alter flag is nonzero, the semaphore set
  979. * may be modified.
  980. * @sma contains the semaphore structure.
  981. * @sops contains the operations to perform.
  982. * @nsops contains the number of operations to perform.
  983. * @alter contains the flag indicating whether changes are to be made.
  984. * Return 0 if permission is granted.
  985. *
  986. * @ptrace:
  987. * Check permission before allowing the @parent process to trace the
  988. * @child process.
  989. * Security modules may also want to perform a process tracing check
  990. * during an execve in the set_security or apply_creds hooks of
  991. * binprm_security_ops if the process is being traced and its security
  992. * attributes would be changed by the execve.
  993. * @parent contains the task_struct structure for parent process.
  994. * @child contains the task_struct structure for child process.
  995. * Return 0 if permission is granted.
  996. * @capget:
  997. * Get the @effective, @inheritable, and @permitted capability sets for
  998. * the @target process. The hook may also perform permission checking to
  999. * determine if the current process is allowed to see the capability sets
  1000. * of the @target process.
  1001. * @target contains the task_struct structure for target process.
  1002. * @effective contains the effective capability set.
  1003. * @inheritable contains the inheritable capability set.
  1004. * @permitted contains the permitted capability set.
  1005. * Return 0 if the capability sets were successfully obtained.
  1006. * @capset_check:
  1007. * Check permission before setting the @effective, @inheritable, and
  1008. * @permitted capability sets for the @target process.
  1009. * Caveat: @target is also set to current if a set of processes is
  1010. * specified (i.e. all processes other than current and init or a
  1011. * particular process group). Hence, the capset_set hook may need to
  1012. * revalidate permission to the actual target process.
  1013. * @target contains the task_struct structure for target process.
  1014. * @effective contains the effective capability set.
  1015. * @inheritable contains the inheritable capability set.
  1016. * @permitted contains the permitted capability set.
  1017. * Return 0 if permission is granted.
  1018. * @capset_set:
  1019. * Set the @effective, @inheritable, and @permitted capability sets for
  1020. * the @target process. Since capset_check cannot always check permission
  1021. * to the real @target process, this hook may also perform permission
  1022. * checking to determine if the current process is allowed to set the
  1023. * capability sets of the @target process. However, this hook has no way
  1024. * of returning an error due to the structure of the sys_capset code.
  1025. * @target contains the task_struct structure for target process.
  1026. * @effective contains the effective capability set.
  1027. * @inheritable contains the inheritable capability set.
  1028. * @permitted contains the permitted capability set.
  1029. * @capable:
  1030. * Check whether the @tsk process has the @cap capability.
  1031. * @tsk contains the task_struct for the process.
  1032. * @cap contains the capability <include/linux/capability.h>.
  1033. * Return 0 if the capability is granted for @tsk.
  1034. * @acct:
  1035. * Check permission before enabling or disabling process accounting. If
  1036. * accounting is being enabled, then @file refers to the open file used to
  1037. * store accounting records. If accounting is being disabled, then @file
  1038. * is NULL.
  1039. * @file contains the file structure for the accounting file (may be NULL).
  1040. * Return 0 if permission is granted.
  1041. * @sysctl:
  1042. * Check permission before accessing the @table sysctl variable in the
  1043. * manner specified by @op.
  1044. * @table contains the ctl_table structure for the sysctl variable.
  1045. * @op contains the operation (001 = search, 002 = write, 004 = read).
  1046. * Return 0 if permission is granted.
  1047. * @syslog:
  1048. * Check permission before accessing the kernel message ring or changing
  1049. * logging to the console.
  1050. * See the syslog(2) manual page for an explanation of the @type values.
  1051. * @type contains the type of action.
  1052. * Return 0 if permission is granted.
  1053. * @settime:
  1054. * Check permission to change the system time.
  1055. * struct timespec and timezone are defined in include/linux/time.h
  1056. * @ts contains new time
  1057. * @tz contains new timezone
  1058. * Return 0 if permission is granted.
  1059. * @vm_enough_memory:
  1060. * Check permissions for allocating a new virtual mapping.
  1061. * @pages contains the number of pages.
  1062. * Return 0 if permission is granted.
  1063. *
  1064. * @register_security:
  1065. * allow module stacking.
  1066. * @name contains the name of the security module being stacked.
  1067. * @ops contains a pointer to the struct security_operations of the module to stack.
  1068. * @unregister_security:
  1069. * remove a stacked module.
  1070. * @name contains the name of the security module being unstacked.
  1071. * @ops contains a pointer to the struct security_operations of the module to unstack.
  1072. *
  1073. * This is the main security structure.
  1074. */
  1075. struct security_operations {
  1076. int (*ptrace) (struct task_struct * parent, struct task_struct * child);
  1077. int (*capget) (struct task_struct * target,
  1078. kernel_cap_t * effective,
  1079. kernel_cap_t * inheritable, kernel_cap_t * permitted);
  1080. int (*capset_check) (struct task_struct * target,
  1081. kernel_cap_t * effective,
  1082. kernel_cap_t * inheritable,
  1083. kernel_cap_t * permitted);
  1084. void (*capset_set) (struct task_struct * target,
  1085. kernel_cap_t * effective,
  1086. kernel_cap_t * inheritable,
  1087. kernel_cap_t * permitted);
  1088. int (*capable) (struct task_struct * tsk, int cap);
  1089. int (*acct) (struct file * file);
  1090. int (*sysctl) (struct ctl_table * table, int op);
  1091. int (*quotactl) (int cmds, int type, int id, struct super_block * sb);
  1092. int (*quota_on) (struct dentry * dentry);
  1093. int (*syslog) (int type);
  1094. int (*settime) (struct timespec *ts, struct timezone *tz);
  1095. int (*vm_enough_memory) (long pages);
  1096. int (*bprm_alloc_security) (struct linux_binprm * bprm);
  1097. void (*bprm_free_security) (struct linux_binprm * bprm);
  1098. void (*bprm_apply_creds) (struct linux_binprm * bprm, int unsafe);
  1099. void (*bprm_post_apply_creds) (struct linux_binprm * bprm);
  1100. int (*bprm_set_security) (struct linux_binprm * bprm);
  1101. int (*bprm_check_security) (struct linux_binprm * bprm);
  1102. int (*bprm_secureexec) (struct linux_binprm * bprm);
  1103. int (*sb_alloc_security) (struct super_block * sb);
  1104. void (*sb_free_security) (struct super_block * sb);
  1105. int (*sb_copy_data)(struct file_system_type *type,
  1106. void *orig, void *copy);
  1107. int (*sb_kern_mount) (struct super_block *sb, void *data);
  1108. int (*sb_statfs) (struct super_block * sb);
  1109. int (*sb_mount) (char *dev_name, struct nameidata * nd,
  1110. char *type, unsigned long flags, void *data);
  1111. int (*sb_check_sb) (struct vfsmount * mnt, struct nameidata * nd);
  1112. int (*sb_umount) (struct vfsmount * mnt, int flags);
  1113. void (*sb_umount_close) (struct vfsmount * mnt);
  1114. void (*sb_umount_busy) (struct vfsmount * mnt);
  1115. void (*sb_post_remount) (struct vfsmount * mnt,
  1116. unsigned long flags, void *data);
  1117. void (*sb_post_mountroot) (void);
  1118. void (*sb_post_addmount) (struct vfsmount * mnt,
  1119. struct nameidata * mountpoint_nd);
  1120. int (*sb_pivotroot) (struct nameidata * old_nd,
  1121. struct nameidata * new_nd);
  1122. void (*sb_post_pivotroot) (struct nameidata * old_nd,
  1123. struct nameidata * new_nd);
  1124. int (*inode_alloc_security) (struct inode *inode);
  1125. void (*inode_free_security) (struct inode *inode);
  1126. int (*inode_init_security) (struct inode *inode, struct inode *dir,
  1127. char **name, void **value, size_t *len);
  1128. int (*inode_create) (struct inode *dir,
  1129. struct dentry *dentry, int mode);
  1130. int (*inode_link) (struct dentry *old_dentry,
  1131. struct inode *dir, struct dentry *new_dentry);
  1132. int (*inode_unlink) (struct inode *dir, struct dentry *dentry);
  1133. int (*inode_symlink) (struct inode *dir,
  1134. struct dentry *dentry, const char *old_name);
  1135. int (*inode_mkdir) (struct inode *dir, struct dentry *dentry, int mode);
  1136. int (*inode_rmdir) (struct inode *dir, struct dentry *dentry);
  1137. int (*inode_mknod) (struct inode *dir, struct dentry *dentry,
  1138. int mode, dev_t dev);
  1139. int (*inode_rename) (struct inode *old_dir, struct dentry *old_dentry,
  1140. struct inode *new_dir, struct dentry *new_dentry);
  1141. int (*inode_readlink) (struct dentry *dentry);
  1142. int (*inode_follow_link) (struct dentry *dentry, struct nameidata *nd);
  1143. int (*inode_permission) (struct inode *inode, int mask, struct nameidata *nd);
  1144. int (*inode_setattr) (struct dentry *dentry, struct iattr *attr);
  1145. int (*inode_getattr) (struct vfsmount *mnt, struct dentry *dentry);
  1146. void (*inode_delete) (struct inode *inode);
  1147. int (*inode_setxattr) (struct dentry *dentry, char *name, void *value,
  1148. size_t size, int flags);
  1149. void (*inode_post_setxattr) (struct dentry *dentry, char *name, void *value,
  1150. size_t size, int flags);
  1151. int (*inode_getxattr) (struct dentry *dentry, char *name);
  1152. int (*inode_listxattr) (struct dentry *dentry);
  1153. int (*inode_removexattr) (struct dentry *dentry, char *name);
  1154. int (*inode_getsecurity)(struct inode *inode, const char *name, void *buffer, size_t size, int err);
  1155. int (*inode_setsecurity)(struct inode *inode, const char *name, const void *value, size_t size, int flags);
  1156. int (*inode_listsecurity)(struct inode *inode, char *buffer, size_t buffer_size);
  1157. int (*file_permission) (struct file * file, int mask);
  1158. int (*file_alloc_security) (struct file * file);
  1159. void (*file_free_security) (struct file * file);
  1160. int (*file_ioctl) (struct file * file, unsigned int cmd,
  1161. unsigned long arg);
  1162. int (*file_mmap) (struct file * file,
  1163. unsigned long reqprot,
  1164. unsigned long prot, unsigned long flags);
  1165. int (*file_mprotect) (struct vm_area_struct * vma,
  1166. unsigned long reqprot,
  1167. unsigned long prot);
  1168. int (*file_lock) (struct file * file, unsigned int cmd);
  1169. int (*file_fcntl) (struct file * file, unsigned int cmd,
  1170. unsigned long arg);
  1171. int (*file_set_fowner) (struct file * file);
  1172. int (*file_send_sigiotask) (struct task_struct * tsk,
  1173. struct fown_struct * fown, int sig);
  1174. int (*file_receive) (struct file * file);
  1175. int (*task_create) (unsigned long clone_flags);
  1176. int (*task_alloc_security) (struct task_struct * p);
  1177. void (*task_free_security) (struct task_struct * p);
  1178. int (*task_setuid) (uid_t id0, uid_t id1, uid_t id2, int flags);
  1179. int (*task_post_setuid) (uid_t old_ruid /* or fsuid */ ,
  1180. uid_t old_euid, uid_t old_suid, int flags);
  1181. int (*task_setgid) (gid_t id0, gid_t id1, gid_t id2, int flags);
  1182. int (*task_setpgid) (struct task_struct * p, pid_t pgid);
  1183. int (*task_getpgid) (struct task_struct * p);
  1184. int (*task_getsid) (struct task_struct * p);
  1185. int (*task_setgroups) (struct group_info *group_info);
  1186. int (*task_setnice) (struct task_struct * p, int nice);
  1187. int (*task_setrlimit) (unsigned int resource, struct rlimit * new_rlim);
  1188. int (*task_setscheduler) (struct task_struct * p, int policy,
  1189. struct sched_param * lp);
  1190. int (*task_getscheduler) (struct task_struct * p);
  1191. int (*task_kill) (struct task_struct * p,
  1192. struct siginfo * info, int sig);
  1193. int (*task_wait) (struct task_struct * p);
  1194. int (*task_prctl) (int option, unsigned long arg2,
  1195. unsigned long arg3, unsigned long arg4,
  1196. unsigned long arg5);
  1197. void (*task_reparent_to_init) (struct task_struct * p);
  1198. void (*task_to_inode)(struct task_struct *p, struct inode *inode);
  1199. int (*ipc_permission) (struct kern_ipc_perm * ipcp, short flag);
  1200. int (*msg_msg_alloc_security) (struct msg_msg * msg);
  1201. void (*msg_msg_free_security) (struct msg_msg * msg);
  1202. int (*msg_queue_alloc_security) (struct msg_queue * msq);
  1203. void (*msg_queue_free_security) (struct msg_queue * msq);
  1204. int (*msg_queue_associate) (struct msg_queue * msq, int msqflg);
  1205. int (*msg_queue_msgctl) (struct msg_queue * msq, int cmd);
  1206. int (*msg_queue_msgsnd) (struct msg_queue * msq,
  1207. struct msg_msg * msg, int msqflg);
  1208. int (*msg_queue_msgrcv) (struct msg_queue * msq,
  1209. struct msg_msg * msg,
  1210. struct task_struct * target,
  1211. long type, int mode);
  1212. int (*shm_alloc_security) (struct shmid_kernel * shp);
  1213. void (*shm_free_security) (struct shmid_kernel * shp);
  1214. int (*shm_associate) (struct shmid_kernel * shp, int shmflg);
  1215. int (*shm_shmctl) (struct shmid_kernel * shp, int cmd);
  1216. int (*shm_shmat) (struct shmid_kernel * shp,
  1217. char __user *shmaddr, int shmflg);
  1218. int (*sem_alloc_security) (struct sem_array * sma);
  1219. void (*sem_free_security) (struct sem_array * sma);
  1220. int (*sem_associate) (struct sem_array * sma, int semflg);
  1221. int (*sem_semctl) (struct sem_array * sma, int cmd);
  1222. int (*sem_semop) (struct sem_array * sma,
  1223. struct sembuf * sops, unsigned nsops, int alter);
  1224. int (*netlink_send) (struct sock * sk, struct sk_buff * skb);
  1225. int (*netlink_recv) (struct sk_buff * skb);
  1226. /* allow module stacking */
  1227. int (*register_security) (const char *name,
  1228. struct security_operations *ops);
  1229. int (*unregister_security) (const char *name,
  1230. struct security_operations *ops);
  1231. void (*d_instantiate) (struct dentry *dentry, struct inode *inode);
  1232. int (*getprocattr)(struct task_struct *p, char *name, void *value, size_t size);
  1233. int (*setprocattr)(struct task_struct *p, char *name, void *value, size_t size);
  1234. #ifdef CONFIG_SECURITY_NETWORK
  1235. int (*unix_stream_connect) (struct socket * sock,
  1236. struct socket * other, struct sock * newsk);
  1237. int (*unix_may_send) (struct socket * sock, struct socket * other);
  1238. int (*socket_create) (int family, int type, int protocol, int kern);
  1239. void (*socket_post_create) (struct socket * sock, int family,
  1240. int type, int protocol, int kern);
  1241. int (*socket_bind) (struct socket * sock,
  1242. struct sockaddr * address, int addrlen);
  1243. int (*socket_connect) (struct socket * sock,
  1244. struct sockaddr * address, int addrlen);
  1245. int (*socket_listen) (struct socket * sock, int backlog);
  1246. int (*socket_accept) (struct socket * sock, struct socket * newsock);
  1247. void (*socket_post_accept) (struct socket * sock,
  1248. struct socket * newsock);
  1249. int (*socket_sendmsg) (struct socket * sock,
  1250. struct msghdr * msg, int size);
  1251. int (*socket_recvmsg) (struct socket * sock,
  1252. struct msghdr * msg, int size, int flags);
  1253. int (*socket_getsockname) (struct socket * sock);
  1254. int (*socket_getpeername) (struct socket * sock);
  1255. int (*socket_getsockopt) (struct socket * sock, int level, int optname);
  1256. int (*socket_setsockopt) (struct socket * sock, int level, int optname);
  1257. int (*socket_shutdown) (struct socket * sock, int how);
  1258. int (*socket_sock_rcv_skb) (struct sock * sk, struct sk_buff * skb);
  1259. int (*socket_getpeersec_stream) (struct socket *sock, char __user *optval, int __user *optlen, unsigned len);
  1260. int (*socket_getpeersec_dgram) (struct sk_buff *skb, char **secdata, u32 *seclen);
  1261. int (*sk_alloc_security) (struct sock *sk, int family, gfp_t priority);
  1262. void (*sk_free_security) (struct sock *sk);
  1263. unsigned int (*sk_getsid) (struct sock *sk, struct flowi *fl, u8 dir);
  1264. #endif /* CONFIG_SECURITY_NETWORK */
  1265. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  1266. int (*xfrm_policy_alloc_security) (struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx);
  1267. int (*xfrm_policy_clone_security) (struct xfrm_policy *old, struct xfrm_policy *new);
  1268. void (*xfrm_policy_free_security) (struct xfrm_policy *xp);
  1269. int (*xfrm_state_alloc_security) (struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx);
  1270. void (*xfrm_state_free_security) (struct xfrm_state *x);
  1271. int (*xfrm_policy_lookup)(struct xfrm_policy *xp, u32 sk_sid, u8 dir);
  1272. #endif /* CONFIG_SECURITY_NETWORK_XFRM */
  1273. /* key management security hooks */
  1274. #ifdef CONFIG_KEYS
  1275. int (*key_alloc)(struct key *key);
  1276. void (*key_free)(struct key *key);
  1277. int (*key_permission)(key_ref_t key_ref,
  1278. struct task_struct *context,
  1279. key_perm_t perm);
  1280. #endif /* CONFIG_KEYS */
  1281. };
  1282. /* global variables */
  1283. extern struct security_operations *security_ops;
  1284. /* inline stuff */
  1285. static inline int security_ptrace (struct task_struct * parent, struct task_struct * child)
  1286. {
  1287. return security_ops->ptrace (parent, child);
  1288. }
  1289. static inline int security_capget (struct task_struct *target,
  1290. kernel_cap_t *effective,
  1291. kernel_cap_t *inheritable,
  1292. kernel_cap_t *permitted)
  1293. {
  1294. return security_ops->capget (target, effective, inheritable, permitted);
  1295. }
  1296. static inline int security_capset_check (struct task_struct *target,
  1297. kernel_cap_t *effective,
  1298. kernel_cap_t *inheritable,
  1299. kernel_cap_t *permitted)
  1300. {
  1301. return security_ops->capset_check (target, effective, inheritable, permitted);
  1302. }
  1303. static inline void security_capset_set (struct task_struct *target,
  1304. kernel_cap_t *effective,
  1305. kernel_cap_t *inheritable,
  1306. kernel_cap_t *permitted)
  1307. {
  1308. security_ops->capset_set (target, effective, inheritable, permitted);
  1309. }
  1310. static inline int security_capable(struct task_struct *tsk, int cap)
  1311. {
  1312. return security_ops->capable(tsk, cap);
  1313. }
  1314. static inline int security_acct (struct file *file)
  1315. {
  1316. return security_ops->acct (file);
  1317. }
  1318. static inline int security_sysctl(struct ctl_table *table, int op)
  1319. {
  1320. return security_ops->sysctl(table, op);
  1321. }
  1322. static inline int security_quotactl (int cmds, int type, int id,
  1323. struct super_block *sb)
  1324. {
  1325. return security_ops->quotactl (cmds, type, id, sb);
  1326. }
  1327. static inline int security_quota_on (struct dentry * dentry)
  1328. {
  1329. return security_ops->quota_on (dentry);
  1330. }
  1331. static inline int security_syslog(int type)
  1332. {
  1333. return security_ops->syslog(type);
  1334. }
  1335. static inline int security_settime(struct timespec *ts, struct timezone *tz)
  1336. {
  1337. return security_ops->settime(ts, tz);
  1338. }
  1339. static inline int security_vm_enough_memory(long pages)
  1340. {
  1341. return security_ops->vm_enough_memory(pages);
  1342. }
  1343. static inline int security_bprm_alloc (struct linux_binprm *bprm)
  1344. {
  1345. return security_ops->bprm_alloc_security (bprm);
  1346. }
  1347. static inline void security_bprm_free (struct linux_binprm *bprm)
  1348. {
  1349. security_ops->bprm_free_security (bprm);
  1350. }
  1351. static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
  1352. {
  1353. security_ops->bprm_apply_creds (bprm, unsafe);
  1354. }
  1355. static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
  1356. {
  1357. security_ops->bprm_post_apply_creds (bprm);
  1358. }
  1359. static inline int security_bprm_set (struct linux_binprm *bprm)
  1360. {
  1361. return security_ops->bprm_set_security (bprm);
  1362. }
  1363. static inline int security_bprm_check (struct linux_binprm *bprm)
  1364. {
  1365. return security_ops->bprm_check_security (bprm);
  1366. }
  1367. static inline int security_bprm_secureexec (struct linux_binprm *bprm)
  1368. {
  1369. return security_ops->bprm_secureexec (bprm);
  1370. }
  1371. static inline int security_sb_alloc (struct super_block *sb)
  1372. {
  1373. return security_ops->sb_alloc_security (sb);
  1374. }
  1375. static inline void security_sb_free (struct super_block *sb)
  1376. {
  1377. security_ops->sb_free_security (sb);
  1378. }
  1379. static inline int security_sb_copy_data (struct file_system_type *type,
  1380. void *orig, void *copy)
  1381. {
  1382. return security_ops->sb_copy_data (type, orig, copy);
  1383. }
  1384. static inline int security_sb_kern_mount (struct super_block *sb, void *data)
  1385. {
  1386. return security_ops->sb_kern_mount (sb, data);
  1387. }
  1388. static inline int security_sb_statfs (struct super_block *sb)
  1389. {
  1390. return security_ops->sb_statfs (sb);
  1391. }
  1392. static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
  1393. char *type, unsigned long flags,
  1394. void *data)
  1395. {
  1396. return security_ops->sb_mount (dev_name, nd, type, flags, data);
  1397. }
  1398. static inline int security_sb_check_sb (struct vfsmount *mnt,
  1399. struct nameidata *nd)
  1400. {
  1401. return security_ops->sb_check_sb (mnt, nd);
  1402. }
  1403. static inline int security_sb_umount (struct vfsmount *mnt, int flags)
  1404. {
  1405. return security_ops->sb_umount (mnt, flags);
  1406. }
  1407. static inline void security_sb_umount_close (struct vfsmount *mnt)
  1408. {
  1409. security_ops->sb_umount_close (mnt);
  1410. }
  1411. static inline void security_sb_umount_busy (struct vfsmount *mnt)
  1412. {
  1413. security_ops->sb_umount_busy (mnt);
  1414. }
  1415. static inline void security_sb_post_remount (struct vfsmount *mnt,
  1416. unsigned long flags, void *data)
  1417. {
  1418. security_ops->sb_post_remount (mnt, flags, data);
  1419. }
  1420. static inline void security_sb_post_mountroot (void)
  1421. {
  1422. security_ops->sb_post_mountroot ();
  1423. }
  1424. static inline void security_sb_post_addmount (struct vfsmount *mnt,
  1425. struct nameidata *mountpoint_nd)
  1426. {
  1427. security_ops->sb_post_addmount (mnt, mountpoint_nd);
  1428. }
  1429. static inline int security_sb_pivotroot (struct nameidata *old_nd,
  1430. struct nameidata *new_nd)
  1431. {
  1432. return security_ops->sb_pivotroot (old_nd, new_nd);
  1433. }
  1434. static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
  1435. struct nameidata *new_nd)
  1436. {
  1437. security_ops->sb_post_pivotroot (old_nd, new_nd);
  1438. }
  1439. static inline int security_inode_alloc (struct inode *inode)
  1440. {
  1441. return security_ops->inode_alloc_security (inode);
  1442. }
  1443. static inline void security_inode_free (struct inode *inode)
  1444. {
  1445. security_ops->inode_free_security (inode);
  1446. }
  1447. static inline int security_inode_init_security (struct inode *inode,
  1448. struct inode *dir,
  1449. char **name,
  1450. void **value,
  1451. size_t *len)
  1452. {
  1453. if (unlikely (IS_PRIVATE (inode)))
  1454. return -EOPNOTSUPP;
  1455. return security_ops->inode_init_security (inode, dir, name, value, len);
  1456. }
  1457. static inline int security_inode_create (struct inode *dir,
  1458. struct dentry *dentry,
  1459. int mode)
  1460. {
  1461. if (unlikely (IS_PRIVATE (dir)))
  1462. return 0;
  1463. return security_ops->inode_create (dir, dentry, mode);
  1464. }
  1465. static inline int security_inode_link (struct dentry *old_dentry,
  1466. struct inode *dir,
  1467. struct dentry *new_dentry)
  1468. {
  1469. if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
  1470. return 0;
  1471. return security_ops->inode_link (old_dentry, dir, new_dentry);
  1472. }
  1473. static inline int security_inode_unlink (struct inode *dir,
  1474. struct dentry *dentry)
  1475. {
  1476. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1477. return 0;
  1478. return security_ops->inode_unlink (dir, dentry);
  1479. }
  1480. static inline int security_inode_symlink (struct inode *dir,
  1481. struct dentry *dentry,
  1482. const char *old_name)
  1483. {
  1484. if (unlikely (IS_PRIVATE (dir)))
  1485. return 0;
  1486. return security_ops->inode_symlink (dir, dentry, old_name);
  1487. }
  1488. static inline int security_inode_mkdir (struct inode *dir,
  1489. struct dentry *dentry,
  1490. int mode)
  1491. {
  1492. if (unlikely (IS_PRIVATE (dir)))
  1493. return 0;
  1494. return security_ops->inode_mkdir (dir, dentry, mode);
  1495. }
  1496. static inline int security_inode_rmdir (struct inode *dir,
  1497. struct dentry *dentry)
  1498. {
  1499. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1500. return 0;
  1501. return security_ops->inode_rmdir (dir, dentry);
  1502. }
  1503. static inline int security_inode_mknod (struct inode *dir,
  1504. struct dentry *dentry,
  1505. int mode, dev_t dev)
  1506. {
  1507. if (unlikely (IS_PRIVATE (dir)))
  1508. return 0;
  1509. return security_ops->inode_mknod (dir, dentry, mode, dev);
  1510. }
  1511. static inline int security_inode_rename (struct inode *old_dir,
  1512. struct dentry *old_dentry,
  1513. struct inode *new_dir,
  1514. struct dentry *new_dentry)
  1515. {
  1516. if (unlikely (IS_PRIVATE (old_dentry->d_inode) ||
  1517. (new_dentry->d_inode && IS_PRIVATE (new_dentry->d_inode))))
  1518. return 0;
  1519. return security_ops->inode_rename (old_dir, old_dentry,
  1520. new_dir, new_dentry);
  1521. }
  1522. static inline int security_inode_readlink (struct dentry *dentry)
  1523. {
  1524. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1525. return 0;
  1526. return security_ops->inode_readlink (dentry);
  1527. }
  1528. static inline int security_inode_follow_link (struct dentry *dentry,
  1529. struct nameidata *nd)
  1530. {
  1531. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1532. return 0;
  1533. return security_ops->inode_follow_link (dentry, nd);
  1534. }
  1535. static inline int security_inode_permission (struct inode *inode, int mask,
  1536. struct nameidata *nd)
  1537. {
  1538. if (unlikely (IS_PRIVATE (inode)))
  1539. return 0;
  1540. return security_ops->inode_permission (inode, mask, nd);
  1541. }
  1542. static inline int security_inode_setattr (struct dentry *dentry,
  1543. struct iattr *attr)
  1544. {
  1545. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1546. return 0;
  1547. return security_ops->inode_setattr (dentry, attr);
  1548. }
  1549. static inline int security_inode_getattr (struct vfsmount *mnt,
  1550. struct dentry *dentry)
  1551. {
  1552. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1553. return 0;
  1554. return security_ops->inode_getattr (mnt, dentry);
  1555. }
  1556. static inline void security_inode_delete (struct inode *inode)
  1557. {
  1558. if (unlikely (IS_PRIVATE (inode)))
  1559. return;
  1560. security_ops->inode_delete (inode);
  1561. }
  1562. static inline int security_inode_setxattr (struct dentry *dentry, char *name,
  1563. void *value, size_t size, int flags)
  1564. {
  1565. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1566. return 0;
  1567. return security_ops->inode_setxattr (dentry, name, value, size, flags);
  1568. }
  1569. static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
  1570. void *value, size_t size, int flags)
  1571. {
  1572. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1573. return;
  1574. security_ops->inode_post_setxattr (dentry, name, value, size, flags);
  1575. }
  1576. static inline int security_inode_getxattr (struct dentry *dentry, char *name)
  1577. {
  1578. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1579. return 0;
  1580. return security_ops->inode_getxattr (dentry, name);
  1581. }
  1582. static inline int security_inode_listxattr (struct dentry *dentry)
  1583. {
  1584. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1585. return 0;
  1586. return security_ops->inode_listxattr (dentry);
  1587. }
  1588. static inline int security_inode_removexattr (struct dentry *dentry, char *name)
  1589. {
  1590. if (unlikely (IS_PRIVATE (dentry->d_inode)))
  1591. return 0;
  1592. return security_ops->inode_removexattr (dentry, name);
  1593. }
  1594. static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size, int err)
  1595. {
  1596. if (unlikely (IS_PRIVATE (inode)))
  1597. return 0;
  1598. return security_ops->inode_getsecurity(inode, name, buffer, size, err);
  1599. }
  1600. static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
  1601. {
  1602. if (unlikely (IS_PRIVATE (inode)))
  1603. return 0;
  1604. return security_ops->inode_setsecurity(inode, name, value, size, flags);
  1605. }
  1606. static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
  1607. {
  1608. if (unlikely (IS_PRIVATE (inode)))
  1609. return 0;
  1610. return security_ops->inode_listsecurity(inode, buffer, buffer_size);
  1611. }
  1612. static inline int security_file_permission (struct file *file, int mask)
  1613. {
  1614. return security_ops->file_permission (file, mask);
  1615. }
  1616. static inline int security_file_alloc (struct file *file)
  1617. {
  1618. return security_ops->file_alloc_security (file);
  1619. }
  1620. static inline void security_file_free (struct file *file)
  1621. {
  1622. security_ops->file_free_security (file);
  1623. }
  1624. static inline int security_file_ioctl (struct file *file, unsigned int cmd,
  1625. unsigned long arg)
  1626. {
  1627. return security_ops->file_ioctl (file, cmd, arg);
  1628. }
  1629. static inline int security_file_mmap (struct file *file, unsigned long reqprot,
  1630. unsigned long prot,
  1631. unsigned long flags)
  1632. {
  1633. return security_ops->file_mmap (file, reqprot, prot, flags);
  1634. }
  1635. static inline int security_file_mprotect (struct vm_area_struct *vma,
  1636. unsigned long reqprot,
  1637. unsigned long prot)
  1638. {
  1639. return security_ops->file_mprotect (vma, reqprot, prot);
  1640. }
  1641. static inline int security_file_lock (struct file *file, unsigned int cmd)
  1642. {
  1643. return security_ops->file_lock (file, cmd);
  1644. }
  1645. static inline int security_file_fcntl (struct file *file, unsigned int cmd,
  1646. unsigned long arg)
  1647. {
  1648. return security_ops->file_fcntl (file, cmd, arg);
  1649. }
  1650. static inline int security_file_set_fowner (struct file *file)
  1651. {
  1652. return security_ops->file_set_fowner (file);
  1653. }
  1654. static inline int security_file_send_sigiotask (struct task_struct *tsk,
  1655. struct fown_struct *fown,
  1656. int sig)
  1657. {
  1658. return security_ops->file_send_sigiotask (tsk, fown, sig);
  1659. }
  1660. static inline int security_file_receive (struct file *file)
  1661. {
  1662. return security_ops->file_receive (file);
  1663. }
  1664. static inline int security_task_create (unsigned long clone_flags)
  1665. {
  1666. return security_ops->task_create (clone_flags);
  1667. }
  1668. static inline int security_task_alloc (struct task_struct *p)
  1669. {
  1670. return security_ops->task_alloc_security (p);
  1671. }
  1672. static inline void security_task_free (struct task_struct *p)
  1673. {
  1674. security_ops->task_free_security (p);
  1675. }
  1676. static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
  1677. int flags)
  1678. {
  1679. return security_ops->task_setuid (id0, id1, id2, flags);
  1680. }
  1681. static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
  1682. uid_t old_suid, int flags)
  1683. {
  1684. return security_ops->task_post_setuid (old_ruid, old_euid, old_suid, flags);
  1685. }
  1686. static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
  1687. int flags)
  1688. {
  1689. return security_ops->task_setgid (id0, id1, id2, flags);
  1690. }
  1691. static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
  1692. {
  1693. return security_ops->task_setpgid (p, pgid);
  1694. }
  1695. static inline int security_task_getpgid (struct task_struct *p)
  1696. {
  1697. return security_ops->task_getpgid (p);
  1698. }
  1699. static inline int security_task_getsid (struct task_struct *p)
  1700. {
  1701. return security_ops->task_getsid (p);
  1702. }
  1703. static inline int security_task_setgroups (struct group_info *group_info)
  1704. {
  1705. return security_ops->task_setgroups (group_info);
  1706. }
  1707. static inline int security_task_setnice (struct task_struct *p, int nice)
  1708. {
  1709. return security_ops->task_setnice (p, nice);
  1710. }
  1711. static inline int security_task_setrlimit (unsigned int resource,
  1712. struct rlimit *new_rlim)
  1713. {
  1714. return security_ops->task_setrlimit (resource, new_rlim);
  1715. }
  1716. static inline int security_task_setscheduler (struct task_struct *p,
  1717. int policy,
  1718. struct sched_param *lp)
  1719. {
  1720. return security_ops->task_setscheduler (p, policy, lp);
  1721. }
  1722. static inline int security_task_getscheduler (struct task_struct *p)
  1723. {
  1724. return security_ops->task_getscheduler (p);
  1725. }
  1726. static inline int security_task_kill (struct task_struct *p,
  1727. struct siginfo *info, int sig)
  1728. {
  1729. return security_ops->task_kill (p, info, sig);
  1730. }
  1731. static inline int security_task_wait (struct task_struct *p)
  1732. {
  1733. return security_ops->task_wait (p);
  1734. }
  1735. static inline int security_task_prctl (int option, unsigned long arg2,
  1736. unsigned long arg3,
  1737. unsigned long arg4,
  1738. unsigned long arg5)
  1739. {
  1740. return security_ops->task_prctl (option, arg2, arg3, arg4, arg5);
  1741. }
  1742. static inline void security_task_reparent_to_init (struct task_struct *p)
  1743. {
  1744. security_ops->task_reparent_to_init (p);
  1745. }
  1746. static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
  1747. {
  1748. security_ops->task_to_inode(p, inode);
  1749. }
  1750. static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
  1751. short flag)
  1752. {
  1753. return security_ops->ipc_permission (ipcp, flag);
  1754. }
  1755. static inline int security_msg_msg_alloc (struct msg_msg * msg)
  1756. {
  1757. return security_ops->msg_msg_alloc_security (msg);
  1758. }
  1759. static inline void security_msg_msg_free (struct msg_msg * msg)
  1760. {
  1761. security_ops->msg_msg_free_security(msg);
  1762. }
  1763. static inline int security_msg_queue_alloc (struct msg_queue *msq)
  1764. {
  1765. return security_ops->msg_queue_alloc_security (msq);
  1766. }
  1767. static inline void security_msg_queue_free (struct msg_queue *msq)
  1768. {
  1769. security_ops->msg_queue_free_security (msq);
  1770. }
  1771. static inline int security_msg_queue_associate (struct msg_queue * msq,
  1772. int msqflg)
  1773. {
  1774. return security_ops->msg_queue_associate (msq, msqflg);
  1775. }
  1776. static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
  1777. {
  1778. return security_ops->msg_queue_msgctl (msq, cmd);
  1779. }
  1780. static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
  1781. struct msg_msg * msg, int msqflg)
  1782. {
  1783. return security_ops->msg_queue_msgsnd (msq, msg, msqflg);
  1784. }
  1785. static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
  1786. struct msg_msg * msg,
  1787. struct task_struct * target,
  1788. long type, int mode)
  1789. {
  1790. return security_ops->msg_queue_msgrcv (msq, msg, target, type, mode);
  1791. }
  1792. static inline int security_shm_alloc (struct shmid_kernel *shp)
  1793. {
  1794. return security_ops->shm_alloc_security (shp);
  1795. }
  1796. static inline void security_shm_free (struct shmid_kernel *shp)
  1797. {
  1798. security_ops->shm_free_security (shp);
  1799. }
  1800. static inline int security_shm_associate (struct shmid_kernel * shp,
  1801. int shmflg)
  1802. {
  1803. return security_ops->shm_associate(shp, shmflg);
  1804. }
  1805. static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
  1806. {
  1807. return security_ops->shm_shmctl (shp, cmd);
  1808. }
  1809. static inline int security_shm_shmat (struct shmid_kernel * shp,
  1810. char __user *shmaddr, int shmflg)
  1811. {
  1812. return security_ops->shm_shmat(shp, shmaddr, shmflg);
  1813. }
  1814. static inline int security_sem_alloc (struct sem_array *sma)
  1815. {
  1816. return security_ops->sem_alloc_security (sma);
  1817. }
  1818. static inline void security_sem_free (struct sem_array *sma)
  1819. {
  1820. security_ops->sem_free_security (sma);
  1821. }
  1822. static inline int security_sem_associate (struct sem_array * sma, int semflg)
  1823. {
  1824. return security_ops->sem_associate (sma, semflg);
  1825. }
  1826. static inline int security_sem_semctl (struct sem_array * sma, int cmd)
  1827. {
  1828. return security_ops->sem_semctl(sma, cmd);
  1829. }
  1830. static inline int security_sem_semop (struct sem_array * sma,
  1831. struct sembuf * sops, unsigned nsops,
  1832. int alter)
  1833. {
  1834. return security_ops->sem_semop(sma, sops, nsops, alter);
  1835. }
  1836. static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
  1837. {
  1838. if (unlikely (inode && IS_PRIVATE (inode)))
  1839. return;
  1840. security_ops->d_instantiate (dentry, inode);
  1841. }
  1842. static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
  1843. {
  1844. return security_ops->getprocattr(p, name, value, size);
  1845. }
  1846. static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
  1847. {
  1848. return security_ops->setprocattr(p, name, value, size);
  1849. }
  1850. static inline int security_netlink_send(struct sock *sk, struct sk_buff * skb)
  1851. {
  1852. return security_ops->netlink_send(sk, skb);
  1853. }
  1854. static inline int security_netlink_recv(struct sk_buff * skb)
  1855. {
  1856. return security_ops->netlink_recv(skb);
  1857. }
  1858. /* prototypes */
  1859. extern int security_init (void);
  1860. extern int register_security (struct security_operations *ops);
  1861. extern int unregister_security (struct security_operations *ops);
  1862. extern int mod_reg_security (const char *name, struct security_operations *ops);
  1863. extern int mod_unreg_security (const char *name, struct security_operations *ops);
  1864. extern struct dentry *securityfs_create_file(const char *name, mode_t mode,
  1865. struct dentry *parent, void *data,
  1866. struct file_operations *fops);
  1867. extern struct dentry *securityfs_create_dir(const char *name, struct dentry *parent);
  1868. extern void securityfs_remove(struct dentry *dentry);
  1869. #else /* CONFIG_SECURITY */
  1870. /*
  1871. * This is the default capabilities functionality. Most of these functions
  1872. * are just stubbed out, but a few must call the proper capable code.
  1873. */
  1874. static inline int security_init(void)
  1875. {
  1876. return 0;
  1877. }
  1878. static inline int security_ptrace (struct task_struct *parent, struct task_struct * child)
  1879. {
  1880. return cap_ptrace (parent, child);
  1881. }
  1882. static inline int security_capget (struct task_struct *target,
  1883. kernel_cap_t *effective,
  1884. kernel_cap_t *inheritable,
  1885. kernel_cap_t *permitted)
  1886. {
  1887. return cap_capget (target, effective, inheritable, permitted);
  1888. }
  1889. static inline int security_capset_check (struct task_struct *target,
  1890. kernel_cap_t *effective,
  1891. kernel_cap_t *inheritable,
  1892. kernel_cap_t *permitted)
  1893. {
  1894. return cap_capset_check (target, effective, inheritable, permitted);
  1895. }
  1896. static inline void security_capset_set (struct task_struct *target,
  1897. kernel_cap_t *effective,
  1898. kernel_cap_t *inheritable,
  1899. kernel_cap_t *permitted)
  1900. {
  1901. cap_capset_set (target, effective, inheritable, permitted);
  1902. }
  1903. static inline int security_capable(struct task_struct *tsk, int cap)
  1904. {
  1905. return cap_capable(tsk, cap);
  1906. }
  1907. static inline int security_acct (struct file *file)
  1908. {
  1909. return 0;
  1910. }
  1911. static inline int security_sysctl(struct ctl_table *table, int op)
  1912. {
  1913. return 0;
  1914. }
  1915. static inline int security_quotactl (int cmds, int type, int id,
  1916. struct super_block * sb)
  1917. {
  1918. return 0;
  1919. }
  1920. static inline int security_quota_on (struct dentry * dentry)
  1921. {
  1922. return 0;
  1923. }
  1924. static inline int security_syslog(int type)
  1925. {
  1926. return cap_syslog(type);
  1927. }
  1928. static inline int security_settime(struct timespec *ts, struct timezone *tz)
  1929. {
  1930. return cap_settime(ts, tz);
  1931. }
  1932. static inline int security_vm_enough_memory(long pages)
  1933. {
  1934. return cap_vm_enough_memory(pages);
  1935. }
  1936. static inline int security_bprm_alloc (struct linux_binprm *bprm)
  1937. {
  1938. return 0;
  1939. }
  1940. static inline void security_bprm_free (struct linux_binprm *bprm)
  1941. { }
  1942. static inline void security_bprm_apply_creds (struct linux_binprm *bprm, int unsafe)
  1943. {
  1944. cap_bprm_apply_creds (bprm, unsafe);
  1945. }
  1946. static inline void security_bprm_post_apply_creds (struct linux_binprm *bprm)
  1947. {
  1948. return;
  1949. }
  1950. static inline int security_bprm_set (struct linux_binprm *bprm)
  1951. {
  1952. return cap_bprm_set_security (bprm);
  1953. }
  1954. static inline int security_bprm_check (struct linux_binprm *bprm)
  1955. {
  1956. return 0;
  1957. }
  1958. static inline int security_bprm_secureexec (struct linux_binprm *bprm)
  1959. {
  1960. return cap_bprm_secureexec(bprm);
  1961. }
  1962. static inline int security_sb_alloc (struct super_block *sb)
  1963. {
  1964. return 0;
  1965. }
  1966. static inline void security_sb_free (struct super_block *sb)
  1967. { }
  1968. static inline int security_sb_copy_data (struct file_system_type *type,
  1969. void *orig, void *copy)
  1970. {
  1971. return 0;
  1972. }
  1973. static inline int security_sb_kern_mount (struct super_block *sb, void *data)
  1974. {
  1975. return 0;
  1976. }
  1977. static inline int security_sb_statfs (struct super_block *sb)
  1978. {
  1979. return 0;
  1980. }
  1981. static inline int security_sb_mount (char *dev_name, struct nameidata *nd,
  1982. char *type, unsigned long flags,
  1983. void *data)
  1984. {
  1985. return 0;
  1986. }
  1987. static inline int security_sb_check_sb (struct vfsmount *mnt,
  1988. struct nameidata *nd)
  1989. {
  1990. return 0;
  1991. }
  1992. static inline int security_sb_umount (struct vfsmount *mnt, int flags)
  1993. {
  1994. return 0;
  1995. }
  1996. static inline void security_sb_umount_close (struct vfsmount *mnt)
  1997. { }
  1998. static inline void security_sb_umount_busy (struct vfsmount *mnt)
  1999. { }
  2000. static inline void security_sb_post_remount (struct vfsmount *mnt,
  2001. unsigned long flags, void *data)
  2002. { }
  2003. static inline void security_sb_post_mountroot (void)
  2004. { }
  2005. static inline void security_sb_post_addmount (struct vfsmount *mnt,
  2006. struct nameidata *mountpoint_nd)
  2007. { }
  2008. static inline int security_sb_pivotroot (struct nameidata *old_nd,
  2009. struct nameidata *new_nd)
  2010. {
  2011. return 0;
  2012. }
  2013. static inline void security_sb_post_pivotroot (struct nameidata *old_nd,
  2014. struct nameidata *new_nd)
  2015. { }
  2016. static inline int security_inode_alloc (struct inode *inode)
  2017. {
  2018. return 0;
  2019. }
  2020. static inline void security_inode_free (struct inode *inode)
  2021. { }
  2022. static inline int security_inode_init_security (struct inode *inode,
  2023. struct inode *dir,
  2024. char **name,
  2025. void **value,
  2026. size_t *len)
  2027. {
  2028. return -EOPNOTSUPP;
  2029. }
  2030. static inline int security_inode_create (struct inode *dir,
  2031. struct dentry *dentry,
  2032. int mode)
  2033. {
  2034. return 0;
  2035. }
  2036. static inline int security_inode_link (struct dentry *old_dentry,
  2037. struct inode *dir,
  2038. struct dentry *new_dentry)
  2039. {
  2040. return 0;
  2041. }
  2042. static inline int security_inode_unlink (struct inode *dir,
  2043. struct dentry *dentry)
  2044. {
  2045. return 0;
  2046. }
  2047. static inline int security_inode_symlink (struct inode *dir,
  2048. struct dentry *dentry,
  2049. const char *old_name)
  2050. {
  2051. return 0;
  2052. }
  2053. static inline int security_inode_mkdir (struct inode *dir,
  2054. struct dentry *dentry,
  2055. int mode)
  2056. {
  2057. return 0;
  2058. }
  2059. static inline int security_inode_rmdir (struct inode *dir,
  2060. struct dentry *dentry)
  2061. {
  2062. return 0;
  2063. }
  2064. static inline int security_inode_mknod (struct inode *dir,
  2065. struct dentry *dentry,
  2066. int mode, dev_t dev)
  2067. {
  2068. return 0;
  2069. }
  2070. static inline int security_inode_rename (struct inode *old_dir,
  2071. struct dentry *old_dentry,
  2072. struct inode *new_dir,
  2073. struct dentry *new_dentry)
  2074. {
  2075. return 0;
  2076. }
  2077. static inline int security_inode_readlink (struct dentry *dentry)
  2078. {
  2079. return 0;
  2080. }
  2081. static inline int security_inode_follow_link (struct dentry *dentry,
  2082. struct nameidata *nd)
  2083. {
  2084. return 0;
  2085. }
  2086. static inline int security_inode_permission (struct inode *inode, int mask,
  2087. struct nameidata *nd)
  2088. {
  2089. return 0;
  2090. }
  2091. static inline int security_inode_setattr (struct dentry *dentry,
  2092. struct iattr *attr)
  2093. {
  2094. return 0;
  2095. }
  2096. static inline int security_inode_getattr (struct vfsmount *mnt,
  2097. struct dentry *dentry)
  2098. {
  2099. return 0;
  2100. }
  2101. static inline void security_inode_delete (struct inode *inode)
  2102. { }
  2103. static inline int security_inode_setxattr (struct dentry *dentry, char *name,
  2104. void *value, size_t size, int flags)
  2105. {
  2106. return cap_inode_setxattr(dentry, name, value, size, flags);
  2107. }
  2108. static inline void security_inode_post_setxattr (struct dentry *dentry, char *name,
  2109. void *value, size_t size, int flags)
  2110. { }
  2111. static inline int security_inode_getxattr (struct dentry *dentry, char *name)
  2112. {
  2113. return 0;
  2114. }
  2115. static inline int security_inode_listxattr (struct dentry *dentry)
  2116. {
  2117. return 0;
  2118. }
  2119. static inline int security_inode_removexattr (struct dentry *dentry, char *name)
  2120. {
  2121. return cap_inode_removexattr(dentry, name);
  2122. }
  2123. static inline int security_inode_getsecurity(struct inode *inode, const char *name, void *buffer, size_t size, int err)
  2124. {
  2125. return -EOPNOTSUPP;
  2126. }
  2127. static inline int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
  2128. {
  2129. return -EOPNOTSUPP;
  2130. }
  2131. static inline int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
  2132. {
  2133. return 0;
  2134. }
  2135. static inline int security_file_permission (struct file *file, int mask)
  2136. {
  2137. return 0;
  2138. }
  2139. static inline int security_file_alloc (struct file *file)
  2140. {
  2141. return 0;
  2142. }
  2143. static inline void security_file_free (struct file *file)
  2144. { }
  2145. static inline int security_file_ioctl (struct file *file, unsigned int cmd,
  2146. unsigned long arg)
  2147. {
  2148. return 0;
  2149. }
  2150. static inline int security_file_mmap (struct file *file, unsigned long reqprot,
  2151. unsigned long prot,
  2152. unsigned long flags)
  2153. {
  2154. return 0;
  2155. }
  2156. static inline int security_file_mprotect (struct vm_area_struct *vma,
  2157. unsigned long reqprot,
  2158. unsigned long prot)
  2159. {
  2160. return 0;
  2161. }
  2162. static inline int security_file_lock (struct file *file, unsigned int cmd)
  2163. {
  2164. return 0;
  2165. }
  2166. static inline int security_file_fcntl (struct file *file, unsigned int cmd,
  2167. unsigned long arg)
  2168. {
  2169. return 0;
  2170. }
  2171. static inline int security_file_set_fowner (struct file *file)
  2172. {
  2173. return 0;
  2174. }
  2175. static inline int security_file_send_sigiotask (struct task_struct *tsk,
  2176. struct fown_struct *fown,
  2177. int sig)
  2178. {
  2179. return 0;
  2180. }
  2181. static inline int security_file_receive (struct file *file)
  2182. {
  2183. return 0;
  2184. }
  2185. static inline int security_task_create (unsigned long clone_flags)
  2186. {
  2187. return 0;
  2188. }
  2189. static inline int security_task_alloc (struct task_struct *p)
  2190. {
  2191. return 0;
  2192. }
  2193. static inline void security_task_free (struct task_struct *p)
  2194. { }
  2195. static inline int security_task_setuid (uid_t id0, uid_t id1, uid_t id2,
  2196. int flags)
  2197. {
  2198. return 0;
  2199. }
  2200. static inline int security_task_post_setuid (uid_t old_ruid, uid_t old_euid,
  2201. uid_t old_suid, int flags)
  2202. {
  2203. return cap_task_post_setuid (old_ruid, old_euid, old_suid, flags);
  2204. }
  2205. static inline int security_task_setgid (gid_t id0, gid_t id1, gid_t id2,
  2206. int flags)
  2207. {
  2208. return 0;
  2209. }
  2210. static inline int security_task_setpgid (struct task_struct *p, pid_t pgid)
  2211. {
  2212. return 0;
  2213. }
  2214. static inline int security_task_getpgid (struct task_struct *p)
  2215. {
  2216. return 0;
  2217. }
  2218. static inline int security_task_getsid (struct task_struct *p)
  2219. {
  2220. return 0;
  2221. }
  2222. static inline int security_task_setgroups (struct group_info *group_info)
  2223. {
  2224. return 0;
  2225. }
  2226. static inline int security_task_setnice (struct task_struct *p, int nice)
  2227. {
  2228. return 0;
  2229. }
  2230. static inline int security_task_setrlimit (unsigned int resource,
  2231. struct rlimit *new_rlim)
  2232. {
  2233. return 0;
  2234. }
  2235. static inline int security_task_setscheduler (struct task_struct *p,
  2236. int policy,
  2237. struct sched_param *lp)
  2238. {
  2239. return 0;
  2240. }
  2241. static inline int security_task_getscheduler (struct task_struct *p)
  2242. {
  2243. return 0;
  2244. }
  2245. static inline int security_task_kill (struct task_struct *p,
  2246. struct siginfo *info, int sig)
  2247. {
  2248. return 0;
  2249. }
  2250. static inline int security_task_wait (struct task_struct *p)
  2251. {
  2252. return 0;
  2253. }
  2254. static inline int security_task_prctl (int option, unsigned long arg2,
  2255. unsigned long arg3,
  2256. unsigned long arg4,
  2257. unsigned long arg5)
  2258. {
  2259. return 0;
  2260. }
  2261. static inline void security_task_reparent_to_init (struct task_struct *p)
  2262. {
  2263. cap_task_reparent_to_init (p);
  2264. }
  2265. static inline void security_task_to_inode(struct task_struct *p, struct inode *inode)
  2266. { }
  2267. static inline int security_ipc_permission (struct kern_ipc_perm *ipcp,
  2268. short flag)
  2269. {
  2270. return 0;
  2271. }
  2272. static inline int security_msg_msg_alloc (struct msg_msg * msg)
  2273. {
  2274. return 0;
  2275. }
  2276. static inline void security_msg_msg_free (struct msg_msg * msg)
  2277. { }
  2278. static inline int security_msg_queue_alloc (struct msg_queue *msq)
  2279. {
  2280. return 0;
  2281. }
  2282. static inline void security_msg_queue_free (struct msg_queue *msq)
  2283. { }
  2284. static inline int security_msg_queue_associate (struct msg_queue * msq,
  2285. int msqflg)
  2286. {
  2287. return 0;
  2288. }
  2289. static inline int security_msg_queue_msgctl (struct msg_queue * msq, int cmd)
  2290. {
  2291. return 0;
  2292. }
  2293. static inline int security_msg_queue_msgsnd (struct msg_queue * msq,
  2294. struct msg_msg * msg, int msqflg)
  2295. {
  2296. return 0;
  2297. }
  2298. static inline int security_msg_queue_msgrcv (struct msg_queue * msq,
  2299. struct msg_msg * msg,
  2300. struct task_struct * target,
  2301. long type, int mode)
  2302. {
  2303. return 0;
  2304. }
  2305. static inline int security_shm_alloc (struct shmid_kernel *shp)
  2306. {
  2307. return 0;
  2308. }
  2309. static inline void security_shm_free (struct shmid_kernel *shp)
  2310. { }
  2311. static inline int security_shm_associate (struct shmid_kernel * shp,
  2312. int shmflg)
  2313. {
  2314. return 0;
  2315. }
  2316. static inline int security_shm_shmctl (struct shmid_kernel * shp, int cmd)
  2317. {
  2318. return 0;
  2319. }
  2320. static inline int security_shm_shmat (struct shmid_kernel * shp,
  2321. char __user *shmaddr, int shmflg)
  2322. {
  2323. return 0;
  2324. }
  2325. static inline int security_sem_alloc (struct sem_array *sma)
  2326. {
  2327. return 0;
  2328. }
  2329. static inline void security_sem_free (struct sem_array *sma)
  2330. { }
  2331. static inline int security_sem_associate (struct sem_array * sma, int semflg)
  2332. {
  2333. return 0;
  2334. }
  2335. static inline int security_sem_semctl (struct sem_array * sma, int cmd)
  2336. {
  2337. return 0;
  2338. }
  2339. static inline int security_sem_semop (struct sem_array * sma,
  2340. struct sembuf * sops, unsigned nsops,
  2341. int alter)
  2342. {
  2343. return 0;
  2344. }
  2345. static inline void security_d_instantiate (struct dentry *dentry, struct inode *inode)
  2346. { }
  2347. static inline int security_getprocattr(struct task_struct *p, char *name, void *value, size_t size)
  2348. {
  2349. return -EINVAL;
  2350. }
  2351. static inline int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
  2352. {
  2353. return -EINVAL;
  2354. }
  2355. static inline int security_netlink_send (struct sock *sk, struct sk_buff *skb)
  2356. {
  2357. return cap_netlink_send (sk, skb);
  2358. }
  2359. static inline int security_netlink_recv (struct sk_buff *skb)
  2360. {
  2361. return cap_netlink_recv (skb);
  2362. }
  2363. static inline struct dentry *securityfs_create_dir(const char *name,
  2364. struct dentry *parent)
  2365. {
  2366. return ERR_PTR(-ENODEV);
  2367. }
  2368. static inline struct dentry *securityfs_create_file(const char *name,
  2369. mode_t mode,
  2370. struct dentry *parent,
  2371. void *data,
  2372. struct file_operations *fops)
  2373. {
  2374. return ERR_PTR(-ENODEV);
  2375. }
  2376. static inline void securityfs_remove(struct dentry *dentry)
  2377. {
  2378. }
  2379. #endif /* CONFIG_SECURITY */
  2380. #ifdef CONFIG_SECURITY_NETWORK
  2381. static inline int security_unix_stream_connect(struct socket * sock,
  2382. struct socket * other,
  2383. struct sock * newsk)
  2384. {
  2385. return security_ops->unix_stream_connect(sock, other, newsk);
  2386. }
  2387. static inline int security_unix_may_send(struct socket * sock,
  2388. struct socket * other)
  2389. {
  2390. return security_ops->unix_may_send(sock, other);
  2391. }
  2392. static inline int security_socket_create (int family, int type,
  2393. int protocol, int kern)
  2394. {
  2395. return security_ops->socket_create(family, type, protocol, kern);
  2396. }
  2397. static inline void security_socket_post_create(struct socket * sock,
  2398. int family,
  2399. int type,
  2400. int protocol, int kern)
  2401. {
  2402. security_ops->socket_post_create(sock, family, type,
  2403. protocol, kern);
  2404. }
  2405. static inline int security_socket_bind(struct socket * sock,
  2406. struct sockaddr * address,
  2407. int addrlen)
  2408. {
  2409. return security_ops->socket_bind(sock, address, addrlen);
  2410. }
  2411. static inline int security_socket_connect(struct socket * sock,
  2412. struct sockaddr * address,
  2413. int addrlen)
  2414. {
  2415. return security_ops->socket_connect(sock, address, addrlen);
  2416. }
  2417. static inline int security_socket_listen(struct socket * sock, int backlog)
  2418. {
  2419. return security_ops->socket_listen(sock, backlog);
  2420. }
  2421. static inline int security_socket_accept(struct socket * sock,
  2422. struct socket * newsock)
  2423. {
  2424. return security_ops->socket_accept(sock, newsock);
  2425. }
  2426. static inline void security_socket_post_accept(struct socket * sock,
  2427. struct socket * newsock)
  2428. {
  2429. security_ops->socket_post_accept(sock, newsock);
  2430. }
  2431. static inline int security_socket_sendmsg(struct socket * sock,
  2432. struct msghdr * msg, int size)
  2433. {
  2434. return security_ops->socket_sendmsg(sock, msg, size);
  2435. }
  2436. static inline int security_socket_recvmsg(struct socket * sock,
  2437. struct msghdr * msg, int size,
  2438. int flags)
  2439. {
  2440. return security_ops->socket_recvmsg(sock, msg, size, flags);
  2441. }
  2442. static inline int security_socket_getsockname(struct socket * sock)
  2443. {
  2444. return security_ops->socket_getsockname(sock);
  2445. }
  2446. static inline int security_socket_getpeername(struct socket * sock)
  2447. {
  2448. return security_ops->socket_getpeername(sock);
  2449. }
  2450. static inline int security_socket_getsockopt(struct socket * sock,
  2451. int level, int optname)
  2452. {
  2453. return security_ops->socket_getsockopt(sock, level, optname);
  2454. }
  2455. static inline int security_socket_setsockopt(struct socket * sock,
  2456. int level, int optname)
  2457. {
  2458. return security_ops->socket_setsockopt(sock, level, optname);
  2459. }
  2460. static inline int security_socket_shutdown(struct socket * sock, int how)
  2461. {
  2462. return security_ops->socket_shutdown(sock, how);
  2463. }
  2464. static inline int security_sock_rcv_skb (struct sock * sk,
  2465. struct sk_buff * skb)
  2466. {
  2467. return security_ops->socket_sock_rcv_skb (sk, skb);
  2468. }
  2469. static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
  2470. int __user *optlen, unsigned len)
  2471. {
  2472. return security_ops->socket_getpeersec_stream(sock, optval, optlen, len);
  2473. }
  2474. static inline int security_socket_getpeersec_dgram(struct sk_buff *skb, char **secdata,
  2475. u32 *seclen)
  2476. {
  2477. return security_ops->socket_getpeersec_dgram(skb, secdata, seclen);
  2478. }
  2479. static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
  2480. {
  2481. return security_ops->sk_alloc_security(sk, family, priority);
  2482. }
  2483. static inline void security_sk_free(struct sock *sk)
  2484. {
  2485. return security_ops->sk_free_security(sk);
  2486. }
  2487. static inline unsigned int security_sk_sid(struct sock *sk, struct flowi *fl, u8 dir)
  2488. {
  2489. return security_ops->sk_getsid(sk, fl, dir);
  2490. }
  2491. #else /* CONFIG_SECURITY_NETWORK */
  2492. static inline int security_unix_stream_connect(struct socket * sock,
  2493. struct socket * other,
  2494. struct sock * newsk)
  2495. {
  2496. return 0;
  2497. }
  2498. static inline int security_unix_may_send(struct socket * sock,
  2499. struct socket * other)
  2500. {
  2501. return 0;
  2502. }
  2503. static inline int security_socket_create (int family, int type,
  2504. int protocol, int kern)
  2505. {
  2506. return 0;
  2507. }
  2508. static inline void security_socket_post_create(struct socket * sock,
  2509. int family,
  2510. int type,
  2511. int protocol, int kern)
  2512. {
  2513. }
  2514. static inline int security_socket_bind(struct socket * sock,
  2515. struct sockaddr * address,
  2516. int addrlen)
  2517. {
  2518. return 0;
  2519. }
  2520. static inline int security_socket_connect(struct socket * sock,
  2521. struct sockaddr * address,
  2522. int addrlen)
  2523. {
  2524. return 0;
  2525. }
  2526. static inline int security_socket_listen(struct socket * sock, int backlog)
  2527. {
  2528. return 0;
  2529. }
  2530. static inline int security_socket_accept(struct socket * sock,
  2531. struct socket * newsock)
  2532. {
  2533. return 0;
  2534. }
  2535. static inline void security_socket_post_accept(struct socket * sock,
  2536. struct socket * newsock)
  2537. {
  2538. }
  2539. static inline int security_socket_sendmsg(struct socket * sock,
  2540. struct msghdr * msg, int size)
  2541. {
  2542. return 0;
  2543. }
  2544. static inline int security_socket_recvmsg(struct socket * sock,
  2545. struct msghdr * msg, int size,
  2546. int flags)
  2547. {
  2548. return 0;
  2549. }
  2550. static inline int security_socket_getsockname(struct socket * sock)
  2551. {
  2552. return 0;
  2553. }
  2554. static inline int security_socket_getpeername(struct socket * sock)
  2555. {
  2556. return 0;
  2557. }
  2558. static inline int security_socket_getsockopt(struct socket * sock,
  2559. int level, int optname)
  2560. {
  2561. return 0;
  2562. }
  2563. static inline int security_socket_setsockopt(struct socket * sock,
  2564. int level, int optname)
  2565. {
  2566. return 0;
  2567. }
  2568. static inline int security_socket_shutdown(struct socket * sock, int how)
  2569. {
  2570. return 0;
  2571. }
  2572. static inline int security_sock_rcv_skb (struct sock * sk,
  2573. struct sk_buff * skb)
  2574. {
  2575. return 0;
  2576. }
  2577. static inline int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
  2578. int __user *optlen, unsigned len)
  2579. {
  2580. return -ENOPROTOOPT;
  2581. }
  2582. static inline int security_socket_getpeersec_dgram(struct sk_buff *skb, char **secdata,
  2583. u32 *seclen)
  2584. {
  2585. return -ENOPROTOOPT;
  2586. }
  2587. static inline int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
  2588. {
  2589. return 0;
  2590. }
  2591. static inline void security_sk_free(struct sock *sk)
  2592. {
  2593. }
  2594. static inline unsigned int security_sk_sid(struct sock *sk, struct flowi *fl, u8 dir)
  2595. {
  2596. return 0;
  2597. }
  2598. #endif /* CONFIG_SECURITY_NETWORK */
  2599. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  2600. static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
  2601. {
  2602. return security_ops->xfrm_policy_alloc_security(xp, sec_ctx);
  2603. }
  2604. static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
  2605. {
  2606. return security_ops->xfrm_policy_clone_security(old, new);
  2607. }
  2608. static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
  2609. {
  2610. security_ops->xfrm_policy_free_security(xp);
  2611. }
  2612. static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx)
  2613. {
  2614. return security_ops->xfrm_state_alloc_security(x, sec_ctx);
  2615. }
  2616. static inline void security_xfrm_state_free(struct xfrm_state *x)
  2617. {
  2618. security_ops->xfrm_state_free_security(x);
  2619. }
  2620. static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir)
  2621. {
  2622. return security_ops->xfrm_policy_lookup(xp, sk_sid, dir);
  2623. }
  2624. #else /* CONFIG_SECURITY_NETWORK_XFRM */
  2625. static inline int security_xfrm_policy_alloc(struct xfrm_policy *xp, struct xfrm_user_sec_ctx *sec_ctx)
  2626. {
  2627. return 0;
  2628. }
  2629. static inline int security_xfrm_policy_clone(struct xfrm_policy *old, struct xfrm_policy *new)
  2630. {
  2631. return 0;
  2632. }
  2633. static inline void security_xfrm_policy_free(struct xfrm_policy *xp)
  2634. {
  2635. }
  2636. static inline int security_xfrm_state_alloc(struct xfrm_state *x, struct xfrm_user_sec_ctx *sec_ctx)
  2637. {
  2638. return 0;
  2639. }
  2640. static inline void security_xfrm_state_free(struct xfrm_state *x)
  2641. {
  2642. }
  2643. static inline int security_xfrm_policy_lookup(struct xfrm_policy *xp, u32 sk_sid, u8 dir)
  2644. {
  2645. return 0;
  2646. }
  2647. #endif /* CONFIG_SECURITY_NETWORK_XFRM */
  2648. #ifdef CONFIG_KEYS
  2649. #ifdef CONFIG_SECURITY
  2650. static inline int security_key_alloc(struct key *key)
  2651. {
  2652. return security_ops->key_alloc(key);
  2653. }
  2654. static inline void security_key_free(struct key *key)
  2655. {
  2656. security_ops->key_free(key);
  2657. }
  2658. static inline int security_key_permission(key_ref_t key_ref,
  2659. struct task_struct *context,
  2660. key_perm_t perm)
  2661. {
  2662. return security_ops->key_permission(key_ref, context, perm);
  2663. }
  2664. #else
  2665. static inline int security_key_alloc(struct key *key)
  2666. {
  2667. return 0;
  2668. }
  2669. static inline void security_key_free(struct key *key)
  2670. {
  2671. }
  2672. static inline int security_key_permission(key_ref_t key_ref,
  2673. struct task_struct *context,
  2674. key_perm_t perm)
  2675. {
  2676. return 0;
  2677. }
  2678. #endif
  2679. #endif /* CONFIG_KEYS */
  2680. #endif /* ! __LINUX_SECURITY_H */