security.c 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893
  1. /*
  2. * Security plug functions
  3. *
  4. * Copyright (C) 2001 WireX Communications, Inc <chris@wirex.com>
  5. * Copyright (C) 2001-2002 Greg Kroah-Hartman <greg@kroah.com>
  6. * Copyright (C) 2001 Networks Associates Technology, Inc <ssmalley@nai.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. */
  13. #include <linux/capability.h>
  14. #include <linux/dcache.h>
  15. #include <linux/module.h>
  16. #include <linux/init.h>
  17. #include <linux/kernel.h>
  18. #include <linux/lsm_hooks.h>
  19. #include <linux/integrity.h>
  20. #include <linux/ima.h>
  21. #include <linux/evm.h>
  22. #include <linux/fsnotify.h>
  23. #include <linux/mman.h>
  24. #include <linux/mount.h>
  25. #include <linux/personality.h>
  26. #include <linux/backing-dev.h>
  27. #include <net/flow.h>
  28. #define MAX_LSM_EVM_XATTR 2
  29. /* Maximum number of letters for an LSM name string */
  30. #define SECURITY_NAME_MAX 10
  31. /* Boot-time LSM user choice */
  32. static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
  33. CONFIG_DEFAULT_SECURITY;
  34. static void __init do_security_initcalls(void)
  35. {
  36. initcall_t *call;
  37. call = __security_initcall_start;
  38. while (call < __security_initcall_end) {
  39. (*call) ();
  40. call++;
  41. }
  42. }
  43. /**
  44. * security_init - initializes the security framework
  45. *
  46. * This should be called early in the kernel initialization sequence.
  47. */
  48. int __init security_init(void)
  49. {
  50. pr_info("Security Framework initialized\n");
  51. /*
  52. * Load minor LSMs, with the capability module always first.
  53. */
  54. capability_add_hooks();
  55. yama_add_hooks();
  56. /*
  57. * Load all the remaining security modules.
  58. */
  59. do_security_initcalls();
  60. return 0;
  61. }
  62. /* Save user chosen LSM */
  63. static int __init choose_lsm(char *str)
  64. {
  65. strncpy(chosen_lsm, str, SECURITY_NAME_MAX);
  66. return 1;
  67. }
  68. __setup("security=", choose_lsm);
  69. /**
  70. * security_module_enable - Load given security module on boot ?
  71. * @module: the name of the module
  72. *
  73. * Each LSM must pass this method before registering its own operations
  74. * to avoid security registration races. This method may also be used
  75. * to check if your LSM is currently loaded during kernel initialization.
  76. *
  77. * Return true if:
  78. * -The passed LSM is the one chosen by user at boot time,
  79. * -or the passed LSM is configured as the default and the user did not
  80. * choose an alternate LSM at boot time.
  81. * Otherwise, return false.
  82. */
  83. int __init security_module_enable(const char *module)
  84. {
  85. return !strcmp(module, chosen_lsm);
  86. }
  87. /*
  88. * Hook list operation macros.
  89. *
  90. * call_void_hook:
  91. * This is a hook that does not return a value.
  92. *
  93. * call_int_hook:
  94. * This is a hook that returns a value.
  95. */
  96. #define call_void_hook(FUNC, ...) \
  97. do { \
  98. struct security_hook_list *P; \
  99. \
  100. list_for_each_entry(P, &security_hook_heads.FUNC, list) \
  101. P->hook.FUNC(__VA_ARGS__); \
  102. } while (0)
  103. #define call_int_hook(FUNC, IRC, ...) ({ \
  104. int RC = IRC; \
  105. do { \
  106. struct security_hook_list *P; \
  107. \
  108. list_for_each_entry(P, &security_hook_heads.FUNC, list) { \
  109. RC = P->hook.FUNC(__VA_ARGS__); \
  110. if (RC != 0) \
  111. break; \
  112. } \
  113. } while (0); \
  114. RC; \
  115. })
  116. /* Security operations */
  117. int security_binder_set_context_mgr(struct task_struct *mgr)
  118. {
  119. return call_int_hook(binder_set_context_mgr, 0, mgr);
  120. }
  121. int security_binder_transaction(struct task_struct *from,
  122. struct task_struct *to)
  123. {
  124. return call_int_hook(binder_transaction, 0, from, to);
  125. }
  126. int security_binder_transfer_binder(struct task_struct *from,
  127. struct task_struct *to)
  128. {
  129. return call_int_hook(binder_transfer_binder, 0, from, to);
  130. }
  131. int security_binder_transfer_file(struct task_struct *from,
  132. struct task_struct *to, struct file *file)
  133. {
  134. return call_int_hook(binder_transfer_file, 0, from, to, file);
  135. }
  136. int security_ptrace_access_check(struct task_struct *child, unsigned int mode)
  137. {
  138. return call_int_hook(ptrace_access_check, 0, child, mode);
  139. }
  140. int security_ptrace_traceme(struct task_struct *parent)
  141. {
  142. return call_int_hook(ptrace_traceme, 0, parent);
  143. }
  144. int security_capget(struct task_struct *target,
  145. kernel_cap_t *effective,
  146. kernel_cap_t *inheritable,
  147. kernel_cap_t *permitted)
  148. {
  149. return call_int_hook(capget, 0, target,
  150. effective, inheritable, permitted);
  151. }
  152. int security_capset(struct cred *new, const struct cred *old,
  153. const kernel_cap_t *effective,
  154. const kernel_cap_t *inheritable,
  155. const kernel_cap_t *permitted)
  156. {
  157. return call_int_hook(capset, 0, new, old,
  158. effective, inheritable, permitted);
  159. }
  160. int security_capable(const struct cred *cred, struct user_namespace *ns,
  161. int cap)
  162. {
  163. return call_int_hook(capable, 0, cred, ns, cap, SECURITY_CAP_AUDIT);
  164. }
  165. int security_capable_noaudit(const struct cred *cred, struct user_namespace *ns,
  166. int cap)
  167. {
  168. return call_int_hook(capable, 0, cred, ns, cap, SECURITY_CAP_NOAUDIT);
  169. }
  170. int security_quotactl(int cmds, int type, int id, struct super_block *sb)
  171. {
  172. return call_int_hook(quotactl, 0, cmds, type, id, sb);
  173. }
  174. int security_quota_on(struct dentry *dentry)
  175. {
  176. return call_int_hook(quota_on, 0, dentry);
  177. }
  178. int security_syslog(int type)
  179. {
  180. return call_int_hook(syslog, 0, type);
  181. }
  182. int security_settime(const struct timespec *ts, const struct timezone *tz)
  183. {
  184. return call_int_hook(settime, 0, ts, tz);
  185. }
  186. int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
  187. {
  188. struct security_hook_list *hp;
  189. int cap_sys_admin = 1;
  190. int rc;
  191. /*
  192. * The module will respond with a positive value if
  193. * it thinks the __vm_enough_memory() call should be
  194. * made with the cap_sys_admin set. If all of the modules
  195. * agree that it should be set it will. If any module
  196. * thinks it should not be set it won't.
  197. */
  198. list_for_each_entry(hp, &security_hook_heads.vm_enough_memory, list) {
  199. rc = hp->hook.vm_enough_memory(mm, pages);
  200. if (rc <= 0) {
  201. cap_sys_admin = 0;
  202. break;
  203. }
  204. }
  205. return __vm_enough_memory(mm, pages, cap_sys_admin);
  206. }
  207. int security_bprm_set_creds(struct linux_binprm *bprm)
  208. {
  209. return call_int_hook(bprm_set_creds, 0, bprm);
  210. }
  211. int security_bprm_check(struct linux_binprm *bprm)
  212. {
  213. int ret;
  214. ret = call_int_hook(bprm_check_security, 0, bprm);
  215. if (ret)
  216. return ret;
  217. return ima_bprm_check(bprm);
  218. }
  219. void security_bprm_committing_creds(struct linux_binprm *bprm)
  220. {
  221. call_void_hook(bprm_committing_creds, bprm);
  222. }
  223. void security_bprm_committed_creds(struct linux_binprm *bprm)
  224. {
  225. call_void_hook(bprm_committed_creds, bprm);
  226. }
  227. int security_bprm_secureexec(struct linux_binprm *bprm)
  228. {
  229. return call_int_hook(bprm_secureexec, 0, bprm);
  230. }
  231. int security_sb_alloc(struct super_block *sb)
  232. {
  233. return call_int_hook(sb_alloc_security, 0, sb);
  234. }
  235. void security_sb_free(struct super_block *sb)
  236. {
  237. call_void_hook(sb_free_security, sb);
  238. }
  239. int security_sb_copy_data(char *orig, char *copy)
  240. {
  241. return call_int_hook(sb_copy_data, 0, orig, copy);
  242. }
  243. EXPORT_SYMBOL(security_sb_copy_data);
  244. int security_sb_remount(struct super_block *sb, void *data)
  245. {
  246. return call_int_hook(sb_remount, 0, sb, data);
  247. }
  248. int security_sb_kern_mount(struct super_block *sb, int flags, void *data)
  249. {
  250. return call_int_hook(sb_kern_mount, 0, sb, flags, data);
  251. }
  252. int security_sb_show_options(struct seq_file *m, struct super_block *sb)
  253. {
  254. return call_int_hook(sb_show_options, 0, m, sb);
  255. }
  256. int security_sb_statfs(struct dentry *dentry)
  257. {
  258. return call_int_hook(sb_statfs, 0, dentry);
  259. }
  260. int security_sb_mount(const char *dev_name, struct path *path,
  261. const char *type, unsigned long flags, void *data)
  262. {
  263. return call_int_hook(sb_mount, 0, dev_name, path, type, flags, data);
  264. }
  265. int security_sb_umount(struct vfsmount *mnt, int flags)
  266. {
  267. return call_int_hook(sb_umount, 0, mnt, flags);
  268. }
  269. int security_sb_pivotroot(struct path *old_path, struct path *new_path)
  270. {
  271. return call_int_hook(sb_pivotroot, 0, old_path, new_path);
  272. }
  273. int security_sb_set_mnt_opts(struct super_block *sb,
  274. struct security_mnt_opts *opts,
  275. unsigned long kern_flags,
  276. unsigned long *set_kern_flags)
  277. {
  278. return call_int_hook(sb_set_mnt_opts,
  279. opts->num_mnt_opts ? -EOPNOTSUPP : 0, sb,
  280. opts, kern_flags, set_kern_flags);
  281. }
  282. EXPORT_SYMBOL(security_sb_set_mnt_opts);
  283. int security_sb_clone_mnt_opts(const struct super_block *oldsb,
  284. struct super_block *newsb)
  285. {
  286. return call_int_hook(sb_clone_mnt_opts, 0, oldsb, newsb);
  287. }
  288. EXPORT_SYMBOL(security_sb_clone_mnt_opts);
  289. int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts)
  290. {
  291. return call_int_hook(sb_parse_opts_str, 0, options, opts);
  292. }
  293. EXPORT_SYMBOL(security_sb_parse_opts_str);
  294. int security_inode_alloc(struct inode *inode)
  295. {
  296. inode->i_security = NULL;
  297. return call_int_hook(inode_alloc_security, 0, inode);
  298. }
  299. void security_inode_free(struct inode *inode)
  300. {
  301. integrity_inode_free(inode);
  302. call_void_hook(inode_free_security, inode);
  303. }
  304. int security_dentry_init_security(struct dentry *dentry, int mode,
  305. struct qstr *name, void **ctx,
  306. u32 *ctxlen)
  307. {
  308. return call_int_hook(dentry_init_security, -EOPNOTSUPP, dentry, mode,
  309. name, ctx, ctxlen);
  310. }
  311. EXPORT_SYMBOL(security_dentry_init_security);
  312. int security_inode_init_security(struct inode *inode, struct inode *dir,
  313. const struct qstr *qstr,
  314. const initxattrs initxattrs, void *fs_data)
  315. {
  316. struct xattr new_xattrs[MAX_LSM_EVM_XATTR + 1];
  317. struct xattr *lsm_xattr, *evm_xattr, *xattr;
  318. int ret;
  319. if (unlikely(IS_PRIVATE(inode)))
  320. return 0;
  321. if (!initxattrs)
  322. return call_int_hook(inode_init_security, -EOPNOTSUPP, inode,
  323. dir, qstr, NULL, NULL, NULL);
  324. memset(new_xattrs, 0, sizeof(new_xattrs));
  325. lsm_xattr = new_xattrs;
  326. ret = call_int_hook(inode_init_security, -EOPNOTSUPP, inode, dir, qstr,
  327. &lsm_xattr->name,
  328. &lsm_xattr->value,
  329. &lsm_xattr->value_len);
  330. if (ret)
  331. goto out;
  332. evm_xattr = lsm_xattr + 1;
  333. ret = evm_inode_init_security(inode, lsm_xattr, evm_xattr);
  334. if (ret)
  335. goto out;
  336. ret = initxattrs(inode, new_xattrs, fs_data);
  337. out:
  338. for (xattr = new_xattrs; xattr->value != NULL; xattr++)
  339. kfree(xattr->value);
  340. return (ret == -EOPNOTSUPP) ? 0 : ret;
  341. }
  342. EXPORT_SYMBOL(security_inode_init_security);
  343. int security_old_inode_init_security(struct inode *inode, struct inode *dir,
  344. const struct qstr *qstr, const char **name,
  345. void **value, size_t *len)
  346. {
  347. if (unlikely(IS_PRIVATE(inode)))
  348. return -EOPNOTSUPP;
  349. return call_int_hook(inode_init_security, -EOPNOTSUPP, inode, dir,
  350. qstr, name, value, len);
  351. }
  352. EXPORT_SYMBOL(security_old_inode_init_security);
  353. #ifdef CONFIG_SECURITY_PATH
  354. int security_path_mknod(struct path *dir, struct dentry *dentry, umode_t mode,
  355. unsigned int dev)
  356. {
  357. if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry))))
  358. return 0;
  359. return call_int_hook(path_mknod, 0, dir, dentry, mode, dev);
  360. }
  361. EXPORT_SYMBOL(security_path_mknod);
  362. int security_path_mkdir(struct path *dir, struct dentry *dentry, umode_t mode)
  363. {
  364. if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry))))
  365. return 0;
  366. return call_int_hook(path_mkdir, 0, dir, dentry, mode);
  367. }
  368. EXPORT_SYMBOL(security_path_mkdir);
  369. int security_path_rmdir(struct path *dir, struct dentry *dentry)
  370. {
  371. if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry))))
  372. return 0;
  373. return call_int_hook(path_rmdir, 0, dir, dentry);
  374. }
  375. int security_path_unlink(struct path *dir, struct dentry *dentry)
  376. {
  377. if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry))))
  378. return 0;
  379. return call_int_hook(path_unlink, 0, dir, dentry);
  380. }
  381. EXPORT_SYMBOL(security_path_unlink);
  382. int security_path_symlink(struct path *dir, struct dentry *dentry,
  383. const char *old_name)
  384. {
  385. if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry))))
  386. return 0;
  387. return call_int_hook(path_symlink, 0, dir, dentry, old_name);
  388. }
  389. int security_path_link(struct dentry *old_dentry, struct path *new_dir,
  390. struct dentry *new_dentry)
  391. {
  392. if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry))))
  393. return 0;
  394. return call_int_hook(path_link, 0, old_dentry, new_dir, new_dentry);
  395. }
  396. int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
  397. struct path *new_dir, struct dentry *new_dentry,
  398. unsigned int flags)
  399. {
  400. if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry)) ||
  401. (d_is_positive(new_dentry) && IS_PRIVATE(d_backing_inode(new_dentry)))))
  402. return 0;
  403. if (flags & RENAME_EXCHANGE) {
  404. int err = call_int_hook(path_rename, 0, new_dir, new_dentry,
  405. old_dir, old_dentry);
  406. if (err)
  407. return err;
  408. }
  409. return call_int_hook(path_rename, 0, old_dir, old_dentry, new_dir,
  410. new_dentry);
  411. }
  412. EXPORT_SYMBOL(security_path_rename);
  413. int security_path_truncate(struct path *path)
  414. {
  415. if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
  416. return 0;
  417. return call_int_hook(path_truncate, 0, path);
  418. }
  419. int security_path_chmod(struct path *path, umode_t mode)
  420. {
  421. if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
  422. return 0;
  423. return call_int_hook(path_chmod, 0, path, mode);
  424. }
  425. int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
  426. {
  427. if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
  428. return 0;
  429. return call_int_hook(path_chown, 0, path, uid, gid);
  430. }
  431. int security_path_chroot(struct path *path)
  432. {
  433. return call_int_hook(path_chroot, 0, path);
  434. }
  435. #endif
  436. int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode)
  437. {
  438. if (unlikely(IS_PRIVATE(dir)))
  439. return 0;
  440. return call_int_hook(inode_create, 0, dir, dentry, mode);
  441. }
  442. EXPORT_SYMBOL_GPL(security_inode_create);
  443. int security_inode_link(struct dentry *old_dentry, struct inode *dir,
  444. struct dentry *new_dentry)
  445. {
  446. if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry))))
  447. return 0;
  448. return call_int_hook(inode_link, 0, old_dentry, dir, new_dentry);
  449. }
  450. int security_inode_unlink(struct inode *dir, struct dentry *dentry)
  451. {
  452. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  453. return 0;
  454. return call_int_hook(inode_unlink, 0, dir, dentry);
  455. }
  456. int security_inode_symlink(struct inode *dir, struct dentry *dentry,
  457. const char *old_name)
  458. {
  459. if (unlikely(IS_PRIVATE(dir)))
  460. return 0;
  461. return call_int_hook(inode_symlink, 0, dir, dentry, old_name);
  462. }
  463. int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
  464. {
  465. if (unlikely(IS_PRIVATE(dir)))
  466. return 0;
  467. return call_int_hook(inode_mkdir, 0, dir, dentry, mode);
  468. }
  469. EXPORT_SYMBOL_GPL(security_inode_mkdir);
  470. int security_inode_rmdir(struct inode *dir, struct dentry *dentry)
  471. {
  472. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  473. return 0;
  474. return call_int_hook(inode_rmdir, 0, dir, dentry);
  475. }
  476. int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
  477. {
  478. if (unlikely(IS_PRIVATE(dir)))
  479. return 0;
  480. return call_int_hook(inode_mknod, 0, dir, dentry, mode, dev);
  481. }
  482. int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
  483. struct inode *new_dir, struct dentry *new_dentry,
  484. unsigned int flags)
  485. {
  486. if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry)) ||
  487. (d_is_positive(new_dentry) && IS_PRIVATE(d_backing_inode(new_dentry)))))
  488. return 0;
  489. if (flags & RENAME_EXCHANGE) {
  490. int err = call_int_hook(inode_rename, 0, new_dir, new_dentry,
  491. old_dir, old_dentry);
  492. if (err)
  493. return err;
  494. }
  495. return call_int_hook(inode_rename, 0, old_dir, old_dentry,
  496. new_dir, new_dentry);
  497. }
  498. int security_inode_readlink(struct dentry *dentry)
  499. {
  500. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  501. return 0;
  502. return call_int_hook(inode_readlink, 0, dentry);
  503. }
  504. int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
  505. bool rcu)
  506. {
  507. if (unlikely(IS_PRIVATE(inode)))
  508. return 0;
  509. return call_int_hook(inode_follow_link, 0, dentry, inode, rcu);
  510. }
  511. int security_inode_permission(struct inode *inode, int mask)
  512. {
  513. if (unlikely(IS_PRIVATE(inode)))
  514. return 0;
  515. return call_int_hook(inode_permission, 0, inode, mask);
  516. }
  517. int security_inode_setattr(struct dentry *dentry, struct iattr *attr)
  518. {
  519. int ret;
  520. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  521. return 0;
  522. ret = call_int_hook(inode_setattr, 0, dentry, attr);
  523. if (ret)
  524. return ret;
  525. return evm_inode_setattr(dentry, attr);
  526. }
  527. EXPORT_SYMBOL_GPL(security_inode_setattr);
  528. int security_inode_getattr(const struct path *path)
  529. {
  530. if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
  531. return 0;
  532. return call_int_hook(inode_getattr, 0, path);
  533. }
  534. int security_inode_setxattr(struct dentry *dentry, const char *name,
  535. const void *value, size_t size, int flags)
  536. {
  537. int ret;
  538. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  539. return 0;
  540. /*
  541. * SELinux and Smack integrate the cap call,
  542. * so assume that all LSMs supplying this call do so.
  543. */
  544. ret = call_int_hook(inode_setxattr, 1, dentry, name, value, size,
  545. flags);
  546. if (ret == 1)
  547. ret = cap_inode_setxattr(dentry, name, value, size, flags);
  548. if (ret)
  549. return ret;
  550. ret = ima_inode_setxattr(dentry, name, value, size);
  551. if (ret)
  552. return ret;
  553. return evm_inode_setxattr(dentry, name, value, size);
  554. }
  555. void security_inode_post_setxattr(struct dentry *dentry, const char *name,
  556. const void *value, size_t size, int flags)
  557. {
  558. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  559. return;
  560. call_void_hook(inode_post_setxattr, dentry, name, value, size, flags);
  561. evm_inode_post_setxattr(dentry, name, value, size);
  562. }
  563. int security_inode_getxattr(struct dentry *dentry, const char *name)
  564. {
  565. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  566. return 0;
  567. return call_int_hook(inode_getxattr, 0, dentry, name);
  568. }
  569. int security_inode_listxattr(struct dentry *dentry)
  570. {
  571. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  572. return 0;
  573. return call_int_hook(inode_listxattr, 0, dentry);
  574. }
  575. int security_inode_removexattr(struct dentry *dentry, const char *name)
  576. {
  577. int ret;
  578. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  579. return 0;
  580. /*
  581. * SELinux and Smack integrate the cap call,
  582. * so assume that all LSMs supplying this call do so.
  583. */
  584. ret = call_int_hook(inode_removexattr, 1, dentry, name);
  585. if (ret == 1)
  586. ret = cap_inode_removexattr(dentry, name);
  587. if (ret)
  588. return ret;
  589. ret = ima_inode_removexattr(dentry, name);
  590. if (ret)
  591. return ret;
  592. return evm_inode_removexattr(dentry, name);
  593. }
  594. int security_inode_need_killpriv(struct dentry *dentry)
  595. {
  596. return call_int_hook(inode_need_killpriv, 0, dentry);
  597. }
  598. int security_inode_killpriv(struct dentry *dentry)
  599. {
  600. return call_int_hook(inode_killpriv, 0, dentry);
  601. }
  602. int security_inode_getsecurity(struct inode *inode, const char *name, void **buffer, bool alloc)
  603. {
  604. if (unlikely(IS_PRIVATE(inode)))
  605. return -EOPNOTSUPP;
  606. return call_int_hook(inode_getsecurity, -EOPNOTSUPP, inode, name,
  607. buffer, alloc);
  608. }
  609. int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
  610. {
  611. if (unlikely(IS_PRIVATE(inode)))
  612. return -EOPNOTSUPP;
  613. return call_int_hook(inode_setsecurity, -EOPNOTSUPP, inode, name,
  614. value, size, flags);
  615. }
  616. int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
  617. {
  618. if (unlikely(IS_PRIVATE(inode)))
  619. return 0;
  620. return call_int_hook(inode_listsecurity, 0, inode, buffer, buffer_size);
  621. }
  622. EXPORT_SYMBOL(security_inode_listsecurity);
  623. void security_inode_getsecid(struct inode *inode, u32 *secid)
  624. {
  625. call_void_hook(inode_getsecid, inode, secid);
  626. }
  627. int security_file_permission(struct file *file, int mask)
  628. {
  629. int ret;
  630. ret = call_int_hook(file_permission, 0, file, mask);
  631. if (ret)
  632. return ret;
  633. return fsnotify_perm(file, mask);
  634. }
  635. int security_file_alloc(struct file *file)
  636. {
  637. return call_int_hook(file_alloc_security, 0, file);
  638. }
  639. void security_file_free(struct file *file)
  640. {
  641. call_void_hook(file_free_security, file);
  642. }
  643. int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  644. {
  645. return call_int_hook(file_ioctl, 0, file, cmd, arg);
  646. }
  647. static inline unsigned long mmap_prot(struct file *file, unsigned long prot)
  648. {
  649. /*
  650. * Does we have PROT_READ and does the application expect
  651. * it to imply PROT_EXEC? If not, nothing to talk about...
  652. */
  653. if ((prot & (PROT_READ | PROT_EXEC)) != PROT_READ)
  654. return prot;
  655. if (!(current->personality & READ_IMPLIES_EXEC))
  656. return prot;
  657. /*
  658. * if that's an anonymous mapping, let it.
  659. */
  660. if (!file)
  661. return prot | PROT_EXEC;
  662. /*
  663. * ditto if it's not on noexec mount, except that on !MMU we need
  664. * NOMMU_MAP_EXEC (== VM_MAYEXEC) in this case
  665. */
  666. if (!path_noexec(&file->f_path)) {
  667. #ifndef CONFIG_MMU
  668. if (file->f_op->mmap_capabilities) {
  669. unsigned caps = file->f_op->mmap_capabilities(file);
  670. if (!(caps & NOMMU_MAP_EXEC))
  671. return prot;
  672. }
  673. #endif
  674. return prot | PROT_EXEC;
  675. }
  676. /* anything on noexec mount won't get PROT_EXEC */
  677. return prot;
  678. }
  679. int security_mmap_file(struct file *file, unsigned long prot,
  680. unsigned long flags)
  681. {
  682. int ret;
  683. ret = call_int_hook(mmap_file, 0, file, prot,
  684. mmap_prot(file, prot), flags);
  685. if (ret)
  686. return ret;
  687. return ima_file_mmap(file, prot);
  688. }
  689. int security_mmap_addr(unsigned long addr)
  690. {
  691. return call_int_hook(mmap_addr, 0, addr);
  692. }
  693. int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
  694. unsigned long prot)
  695. {
  696. return call_int_hook(file_mprotect, 0, vma, reqprot, prot);
  697. }
  698. int security_file_lock(struct file *file, unsigned int cmd)
  699. {
  700. return call_int_hook(file_lock, 0, file, cmd);
  701. }
  702. int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
  703. {
  704. return call_int_hook(file_fcntl, 0, file, cmd, arg);
  705. }
  706. void security_file_set_fowner(struct file *file)
  707. {
  708. call_void_hook(file_set_fowner, file);
  709. }
  710. int security_file_send_sigiotask(struct task_struct *tsk,
  711. struct fown_struct *fown, int sig)
  712. {
  713. return call_int_hook(file_send_sigiotask, 0, tsk, fown, sig);
  714. }
  715. int security_file_receive(struct file *file)
  716. {
  717. return call_int_hook(file_receive, 0, file);
  718. }
  719. int security_file_open(struct file *file, const struct cred *cred)
  720. {
  721. int ret;
  722. ret = call_int_hook(file_open, 0, file, cred);
  723. if (ret)
  724. return ret;
  725. return fsnotify_perm(file, MAY_OPEN);
  726. }
  727. int security_task_create(unsigned long clone_flags)
  728. {
  729. return call_int_hook(task_create, 0, clone_flags);
  730. }
  731. void security_task_free(struct task_struct *task)
  732. {
  733. call_void_hook(task_free, task);
  734. }
  735. int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
  736. {
  737. return call_int_hook(cred_alloc_blank, 0, cred, gfp);
  738. }
  739. void security_cred_free(struct cred *cred)
  740. {
  741. call_void_hook(cred_free, cred);
  742. }
  743. int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp)
  744. {
  745. return call_int_hook(cred_prepare, 0, new, old, gfp);
  746. }
  747. void security_transfer_creds(struct cred *new, const struct cred *old)
  748. {
  749. call_void_hook(cred_transfer, new, old);
  750. }
  751. int security_kernel_act_as(struct cred *new, u32 secid)
  752. {
  753. return call_int_hook(kernel_act_as, 0, new, secid);
  754. }
  755. int security_kernel_create_files_as(struct cred *new, struct inode *inode)
  756. {
  757. return call_int_hook(kernel_create_files_as, 0, new, inode);
  758. }
  759. int security_kernel_fw_from_file(struct file *file, char *buf, size_t size)
  760. {
  761. int ret;
  762. ret = call_int_hook(kernel_fw_from_file, 0, file, buf, size);
  763. if (ret)
  764. return ret;
  765. return ima_fw_from_file(file, buf, size);
  766. }
  767. EXPORT_SYMBOL_GPL(security_kernel_fw_from_file);
  768. int security_kernel_module_request(char *kmod_name)
  769. {
  770. return call_int_hook(kernel_module_request, 0, kmod_name);
  771. }
  772. int security_kernel_module_from_file(struct file *file)
  773. {
  774. int ret;
  775. ret = call_int_hook(kernel_module_from_file, 0, file);
  776. if (ret)
  777. return ret;
  778. return ima_module_check(file);
  779. }
  780. int security_task_fix_setuid(struct cred *new, const struct cred *old,
  781. int flags)
  782. {
  783. return call_int_hook(task_fix_setuid, 0, new, old, flags);
  784. }
  785. int security_task_setpgid(struct task_struct *p, pid_t pgid)
  786. {
  787. return call_int_hook(task_setpgid, 0, p, pgid);
  788. }
  789. int security_task_getpgid(struct task_struct *p)
  790. {
  791. return call_int_hook(task_getpgid, 0, p);
  792. }
  793. int security_task_getsid(struct task_struct *p)
  794. {
  795. return call_int_hook(task_getsid, 0, p);
  796. }
  797. void security_task_getsecid(struct task_struct *p, u32 *secid)
  798. {
  799. *secid = 0;
  800. call_void_hook(task_getsecid, p, secid);
  801. }
  802. EXPORT_SYMBOL(security_task_getsecid);
  803. int security_task_setnice(struct task_struct *p, int nice)
  804. {
  805. return call_int_hook(task_setnice, 0, p, nice);
  806. }
  807. int security_task_setioprio(struct task_struct *p, int ioprio)
  808. {
  809. return call_int_hook(task_setioprio, 0, p, ioprio);
  810. }
  811. int security_task_getioprio(struct task_struct *p)
  812. {
  813. return call_int_hook(task_getioprio, 0, p);
  814. }
  815. int security_task_setrlimit(struct task_struct *p, unsigned int resource,
  816. struct rlimit *new_rlim)
  817. {
  818. return call_int_hook(task_setrlimit, 0, p, resource, new_rlim);
  819. }
  820. int security_task_setscheduler(struct task_struct *p)
  821. {
  822. return call_int_hook(task_setscheduler, 0, p);
  823. }
  824. int security_task_getscheduler(struct task_struct *p)
  825. {
  826. return call_int_hook(task_getscheduler, 0, p);
  827. }
  828. int security_task_movememory(struct task_struct *p)
  829. {
  830. return call_int_hook(task_movememory, 0, p);
  831. }
  832. int security_task_kill(struct task_struct *p, struct siginfo *info,
  833. int sig, u32 secid)
  834. {
  835. return call_int_hook(task_kill, 0, p, info, sig, secid);
  836. }
  837. int security_task_wait(struct task_struct *p)
  838. {
  839. return call_int_hook(task_wait, 0, p);
  840. }
  841. int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
  842. unsigned long arg4, unsigned long arg5)
  843. {
  844. int thisrc;
  845. int rc = -ENOSYS;
  846. struct security_hook_list *hp;
  847. list_for_each_entry(hp, &security_hook_heads.task_prctl, list) {
  848. thisrc = hp->hook.task_prctl(option, arg2, arg3, arg4, arg5);
  849. if (thisrc != -ENOSYS) {
  850. rc = thisrc;
  851. if (thisrc != 0)
  852. break;
  853. }
  854. }
  855. return rc;
  856. }
  857. void security_task_to_inode(struct task_struct *p, struct inode *inode)
  858. {
  859. call_void_hook(task_to_inode, p, inode);
  860. }
  861. int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag)
  862. {
  863. return call_int_hook(ipc_permission, 0, ipcp, flag);
  864. }
  865. void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
  866. {
  867. *secid = 0;
  868. call_void_hook(ipc_getsecid, ipcp, secid);
  869. }
  870. int security_msg_msg_alloc(struct msg_msg *msg)
  871. {
  872. return call_int_hook(msg_msg_alloc_security, 0, msg);
  873. }
  874. void security_msg_msg_free(struct msg_msg *msg)
  875. {
  876. call_void_hook(msg_msg_free_security, msg);
  877. }
  878. int security_msg_queue_alloc(struct msg_queue *msq)
  879. {
  880. return call_int_hook(msg_queue_alloc_security, 0, msq);
  881. }
  882. void security_msg_queue_free(struct msg_queue *msq)
  883. {
  884. call_void_hook(msg_queue_free_security, msq);
  885. }
  886. int security_msg_queue_associate(struct msg_queue *msq, int msqflg)
  887. {
  888. return call_int_hook(msg_queue_associate, 0, msq, msqflg);
  889. }
  890. int security_msg_queue_msgctl(struct msg_queue *msq, int cmd)
  891. {
  892. return call_int_hook(msg_queue_msgctl, 0, msq, cmd);
  893. }
  894. int security_msg_queue_msgsnd(struct msg_queue *msq,
  895. struct msg_msg *msg, int msqflg)
  896. {
  897. return call_int_hook(msg_queue_msgsnd, 0, msq, msg, msqflg);
  898. }
  899. int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
  900. struct task_struct *target, long type, int mode)
  901. {
  902. return call_int_hook(msg_queue_msgrcv, 0, msq, msg, target, type, mode);
  903. }
  904. int security_shm_alloc(struct shmid_kernel *shp)
  905. {
  906. return call_int_hook(shm_alloc_security, 0, shp);
  907. }
  908. void security_shm_free(struct shmid_kernel *shp)
  909. {
  910. call_void_hook(shm_free_security, shp);
  911. }
  912. int security_shm_associate(struct shmid_kernel *shp, int shmflg)
  913. {
  914. return call_int_hook(shm_associate, 0, shp, shmflg);
  915. }
  916. int security_shm_shmctl(struct shmid_kernel *shp, int cmd)
  917. {
  918. return call_int_hook(shm_shmctl, 0, shp, cmd);
  919. }
  920. int security_shm_shmat(struct shmid_kernel *shp, char __user *shmaddr, int shmflg)
  921. {
  922. return call_int_hook(shm_shmat, 0, shp, shmaddr, shmflg);
  923. }
  924. int security_sem_alloc(struct sem_array *sma)
  925. {
  926. return call_int_hook(sem_alloc_security, 0, sma);
  927. }
  928. void security_sem_free(struct sem_array *sma)
  929. {
  930. call_void_hook(sem_free_security, sma);
  931. }
  932. int security_sem_associate(struct sem_array *sma, int semflg)
  933. {
  934. return call_int_hook(sem_associate, 0, sma, semflg);
  935. }
  936. int security_sem_semctl(struct sem_array *sma, int cmd)
  937. {
  938. return call_int_hook(sem_semctl, 0, sma, cmd);
  939. }
  940. int security_sem_semop(struct sem_array *sma, struct sembuf *sops,
  941. unsigned nsops, int alter)
  942. {
  943. return call_int_hook(sem_semop, 0, sma, sops, nsops, alter);
  944. }
  945. void security_d_instantiate(struct dentry *dentry, struct inode *inode)
  946. {
  947. if (unlikely(inode && IS_PRIVATE(inode)))
  948. return;
  949. call_void_hook(d_instantiate, dentry, inode);
  950. }
  951. EXPORT_SYMBOL(security_d_instantiate);
  952. int security_getprocattr(struct task_struct *p, char *name, char **value)
  953. {
  954. return call_int_hook(getprocattr, -EINVAL, p, name, value);
  955. }
  956. int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
  957. {
  958. return call_int_hook(setprocattr, -EINVAL, p, name, value, size);
  959. }
  960. int security_netlink_send(struct sock *sk, struct sk_buff *skb)
  961. {
  962. return call_int_hook(netlink_send, 0, sk, skb);
  963. }
  964. int security_ismaclabel(const char *name)
  965. {
  966. return call_int_hook(ismaclabel, 0, name);
  967. }
  968. EXPORT_SYMBOL(security_ismaclabel);
  969. int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
  970. {
  971. return call_int_hook(secid_to_secctx, -EOPNOTSUPP, secid, secdata,
  972. seclen);
  973. }
  974. EXPORT_SYMBOL(security_secid_to_secctx);
  975. int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid)
  976. {
  977. *secid = 0;
  978. return call_int_hook(secctx_to_secid, 0, secdata, seclen, secid);
  979. }
  980. EXPORT_SYMBOL(security_secctx_to_secid);
  981. void security_release_secctx(char *secdata, u32 seclen)
  982. {
  983. call_void_hook(release_secctx, secdata, seclen);
  984. }
  985. EXPORT_SYMBOL(security_release_secctx);
  986. void security_inode_invalidate_secctx(struct inode *inode)
  987. {
  988. call_void_hook(inode_invalidate_secctx, inode);
  989. }
  990. EXPORT_SYMBOL(security_inode_invalidate_secctx);
  991. int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
  992. {
  993. return call_int_hook(inode_notifysecctx, 0, inode, ctx, ctxlen);
  994. }
  995. EXPORT_SYMBOL(security_inode_notifysecctx);
  996. int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
  997. {
  998. return call_int_hook(inode_setsecctx, 0, dentry, ctx, ctxlen);
  999. }
  1000. EXPORT_SYMBOL(security_inode_setsecctx);
  1001. int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
  1002. {
  1003. return call_int_hook(inode_getsecctx, -EOPNOTSUPP, inode, ctx, ctxlen);
  1004. }
  1005. EXPORT_SYMBOL(security_inode_getsecctx);
  1006. #ifdef CONFIG_SECURITY_NETWORK
  1007. int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk)
  1008. {
  1009. return call_int_hook(unix_stream_connect, 0, sock, other, newsk);
  1010. }
  1011. EXPORT_SYMBOL(security_unix_stream_connect);
  1012. int security_unix_may_send(struct socket *sock, struct socket *other)
  1013. {
  1014. return call_int_hook(unix_may_send, 0, sock, other);
  1015. }
  1016. EXPORT_SYMBOL(security_unix_may_send);
  1017. int security_socket_create(int family, int type, int protocol, int kern)
  1018. {
  1019. return call_int_hook(socket_create, 0, family, type, protocol, kern);
  1020. }
  1021. int security_socket_post_create(struct socket *sock, int family,
  1022. int type, int protocol, int kern)
  1023. {
  1024. return call_int_hook(socket_post_create, 0, sock, family, type,
  1025. protocol, kern);
  1026. }
  1027. int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen)
  1028. {
  1029. return call_int_hook(socket_bind, 0, sock, address, addrlen);
  1030. }
  1031. int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen)
  1032. {
  1033. return call_int_hook(socket_connect, 0, sock, address, addrlen);
  1034. }
  1035. int security_socket_listen(struct socket *sock, int backlog)
  1036. {
  1037. return call_int_hook(socket_listen, 0, sock, backlog);
  1038. }
  1039. int security_socket_accept(struct socket *sock, struct socket *newsock)
  1040. {
  1041. return call_int_hook(socket_accept, 0, sock, newsock);
  1042. }
  1043. int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size)
  1044. {
  1045. return call_int_hook(socket_sendmsg, 0, sock, msg, size);
  1046. }
  1047. int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
  1048. int size, int flags)
  1049. {
  1050. return call_int_hook(socket_recvmsg, 0, sock, msg, size, flags);
  1051. }
  1052. int security_socket_getsockname(struct socket *sock)
  1053. {
  1054. return call_int_hook(socket_getsockname, 0, sock);
  1055. }
  1056. int security_socket_getpeername(struct socket *sock)
  1057. {
  1058. return call_int_hook(socket_getpeername, 0, sock);
  1059. }
  1060. int security_socket_getsockopt(struct socket *sock, int level, int optname)
  1061. {
  1062. return call_int_hook(socket_getsockopt, 0, sock, level, optname);
  1063. }
  1064. int security_socket_setsockopt(struct socket *sock, int level, int optname)
  1065. {
  1066. return call_int_hook(socket_setsockopt, 0, sock, level, optname);
  1067. }
  1068. int security_socket_shutdown(struct socket *sock, int how)
  1069. {
  1070. return call_int_hook(socket_shutdown, 0, sock, how);
  1071. }
  1072. int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
  1073. {
  1074. return call_int_hook(socket_sock_rcv_skb, 0, sk, skb);
  1075. }
  1076. EXPORT_SYMBOL(security_sock_rcv_skb);
  1077. int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
  1078. int __user *optlen, unsigned len)
  1079. {
  1080. return call_int_hook(socket_getpeersec_stream, -ENOPROTOOPT, sock,
  1081. optval, optlen, len);
  1082. }
  1083. int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
  1084. {
  1085. return call_int_hook(socket_getpeersec_dgram, -ENOPROTOOPT, sock,
  1086. skb, secid);
  1087. }
  1088. EXPORT_SYMBOL(security_socket_getpeersec_dgram);
  1089. int security_sk_alloc(struct sock *sk, int family, gfp_t priority)
  1090. {
  1091. return call_int_hook(sk_alloc_security, 0, sk, family, priority);
  1092. }
  1093. void security_sk_free(struct sock *sk)
  1094. {
  1095. call_void_hook(sk_free_security, sk);
  1096. }
  1097. void security_sk_clone(const struct sock *sk, struct sock *newsk)
  1098. {
  1099. call_void_hook(sk_clone_security, sk, newsk);
  1100. }
  1101. EXPORT_SYMBOL(security_sk_clone);
  1102. void security_sk_classify_flow(struct sock *sk, struct flowi *fl)
  1103. {
  1104. call_void_hook(sk_getsecid, sk, &fl->flowi_secid);
  1105. }
  1106. EXPORT_SYMBOL(security_sk_classify_flow);
  1107. void security_req_classify_flow(const struct request_sock *req, struct flowi *fl)
  1108. {
  1109. call_void_hook(req_classify_flow, req, fl);
  1110. }
  1111. EXPORT_SYMBOL(security_req_classify_flow);
  1112. void security_sock_graft(struct sock *sk, struct socket *parent)
  1113. {
  1114. call_void_hook(sock_graft, sk, parent);
  1115. }
  1116. EXPORT_SYMBOL(security_sock_graft);
  1117. int security_inet_conn_request(struct sock *sk,
  1118. struct sk_buff *skb, struct request_sock *req)
  1119. {
  1120. return call_int_hook(inet_conn_request, 0, sk, skb, req);
  1121. }
  1122. EXPORT_SYMBOL(security_inet_conn_request);
  1123. void security_inet_csk_clone(struct sock *newsk,
  1124. const struct request_sock *req)
  1125. {
  1126. call_void_hook(inet_csk_clone, newsk, req);
  1127. }
  1128. void security_inet_conn_established(struct sock *sk,
  1129. struct sk_buff *skb)
  1130. {
  1131. call_void_hook(inet_conn_established, sk, skb);
  1132. }
  1133. int security_secmark_relabel_packet(u32 secid)
  1134. {
  1135. return call_int_hook(secmark_relabel_packet, 0, secid);
  1136. }
  1137. EXPORT_SYMBOL(security_secmark_relabel_packet);
  1138. void security_secmark_refcount_inc(void)
  1139. {
  1140. call_void_hook(secmark_refcount_inc);
  1141. }
  1142. EXPORT_SYMBOL(security_secmark_refcount_inc);
  1143. void security_secmark_refcount_dec(void)
  1144. {
  1145. call_void_hook(secmark_refcount_dec);
  1146. }
  1147. EXPORT_SYMBOL(security_secmark_refcount_dec);
  1148. int security_tun_dev_alloc_security(void **security)
  1149. {
  1150. return call_int_hook(tun_dev_alloc_security, 0, security);
  1151. }
  1152. EXPORT_SYMBOL(security_tun_dev_alloc_security);
  1153. void security_tun_dev_free_security(void *security)
  1154. {
  1155. call_void_hook(tun_dev_free_security, security);
  1156. }
  1157. EXPORT_SYMBOL(security_tun_dev_free_security);
  1158. int security_tun_dev_create(void)
  1159. {
  1160. return call_int_hook(tun_dev_create, 0);
  1161. }
  1162. EXPORT_SYMBOL(security_tun_dev_create);
  1163. int security_tun_dev_attach_queue(void *security)
  1164. {
  1165. return call_int_hook(tun_dev_attach_queue, 0, security);
  1166. }
  1167. EXPORT_SYMBOL(security_tun_dev_attach_queue);
  1168. int security_tun_dev_attach(struct sock *sk, void *security)
  1169. {
  1170. return call_int_hook(tun_dev_attach, 0, sk, security);
  1171. }
  1172. EXPORT_SYMBOL(security_tun_dev_attach);
  1173. int security_tun_dev_open(void *security)
  1174. {
  1175. return call_int_hook(tun_dev_open, 0, security);
  1176. }
  1177. EXPORT_SYMBOL(security_tun_dev_open);
  1178. #endif /* CONFIG_SECURITY_NETWORK */
  1179. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  1180. int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
  1181. struct xfrm_user_sec_ctx *sec_ctx,
  1182. gfp_t gfp)
  1183. {
  1184. return call_int_hook(xfrm_policy_alloc_security, 0, ctxp, sec_ctx, gfp);
  1185. }
  1186. EXPORT_SYMBOL(security_xfrm_policy_alloc);
  1187. int security_xfrm_policy_clone(struct xfrm_sec_ctx *old_ctx,
  1188. struct xfrm_sec_ctx **new_ctxp)
  1189. {
  1190. return call_int_hook(xfrm_policy_clone_security, 0, old_ctx, new_ctxp);
  1191. }
  1192. void security_xfrm_policy_free(struct xfrm_sec_ctx *ctx)
  1193. {
  1194. call_void_hook(xfrm_policy_free_security, ctx);
  1195. }
  1196. EXPORT_SYMBOL(security_xfrm_policy_free);
  1197. int security_xfrm_policy_delete(struct xfrm_sec_ctx *ctx)
  1198. {
  1199. return call_int_hook(xfrm_policy_delete_security, 0, ctx);
  1200. }
  1201. int security_xfrm_state_alloc(struct xfrm_state *x,
  1202. struct xfrm_user_sec_ctx *sec_ctx)
  1203. {
  1204. return call_int_hook(xfrm_state_alloc, 0, x, sec_ctx);
  1205. }
  1206. EXPORT_SYMBOL(security_xfrm_state_alloc);
  1207. int security_xfrm_state_alloc_acquire(struct xfrm_state *x,
  1208. struct xfrm_sec_ctx *polsec, u32 secid)
  1209. {
  1210. return call_int_hook(xfrm_state_alloc_acquire, 0, x, polsec, secid);
  1211. }
  1212. int security_xfrm_state_delete(struct xfrm_state *x)
  1213. {
  1214. return call_int_hook(xfrm_state_delete_security, 0, x);
  1215. }
  1216. EXPORT_SYMBOL(security_xfrm_state_delete);
  1217. void security_xfrm_state_free(struct xfrm_state *x)
  1218. {
  1219. call_void_hook(xfrm_state_free_security, x);
  1220. }
  1221. int security_xfrm_policy_lookup(struct xfrm_sec_ctx *ctx, u32 fl_secid, u8 dir)
  1222. {
  1223. return call_int_hook(xfrm_policy_lookup, 0, ctx, fl_secid, dir);
  1224. }
  1225. int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
  1226. struct xfrm_policy *xp,
  1227. const struct flowi *fl)
  1228. {
  1229. struct security_hook_list *hp;
  1230. int rc = 1;
  1231. /*
  1232. * Since this function is expected to return 0 or 1, the judgment
  1233. * becomes difficult if multiple LSMs supply this call. Fortunately,
  1234. * we can use the first LSM's judgment because currently only SELinux
  1235. * supplies this call.
  1236. *
  1237. * For speed optimization, we explicitly break the loop rather than
  1238. * using the macro
  1239. */
  1240. list_for_each_entry(hp, &security_hook_heads.xfrm_state_pol_flow_match,
  1241. list) {
  1242. rc = hp->hook.xfrm_state_pol_flow_match(x, xp, fl);
  1243. break;
  1244. }
  1245. return rc;
  1246. }
  1247. int security_xfrm_decode_session(struct sk_buff *skb, u32 *secid)
  1248. {
  1249. return call_int_hook(xfrm_decode_session, 0, skb, secid, 1);
  1250. }
  1251. void security_skb_classify_flow(struct sk_buff *skb, struct flowi *fl)
  1252. {
  1253. int rc = call_int_hook(xfrm_decode_session, 0, skb, &fl->flowi_secid,
  1254. 0);
  1255. BUG_ON(rc);
  1256. }
  1257. EXPORT_SYMBOL(security_skb_classify_flow);
  1258. #endif /* CONFIG_SECURITY_NETWORK_XFRM */
  1259. #ifdef CONFIG_KEYS
  1260. int security_key_alloc(struct key *key, const struct cred *cred,
  1261. unsigned long flags)
  1262. {
  1263. return call_int_hook(key_alloc, 0, key, cred, flags);
  1264. }
  1265. void security_key_free(struct key *key)
  1266. {
  1267. call_void_hook(key_free, key);
  1268. }
  1269. int security_key_permission(key_ref_t key_ref,
  1270. const struct cred *cred, unsigned perm)
  1271. {
  1272. return call_int_hook(key_permission, 0, key_ref, cred, perm);
  1273. }
  1274. int security_key_getsecurity(struct key *key, char **_buffer)
  1275. {
  1276. *_buffer = NULL;
  1277. return call_int_hook(key_getsecurity, 0, key, _buffer);
  1278. }
  1279. #endif /* CONFIG_KEYS */
  1280. #ifdef CONFIG_AUDIT
  1281. int security_audit_rule_init(u32 field, u32 op, char *rulestr, void **lsmrule)
  1282. {
  1283. return call_int_hook(audit_rule_init, 0, field, op, rulestr, lsmrule);
  1284. }
  1285. int security_audit_rule_known(struct audit_krule *krule)
  1286. {
  1287. return call_int_hook(audit_rule_known, 0, krule);
  1288. }
  1289. void security_audit_rule_free(void *lsmrule)
  1290. {
  1291. call_void_hook(audit_rule_free, lsmrule);
  1292. }
  1293. int security_audit_rule_match(u32 secid, u32 field, u32 op, void *lsmrule,
  1294. struct audit_context *actx)
  1295. {
  1296. return call_int_hook(audit_rule_match, 0, secid, field, op, lsmrule,
  1297. actx);
  1298. }
  1299. #endif /* CONFIG_AUDIT */
  1300. struct security_hook_heads security_hook_heads = {
  1301. .binder_set_context_mgr =
  1302. LIST_HEAD_INIT(security_hook_heads.binder_set_context_mgr),
  1303. .binder_transaction =
  1304. LIST_HEAD_INIT(security_hook_heads.binder_transaction),
  1305. .binder_transfer_binder =
  1306. LIST_HEAD_INIT(security_hook_heads.binder_transfer_binder),
  1307. .binder_transfer_file =
  1308. LIST_HEAD_INIT(security_hook_heads.binder_transfer_file),
  1309. .ptrace_access_check =
  1310. LIST_HEAD_INIT(security_hook_heads.ptrace_access_check),
  1311. .ptrace_traceme =
  1312. LIST_HEAD_INIT(security_hook_heads.ptrace_traceme),
  1313. .capget = LIST_HEAD_INIT(security_hook_heads.capget),
  1314. .capset = LIST_HEAD_INIT(security_hook_heads.capset),
  1315. .capable = LIST_HEAD_INIT(security_hook_heads.capable),
  1316. .quotactl = LIST_HEAD_INIT(security_hook_heads.quotactl),
  1317. .quota_on = LIST_HEAD_INIT(security_hook_heads.quota_on),
  1318. .syslog = LIST_HEAD_INIT(security_hook_heads.syslog),
  1319. .settime = LIST_HEAD_INIT(security_hook_heads.settime),
  1320. .vm_enough_memory =
  1321. LIST_HEAD_INIT(security_hook_heads.vm_enough_memory),
  1322. .bprm_set_creds =
  1323. LIST_HEAD_INIT(security_hook_heads.bprm_set_creds),
  1324. .bprm_check_security =
  1325. LIST_HEAD_INIT(security_hook_heads.bprm_check_security),
  1326. .bprm_secureexec =
  1327. LIST_HEAD_INIT(security_hook_heads.bprm_secureexec),
  1328. .bprm_committing_creds =
  1329. LIST_HEAD_INIT(security_hook_heads.bprm_committing_creds),
  1330. .bprm_committed_creds =
  1331. LIST_HEAD_INIT(security_hook_heads.bprm_committed_creds),
  1332. .sb_alloc_security =
  1333. LIST_HEAD_INIT(security_hook_heads.sb_alloc_security),
  1334. .sb_free_security =
  1335. LIST_HEAD_INIT(security_hook_heads.sb_free_security),
  1336. .sb_copy_data = LIST_HEAD_INIT(security_hook_heads.sb_copy_data),
  1337. .sb_remount = LIST_HEAD_INIT(security_hook_heads.sb_remount),
  1338. .sb_kern_mount =
  1339. LIST_HEAD_INIT(security_hook_heads.sb_kern_mount),
  1340. .sb_show_options =
  1341. LIST_HEAD_INIT(security_hook_heads.sb_show_options),
  1342. .sb_statfs = LIST_HEAD_INIT(security_hook_heads.sb_statfs),
  1343. .sb_mount = LIST_HEAD_INIT(security_hook_heads.sb_mount),
  1344. .sb_umount = LIST_HEAD_INIT(security_hook_heads.sb_umount),
  1345. .sb_pivotroot = LIST_HEAD_INIT(security_hook_heads.sb_pivotroot),
  1346. .sb_set_mnt_opts =
  1347. LIST_HEAD_INIT(security_hook_heads.sb_set_mnt_opts),
  1348. .sb_clone_mnt_opts =
  1349. LIST_HEAD_INIT(security_hook_heads.sb_clone_mnt_opts),
  1350. .sb_parse_opts_str =
  1351. LIST_HEAD_INIT(security_hook_heads.sb_parse_opts_str),
  1352. .dentry_init_security =
  1353. LIST_HEAD_INIT(security_hook_heads.dentry_init_security),
  1354. #ifdef CONFIG_SECURITY_PATH
  1355. .path_unlink = LIST_HEAD_INIT(security_hook_heads.path_unlink),
  1356. .path_mkdir = LIST_HEAD_INIT(security_hook_heads.path_mkdir),
  1357. .path_rmdir = LIST_HEAD_INIT(security_hook_heads.path_rmdir),
  1358. .path_mknod = LIST_HEAD_INIT(security_hook_heads.path_mknod),
  1359. .path_truncate =
  1360. LIST_HEAD_INIT(security_hook_heads.path_truncate),
  1361. .path_symlink = LIST_HEAD_INIT(security_hook_heads.path_symlink),
  1362. .path_link = LIST_HEAD_INIT(security_hook_heads.path_link),
  1363. .path_rename = LIST_HEAD_INIT(security_hook_heads.path_rename),
  1364. .path_chmod = LIST_HEAD_INIT(security_hook_heads.path_chmod),
  1365. .path_chown = LIST_HEAD_INIT(security_hook_heads.path_chown),
  1366. .path_chroot = LIST_HEAD_INIT(security_hook_heads.path_chroot),
  1367. #endif
  1368. .inode_alloc_security =
  1369. LIST_HEAD_INIT(security_hook_heads.inode_alloc_security),
  1370. .inode_free_security =
  1371. LIST_HEAD_INIT(security_hook_heads.inode_free_security),
  1372. .inode_init_security =
  1373. LIST_HEAD_INIT(security_hook_heads.inode_init_security),
  1374. .inode_create = LIST_HEAD_INIT(security_hook_heads.inode_create),
  1375. .inode_link = LIST_HEAD_INIT(security_hook_heads.inode_link),
  1376. .inode_unlink = LIST_HEAD_INIT(security_hook_heads.inode_unlink),
  1377. .inode_symlink =
  1378. LIST_HEAD_INIT(security_hook_heads.inode_symlink),
  1379. .inode_mkdir = LIST_HEAD_INIT(security_hook_heads.inode_mkdir),
  1380. .inode_rmdir = LIST_HEAD_INIT(security_hook_heads.inode_rmdir),
  1381. .inode_mknod = LIST_HEAD_INIT(security_hook_heads.inode_mknod),
  1382. .inode_rename = LIST_HEAD_INIT(security_hook_heads.inode_rename),
  1383. .inode_readlink =
  1384. LIST_HEAD_INIT(security_hook_heads.inode_readlink),
  1385. .inode_follow_link =
  1386. LIST_HEAD_INIT(security_hook_heads.inode_follow_link),
  1387. .inode_permission =
  1388. LIST_HEAD_INIT(security_hook_heads.inode_permission),
  1389. .inode_setattr =
  1390. LIST_HEAD_INIT(security_hook_heads.inode_setattr),
  1391. .inode_getattr =
  1392. LIST_HEAD_INIT(security_hook_heads.inode_getattr),
  1393. .inode_setxattr =
  1394. LIST_HEAD_INIT(security_hook_heads.inode_setxattr),
  1395. .inode_post_setxattr =
  1396. LIST_HEAD_INIT(security_hook_heads.inode_post_setxattr),
  1397. .inode_getxattr =
  1398. LIST_HEAD_INIT(security_hook_heads.inode_getxattr),
  1399. .inode_listxattr =
  1400. LIST_HEAD_INIT(security_hook_heads.inode_listxattr),
  1401. .inode_removexattr =
  1402. LIST_HEAD_INIT(security_hook_heads.inode_removexattr),
  1403. .inode_need_killpriv =
  1404. LIST_HEAD_INIT(security_hook_heads.inode_need_killpriv),
  1405. .inode_killpriv =
  1406. LIST_HEAD_INIT(security_hook_heads.inode_killpriv),
  1407. .inode_getsecurity =
  1408. LIST_HEAD_INIT(security_hook_heads.inode_getsecurity),
  1409. .inode_setsecurity =
  1410. LIST_HEAD_INIT(security_hook_heads.inode_setsecurity),
  1411. .inode_listsecurity =
  1412. LIST_HEAD_INIT(security_hook_heads.inode_listsecurity),
  1413. .inode_getsecid =
  1414. LIST_HEAD_INIT(security_hook_heads.inode_getsecid),
  1415. .file_permission =
  1416. LIST_HEAD_INIT(security_hook_heads.file_permission),
  1417. .file_alloc_security =
  1418. LIST_HEAD_INIT(security_hook_heads.file_alloc_security),
  1419. .file_free_security =
  1420. LIST_HEAD_INIT(security_hook_heads.file_free_security),
  1421. .file_ioctl = LIST_HEAD_INIT(security_hook_heads.file_ioctl),
  1422. .mmap_addr = LIST_HEAD_INIT(security_hook_heads.mmap_addr),
  1423. .mmap_file = LIST_HEAD_INIT(security_hook_heads.mmap_file),
  1424. .file_mprotect =
  1425. LIST_HEAD_INIT(security_hook_heads.file_mprotect),
  1426. .file_lock = LIST_HEAD_INIT(security_hook_heads.file_lock),
  1427. .file_fcntl = LIST_HEAD_INIT(security_hook_heads.file_fcntl),
  1428. .file_set_fowner =
  1429. LIST_HEAD_INIT(security_hook_heads.file_set_fowner),
  1430. .file_send_sigiotask =
  1431. LIST_HEAD_INIT(security_hook_heads.file_send_sigiotask),
  1432. .file_receive = LIST_HEAD_INIT(security_hook_heads.file_receive),
  1433. .file_open = LIST_HEAD_INIT(security_hook_heads.file_open),
  1434. .task_create = LIST_HEAD_INIT(security_hook_heads.task_create),
  1435. .task_free = LIST_HEAD_INIT(security_hook_heads.task_free),
  1436. .cred_alloc_blank =
  1437. LIST_HEAD_INIT(security_hook_heads.cred_alloc_blank),
  1438. .cred_free = LIST_HEAD_INIT(security_hook_heads.cred_free),
  1439. .cred_prepare = LIST_HEAD_INIT(security_hook_heads.cred_prepare),
  1440. .cred_transfer =
  1441. LIST_HEAD_INIT(security_hook_heads.cred_transfer),
  1442. .kernel_act_as =
  1443. LIST_HEAD_INIT(security_hook_heads.kernel_act_as),
  1444. .kernel_create_files_as =
  1445. LIST_HEAD_INIT(security_hook_heads.kernel_create_files_as),
  1446. .kernel_fw_from_file =
  1447. LIST_HEAD_INIT(security_hook_heads.kernel_fw_from_file),
  1448. .kernel_module_request =
  1449. LIST_HEAD_INIT(security_hook_heads.kernel_module_request),
  1450. .kernel_module_from_file =
  1451. LIST_HEAD_INIT(security_hook_heads.kernel_module_from_file),
  1452. .task_fix_setuid =
  1453. LIST_HEAD_INIT(security_hook_heads.task_fix_setuid),
  1454. .task_setpgid = LIST_HEAD_INIT(security_hook_heads.task_setpgid),
  1455. .task_getpgid = LIST_HEAD_INIT(security_hook_heads.task_getpgid),
  1456. .task_getsid = LIST_HEAD_INIT(security_hook_heads.task_getsid),
  1457. .task_getsecid =
  1458. LIST_HEAD_INIT(security_hook_heads.task_getsecid),
  1459. .task_setnice = LIST_HEAD_INIT(security_hook_heads.task_setnice),
  1460. .task_setioprio =
  1461. LIST_HEAD_INIT(security_hook_heads.task_setioprio),
  1462. .task_getioprio =
  1463. LIST_HEAD_INIT(security_hook_heads.task_getioprio),
  1464. .task_setrlimit =
  1465. LIST_HEAD_INIT(security_hook_heads.task_setrlimit),
  1466. .task_setscheduler =
  1467. LIST_HEAD_INIT(security_hook_heads.task_setscheduler),
  1468. .task_getscheduler =
  1469. LIST_HEAD_INIT(security_hook_heads.task_getscheduler),
  1470. .task_movememory =
  1471. LIST_HEAD_INIT(security_hook_heads.task_movememory),
  1472. .task_kill = LIST_HEAD_INIT(security_hook_heads.task_kill),
  1473. .task_wait = LIST_HEAD_INIT(security_hook_heads.task_wait),
  1474. .task_prctl = LIST_HEAD_INIT(security_hook_heads.task_prctl),
  1475. .task_to_inode =
  1476. LIST_HEAD_INIT(security_hook_heads.task_to_inode),
  1477. .ipc_permission =
  1478. LIST_HEAD_INIT(security_hook_heads.ipc_permission),
  1479. .ipc_getsecid = LIST_HEAD_INIT(security_hook_heads.ipc_getsecid),
  1480. .msg_msg_alloc_security =
  1481. LIST_HEAD_INIT(security_hook_heads.msg_msg_alloc_security),
  1482. .msg_msg_free_security =
  1483. LIST_HEAD_INIT(security_hook_heads.msg_msg_free_security),
  1484. .msg_queue_alloc_security =
  1485. LIST_HEAD_INIT(security_hook_heads.msg_queue_alloc_security),
  1486. .msg_queue_free_security =
  1487. LIST_HEAD_INIT(security_hook_heads.msg_queue_free_security),
  1488. .msg_queue_associate =
  1489. LIST_HEAD_INIT(security_hook_heads.msg_queue_associate),
  1490. .msg_queue_msgctl =
  1491. LIST_HEAD_INIT(security_hook_heads.msg_queue_msgctl),
  1492. .msg_queue_msgsnd =
  1493. LIST_HEAD_INIT(security_hook_heads.msg_queue_msgsnd),
  1494. .msg_queue_msgrcv =
  1495. LIST_HEAD_INIT(security_hook_heads.msg_queue_msgrcv),
  1496. .shm_alloc_security =
  1497. LIST_HEAD_INIT(security_hook_heads.shm_alloc_security),
  1498. .shm_free_security =
  1499. LIST_HEAD_INIT(security_hook_heads.shm_free_security),
  1500. .shm_associate =
  1501. LIST_HEAD_INIT(security_hook_heads.shm_associate),
  1502. .shm_shmctl = LIST_HEAD_INIT(security_hook_heads.shm_shmctl),
  1503. .shm_shmat = LIST_HEAD_INIT(security_hook_heads.shm_shmat),
  1504. .sem_alloc_security =
  1505. LIST_HEAD_INIT(security_hook_heads.sem_alloc_security),
  1506. .sem_free_security =
  1507. LIST_HEAD_INIT(security_hook_heads.sem_free_security),
  1508. .sem_associate =
  1509. LIST_HEAD_INIT(security_hook_heads.sem_associate),
  1510. .sem_semctl = LIST_HEAD_INIT(security_hook_heads.sem_semctl),
  1511. .sem_semop = LIST_HEAD_INIT(security_hook_heads.sem_semop),
  1512. .netlink_send = LIST_HEAD_INIT(security_hook_heads.netlink_send),
  1513. .d_instantiate =
  1514. LIST_HEAD_INIT(security_hook_heads.d_instantiate),
  1515. .getprocattr = LIST_HEAD_INIT(security_hook_heads.getprocattr),
  1516. .setprocattr = LIST_HEAD_INIT(security_hook_heads.setprocattr),
  1517. .ismaclabel = LIST_HEAD_INIT(security_hook_heads.ismaclabel),
  1518. .secid_to_secctx =
  1519. LIST_HEAD_INIT(security_hook_heads.secid_to_secctx),
  1520. .secctx_to_secid =
  1521. LIST_HEAD_INIT(security_hook_heads.secctx_to_secid),
  1522. .release_secctx =
  1523. LIST_HEAD_INIT(security_hook_heads.release_secctx),
  1524. .inode_invalidate_secctx =
  1525. LIST_HEAD_INIT(security_hook_heads.inode_invalidate_secctx),
  1526. .inode_notifysecctx =
  1527. LIST_HEAD_INIT(security_hook_heads.inode_notifysecctx),
  1528. .inode_setsecctx =
  1529. LIST_HEAD_INIT(security_hook_heads.inode_setsecctx),
  1530. .inode_getsecctx =
  1531. LIST_HEAD_INIT(security_hook_heads.inode_getsecctx),
  1532. #ifdef CONFIG_SECURITY_NETWORK
  1533. .unix_stream_connect =
  1534. LIST_HEAD_INIT(security_hook_heads.unix_stream_connect),
  1535. .unix_may_send =
  1536. LIST_HEAD_INIT(security_hook_heads.unix_may_send),
  1537. .socket_create =
  1538. LIST_HEAD_INIT(security_hook_heads.socket_create),
  1539. .socket_post_create =
  1540. LIST_HEAD_INIT(security_hook_heads.socket_post_create),
  1541. .socket_bind = LIST_HEAD_INIT(security_hook_heads.socket_bind),
  1542. .socket_connect =
  1543. LIST_HEAD_INIT(security_hook_heads.socket_connect),
  1544. .socket_listen =
  1545. LIST_HEAD_INIT(security_hook_heads.socket_listen),
  1546. .socket_accept =
  1547. LIST_HEAD_INIT(security_hook_heads.socket_accept),
  1548. .socket_sendmsg =
  1549. LIST_HEAD_INIT(security_hook_heads.socket_sendmsg),
  1550. .socket_recvmsg =
  1551. LIST_HEAD_INIT(security_hook_heads.socket_recvmsg),
  1552. .socket_getsockname =
  1553. LIST_HEAD_INIT(security_hook_heads.socket_getsockname),
  1554. .socket_getpeername =
  1555. LIST_HEAD_INIT(security_hook_heads.socket_getpeername),
  1556. .socket_getsockopt =
  1557. LIST_HEAD_INIT(security_hook_heads.socket_getsockopt),
  1558. .socket_setsockopt =
  1559. LIST_HEAD_INIT(security_hook_heads.socket_setsockopt),
  1560. .socket_shutdown =
  1561. LIST_HEAD_INIT(security_hook_heads.socket_shutdown),
  1562. .socket_sock_rcv_skb =
  1563. LIST_HEAD_INIT(security_hook_heads.socket_sock_rcv_skb),
  1564. .socket_getpeersec_stream =
  1565. LIST_HEAD_INIT(security_hook_heads.socket_getpeersec_stream),
  1566. .socket_getpeersec_dgram =
  1567. LIST_HEAD_INIT(security_hook_heads.socket_getpeersec_dgram),
  1568. .sk_alloc_security =
  1569. LIST_HEAD_INIT(security_hook_heads.sk_alloc_security),
  1570. .sk_free_security =
  1571. LIST_HEAD_INIT(security_hook_heads.sk_free_security),
  1572. .sk_clone_security =
  1573. LIST_HEAD_INIT(security_hook_heads.sk_clone_security),
  1574. .sk_getsecid = LIST_HEAD_INIT(security_hook_heads.sk_getsecid),
  1575. .sock_graft = LIST_HEAD_INIT(security_hook_heads.sock_graft),
  1576. .inet_conn_request =
  1577. LIST_HEAD_INIT(security_hook_heads.inet_conn_request),
  1578. .inet_csk_clone =
  1579. LIST_HEAD_INIT(security_hook_heads.inet_csk_clone),
  1580. .inet_conn_established =
  1581. LIST_HEAD_INIT(security_hook_heads.inet_conn_established),
  1582. .secmark_relabel_packet =
  1583. LIST_HEAD_INIT(security_hook_heads.secmark_relabel_packet),
  1584. .secmark_refcount_inc =
  1585. LIST_HEAD_INIT(security_hook_heads.secmark_refcount_inc),
  1586. .secmark_refcount_dec =
  1587. LIST_HEAD_INIT(security_hook_heads.secmark_refcount_dec),
  1588. .req_classify_flow =
  1589. LIST_HEAD_INIT(security_hook_heads.req_classify_flow),
  1590. .tun_dev_alloc_security =
  1591. LIST_HEAD_INIT(security_hook_heads.tun_dev_alloc_security),
  1592. .tun_dev_free_security =
  1593. LIST_HEAD_INIT(security_hook_heads.tun_dev_free_security),
  1594. .tun_dev_create =
  1595. LIST_HEAD_INIT(security_hook_heads.tun_dev_create),
  1596. .tun_dev_attach_queue =
  1597. LIST_HEAD_INIT(security_hook_heads.tun_dev_attach_queue),
  1598. .tun_dev_attach =
  1599. LIST_HEAD_INIT(security_hook_heads.tun_dev_attach),
  1600. .tun_dev_open = LIST_HEAD_INIT(security_hook_heads.tun_dev_open),
  1601. .skb_owned_by = LIST_HEAD_INIT(security_hook_heads.skb_owned_by),
  1602. #endif /* CONFIG_SECURITY_NETWORK */
  1603. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  1604. .xfrm_policy_alloc_security =
  1605. LIST_HEAD_INIT(security_hook_heads.xfrm_policy_alloc_security),
  1606. .xfrm_policy_clone_security =
  1607. LIST_HEAD_INIT(security_hook_heads.xfrm_policy_clone_security),
  1608. .xfrm_policy_free_security =
  1609. LIST_HEAD_INIT(security_hook_heads.xfrm_policy_free_security),
  1610. .xfrm_policy_delete_security =
  1611. LIST_HEAD_INIT(security_hook_heads.xfrm_policy_delete_security),
  1612. .xfrm_state_alloc =
  1613. LIST_HEAD_INIT(security_hook_heads.xfrm_state_alloc),
  1614. .xfrm_state_alloc_acquire =
  1615. LIST_HEAD_INIT(security_hook_heads.xfrm_state_alloc_acquire),
  1616. .xfrm_state_free_security =
  1617. LIST_HEAD_INIT(security_hook_heads.xfrm_state_free_security),
  1618. .xfrm_state_delete_security =
  1619. LIST_HEAD_INIT(security_hook_heads.xfrm_state_delete_security),
  1620. .xfrm_policy_lookup =
  1621. LIST_HEAD_INIT(security_hook_heads.xfrm_policy_lookup),
  1622. .xfrm_state_pol_flow_match =
  1623. LIST_HEAD_INIT(security_hook_heads.xfrm_state_pol_flow_match),
  1624. .xfrm_decode_session =
  1625. LIST_HEAD_INIT(security_hook_heads.xfrm_decode_session),
  1626. #endif /* CONFIG_SECURITY_NETWORK_XFRM */
  1627. #ifdef CONFIG_KEYS
  1628. .key_alloc = LIST_HEAD_INIT(security_hook_heads.key_alloc),
  1629. .key_free = LIST_HEAD_INIT(security_hook_heads.key_free),
  1630. .key_permission =
  1631. LIST_HEAD_INIT(security_hook_heads.key_permission),
  1632. .key_getsecurity =
  1633. LIST_HEAD_INIT(security_hook_heads.key_getsecurity),
  1634. #endif /* CONFIG_KEYS */
  1635. #ifdef CONFIG_AUDIT
  1636. .audit_rule_init =
  1637. LIST_HEAD_INIT(security_hook_heads.audit_rule_init),
  1638. .audit_rule_known =
  1639. LIST_HEAD_INIT(security_hook_heads.audit_rule_known),
  1640. .audit_rule_match =
  1641. LIST_HEAD_INIT(security_hook_heads.audit_rule_match),
  1642. .audit_rule_free =
  1643. LIST_HEAD_INIT(security_hook_heads.audit_rule_free),
  1644. #endif /* CONFIG_AUDIT */
  1645. };