security.h 102 KB

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