security.h 101 KB

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