security.h 104 KB

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