security.h 101 KB

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