security.h 103 KB

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