security.c 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890
  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. * Always load the capability module.
  53. */
  54. capability_add_hooks();
  55. #ifdef CONFIG_SECURITY_YAMA_STACKED
  56. /*
  57. * If Yama is configured for stacking load it next.
  58. */
  59. yama_add_hooks();
  60. #endif
  61. /*
  62. * Load the chosen module if there is one.
  63. * This will also find yama if it is stacking
  64. */
  65. do_security_initcalls();
  66. return 0;
  67. }
  68. /* Save user chosen LSM */
  69. static int __init choose_lsm(char *str)
  70. {
  71. strncpy(chosen_lsm, str, SECURITY_NAME_MAX);
  72. return 1;
  73. }
  74. __setup("security=", choose_lsm);
  75. /**
  76. * security_module_enable - Load given security module on boot ?
  77. * @module: the name of the module
  78. *
  79. * Each LSM must pass this method before registering its own operations
  80. * to avoid security registration races. This method may also be used
  81. * to check if your LSM is currently loaded during kernel initialization.
  82. *
  83. * Return true if:
  84. * -The passed LSM is the one chosen by user at boot time,
  85. * -or the passed LSM is configured as the default and the user did not
  86. * choose an alternate LSM at boot time.
  87. * Otherwise, return false.
  88. */
  89. int __init security_module_enable(const char *module)
  90. {
  91. return !strcmp(module, chosen_lsm);
  92. }
  93. /*
  94. * Hook list operation macros.
  95. *
  96. * call_void_hook:
  97. * This is a hook that does not return a value.
  98. *
  99. * call_int_hook:
  100. * This is a hook that returns a value.
  101. */
  102. #define call_void_hook(FUNC, ...) \
  103. do { \
  104. struct security_hook_list *P; \
  105. \
  106. list_for_each_entry(P, &security_hook_heads.FUNC, list) \
  107. P->hook.FUNC(__VA_ARGS__); \
  108. } while (0)
  109. #define call_int_hook(FUNC, IRC, ...) ({ \
  110. int RC = IRC; \
  111. do { \
  112. struct security_hook_list *P; \
  113. \
  114. list_for_each_entry(P, &security_hook_heads.FUNC, list) { \
  115. RC = P->hook.FUNC(__VA_ARGS__); \
  116. if (RC != 0) \
  117. break; \
  118. } \
  119. } while (0); \
  120. RC; \
  121. })
  122. /* Security operations */
  123. int security_binder_set_context_mgr(struct task_struct *mgr)
  124. {
  125. return call_int_hook(binder_set_context_mgr, 0, mgr);
  126. }
  127. int security_binder_transaction(struct task_struct *from,
  128. struct task_struct *to)
  129. {
  130. return call_int_hook(binder_transaction, 0, from, to);
  131. }
  132. int security_binder_transfer_binder(struct task_struct *from,
  133. struct task_struct *to)
  134. {
  135. return call_int_hook(binder_transfer_binder, 0, from, to);
  136. }
  137. int security_binder_transfer_file(struct task_struct *from,
  138. struct task_struct *to, struct file *file)
  139. {
  140. return call_int_hook(binder_transfer_file, 0, from, to, file);
  141. }
  142. int security_ptrace_access_check(struct task_struct *child, unsigned int mode)
  143. {
  144. return call_int_hook(ptrace_access_check, 0, child, mode);
  145. }
  146. int security_ptrace_traceme(struct task_struct *parent)
  147. {
  148. return call_int_hook(ptrace_traceme, 0, parent);
  149. }
  150. int security_capget(struct task_struct *target,
  151. kernel_cap_t *effective,
  152. kernel_cap_t *inheritable,
  153. kernel_cap_t *permitted)
  154. {
  155. return call_int_hook(capget, 0, target,
  156. effective, inheritable, permitted);
  157. }
  158. int security_capset(struct cred *new, const struct cred *old,
  159. const kernel_cap_t *effective,
  160. const kernel_cap_t *inheritable,
  161. const kernel_cap_t *permitted)
  162. {
  163. return call_int_hook(capset, 0, new, old,
  164. effective, inheritable, permitted);
  165. }
  166. int security_capable(const struct cred *cred, struct user_namespace *ns,
  167. int cap)
  168. {
  169. return call_int_hook(capable, 0, cred, ns, cap, SECURITY_CAP_AUDIT);
  170. }
  171. int security_capable_noaudit(const struct cred *cred, struct user_namespace *ns,
  172. int cap)
  173. {
  174. return call_int_hook(capable, 0, cred, ns, cap, SECURITY_CAP_NOAUDIT);
  175. }
  176. int security_quotactl(int cmds, int type, int id, struct super_block *sb)
  177. {
  178. return call_int_hook(quotactl, 0, cmds, type, id, sb);
  179. }
  180. int security_quota_on(struct dentry *dentry)
  181. {
  182. return call_int_hook(quota_on, 0, dentry);
  183. }
  184. int security_syslog(int type)
  185. {
  186. return call_int_hook(syslog, 0, type);
  187. }
  188. int security_settime(const struct timespec *ts, const struct timezone *tz)
  189. {
  190. return call_int_hook(settime, 0, ts, tz);
  191. }
  192. int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
  193. {
  194. struct security_hook_list *hp;
  195. int cap_sys_admin = 1;
  196. int rc;
  197. /*
  198. * The module will respond with a positive value if
  199. * it thinks the __vm_enough_memory() call should be
  200. * made with the cap_sys_admin set. If all of the modules
  201. * agree that it should be set it will. If any module
  202. * thinks it should not be set it won't.
  203. */
  204. list_for_each_entry(hp, &security_hook_heads.vm_enough_memory, list) {
  205. rc = hp->hook.vm_enough_memory(mm, pages);
  206. if (rc <= 0) {
  207. cap_sys_admin = 0;
  208. break;
  209. }
  210. }
  211. return __vm_enough_memory(mm, pages, cap_sys_admin);
  212. }
  213. int security_bprm_set_creds(struct linux_binprm *bprm)
  214. {
  215. return call_int_hook(bprm_set_creds, 0, bprm);
  216. }
  217. int security_bprm_check(struct linux_binprm *bprm)
  218. {
  219. int ret;
  220. ret = call_int_hook(bprm_check_security, 0, bprm);
  221. if (ret)
  222. return ret;
  223. return ima_bprm_check(bprm);
  224. }
  225. void security_bprm_committing_creds(struct linux_binprm *bprm)
  226. {
  227. call_void_hook(bprm_committing_creds, bprm);
  228. }
  229. void security_bprm_committed_creds(struct linux_binprm *bprm)
  230. {
  231. call_void_hook(bprm_committed_creds, bprm);
  232. }
  233. int security_bprm_secureexec(struct linux_binprm *bprm)
  234. {
  235. return call_int_hook(bprm_secureexec, 0, bprm);
  236. }
  237. int security_sb_alloc(struct super_block *sb)
  238. {
  239. return call_int_hook(sb_alloc_security, 0, sb);
  240. }
  241. void security_sb_free(struct super_block *sb)
  242. {
  243. call_void_hook(sb_free_security, sb);
  244. }
  245. int security_sb_copy_data(char *orig, char *copy)
  246. {
  247. return call_int_hook(sb_copy_data, 0, orig, copy);
  248. }
  249. EXPORT_SYMBOL(security_sb_copy_data);
  250. int security_sb_remount(struct super_block *sb, void *data)
  251. {
  252. return call_int_hook(sb_remount, 0, sb, data);
  253. }
  254. int security_sb_kern_mount(struct super_block *sb, int flags, void *data)
  255. {
  256. return call_int_hook(sb_kern_mount, 0, sb, flags, data);
  257. }
  258. int security_sb_show_options(struct seq_file *m, struct super_block *sb)
  259. {
  260. return call_int_hook(sb_show_options, 0, m, sb);
  261. }
  262. int security_sb_statfs(struct dentry *dentry)
  263. {
  264. return call_int_hook(sb_statfs, 0, dentry);
  265. }
  266. int security_sb_mount(const char *dev_name, struct path *path,
  267. const char *type, unsigned long flags, void *data)
  268. {
  269. return call_int_hook(sb_mount, 0, dev_name, path, type, flags, data);
  270. }
  271. int security_sb_umount(struct vfsmount *mnt, int flags)
  272. {
  273. return call_int_hook(sb_umount, 0, mnt, flags);
  274. }
  275. int security_sb_pivotroot(struct path *old_path, struct path *new_path)
  276. {
  277. return call_int_hook(sb_pivotroot, 0, old_path, new_path);
  278. }
  279. int security_sb_set_mnt_opts(struct super_block *sb,
  280. struct security_mnt_opts *opts,
  281. unsigned long kern_flags,
  282. unsigned long *set_kern_flags)
  283. {
  284. return call_int_hook(sb_set_mnt_opts,
  285. opts->num_mnt_opts ? -EOPNOTSUPP : 0, sb,
  286. opts, kern_flags, set_kern_flags);
  287. }
  288. EXPORT_SYMBOL(security_sb_set_mnt_opts);
  289. int security_sb_clone_mnt_opts(const struct super_block *oldsb,
  290. struct super_block *newsb)
  291. {
  292. return call_int_hook(sb_clone_mnt_opts, 0, oldsb, newsb);
  293. }
  294. EXPORT_SYMBOL(security_sb_clone_mnt_opts);
  295. int security_sb_parse_opts_str(char *options, struct security_mnt_opts *opts)
  296. {
  297. return call_int_hook(sb_parse_opts_str, 0, options, opts);
  298. }
  299. EXPORT_SYMBOL(security_sb_parse_opts_str);
  300. int security_inode_alloc(struct inode *inode)
  301. {
  302. inode->i_security = NULL;
  303. return call_int_hook(inode_alloc_security, 0, inode);
  304. }
  305. void security_inode_free(struct inode *inode)
  306. {
  307. integrity_inode_free(inode);
  308. call_void_hook(inode_free_security, inode);
  309. }
  310. int security_dentry_init_security(struct dentry *dentry, int mode,
  311. struct qstr *name, void **ctx,
  312. u32 *ctxlen)
  313. {
  314. return call_int_hook(dentry_init_security, -EOPNOTSUPP, dentry, mode,
  315. name, ctx, ctxlen);
  316. }
  317. EXPORT_SYMBOL(security_dentry_init_security);
  318. int security_inode_init_security(struct inode *inode, struct inode *dir,
  319. const struct qstr *qstr,
  320. const initxattrs initxattrs, void *fs_data)
  321. {
  322. struct xattr new_xattrs[MAX_LSM_EVM_XATTR + 1];
  323. struct xattr *lsm_xattr, *evm_xattr, *xattr;
  324. int ret;
  325. if (unlikely(IS_PRIVATE(inode)))
  326. return 0;
  327. if (!initxattrs)
  328. return call_int_hook(inode_init_security, 0, inode, dir, qstr,
  329. NULL, NULL, NULL);
  330. memset(new_xattrs, 0, sizeof(new_xattrs));
  331. lsm_xattr = new_xattrs;
  332. ret = call_int_hook(inode_init_security, -EOPNOTSUPP, inode, dir, qstr,
  333. &lsm_xattr->name,
  334. &lsm_xattr->value,
  335. &lsm_xattr->value_len);
  336. if (ret)
  337. goto out;
  338. evm_xattr = lsm_xattr + 1;
  339. ret = evm_inode_init_security(inode, lsm_xattr, evm_xattr);
  340. if (ret)
  341. goto out;
  342. ret = initxattrs(inode, new_xattrs, fs_data);
  343. out:
  344. for (xattr = new_xattrs; xattr->value != NULL; xattr++)
  345. kfree(xattr->value);
  346. return (ret == -EOPNOTSUPP) ? 0 : ret;
  347. }
  348. EXPORT_SYMBOL(security_inode_init_security);
  349. int security_old_inode_init_security(struct inode *inode, struct inode *dir,
  350. const struct qstr *qstr, const char **name,
  351. void **value, size_t *len)
  352. {
  353. if (unlikely(IS_PRIVATE(inode)))
  354. return -EOPNOTSUPP;
  355. return call_int_hook(inode_init_security, 0, inode, dir, qstr,
  356. name, value, len);
  357. }
  358. EXPORT_SYMBOL(security_old_inode_init_security);
  359. #ifdef CONFIG_SECURITY_PATH
  360. int security_path_mknod(struct path *dir, struct dentry *dentry, umode_t mode,
  361. unsigned int dev)
  362. {
  363. if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry))))
  364. return 0;
  365. return call_int_hook(path_mknod, 0, dir, dentry, mode, dev);
  366. }
  367. EXPORT_SYMBOL(security_path_mknod);
  368. int security_path_mkdir(struct path *dir, struct dentry *dentry, umode_t mode)
  369. {
  370. if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry))))
  371. return 0;
  372. return call_int_hook(path_mkdir, 0, dir, dentry, mode);
  373. }
  374. EXPORT_SYMBOL(security_path_mkdir);
  375. int security_path_rmdir(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_rmdir, 0, dir, dentry);
  380. }
  381. int security_path_unlink(struct path *dir, struct dentry *dentry)
  382. {
  383. if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry))))
  384. return 0;
  385. return call_int_hook(path_unlink, 0, dir, dentry);
  386. }
  387. EXPORT_SYMBOL(security_path_unlink);
  388. int security_path_symlink(struct path *dir, struct dentry *dentry,
  389. const char *old_name)
  390. {
  391. if (unlikely(IS_PRIVATE(d_backing_inode(dir->dentry))))
  392. return 0;
  393. return call_int_hook(path_symlink, 0, dir, dentry, old_name);
  394. }
  395. int security_path_link(struct dentry *old_dentry, struct path *new_dir,
  396. struct dentry *new_dentry)
  397. {
  398. if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry))))
  399. return 0;
  400. return call_int_hook(path_link, 0, old_dentry, new_dir, new_dentry);
  401. }
  402. int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
  403. struct path *new_dir, struct dentry *new_dentry,
  404. unsigned int flags)
  405. {
  406. if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry)) ||
  407. (d_is_positive(new_dentry) && IS_PRIVATE(d_backing_inode(new_dentry)))))
  408. return 0;
  409. if (flags & RENAME_EXCHANGE) {
  410. int err = call_int_hook(path_rename, 0, new_dir, new_dentry,
  411. old_dir, old_dentry);
  412. if (err)
  413. return err;
  414. }
  415. return call_int_hook(path_rename, 0, old_dir, old_dentry, new_dir,
  416. new_dentry);
  417. }
  418. EXPORT_SYMBOL(security_path_rename);
  419. int security_path_truncate(struct path *path)
  420. {
  421. if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
  422. return 0;
  423. return call_int_hook(path_truncate, 0, path);
  424. }
  425. int security_path_chmod(struct path *path, umode_t mode)
  426. {
  427. if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
  428. return 0;
  429. return call_int_hook(path_chmod, 0, path, mode);
  430. }
  431. int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
  432. {
  433. if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
  434. return 0;
  435. return call_int_hook(path_chown, 0, path, uid, gid);
  436. }
  437. int security_path_chroot(struct path *path)
  438. {
  439. return call_int_hook(path_chroot, 0, path);
  440. }
  441. #endif
  442. int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode)
  443. {
  444. if (unlikely(IS_PRIVATE(dir)))
  445. return 0;
  446. return call_int_hook(inode_create, 0, dir, dentry, mode);
  447. }
  448. EXPORT_SYMBOL_GPL(security_inode_create);
  449. int security_inode_link(struct dentry *old_dentry, struct inode *dir,
  450. struct dentry *new_dentry)
  451. {
  452. if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry))))
  453. return 0;
  454. return call_int_hook(inode_link, 0, old_dentry, dir, new_dentry);
  455. }
  456. int security_inode_unlink(struct inode *dir, struct dentry *dentry)
  457. {
  458. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  459. return 0;
  460. return call_int_hook(inode_unlink, 0, dir, dentry);
  461. }
  462. int security_inode_symlink(struct inode *dir, struct dentry *dentry,
  463. const char *old_name)
  464. {
  465. if (unlikely(IS_PRIVATE(dir)))
  466. return 0;
  467. return call_int_hook(inode_symlink, 0, dir, dentry, old_name);
  468. }
  469. int security_inode_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
  470. {
  471. if (unlikely(IS_PRIVATE(dir)))
  472. return 0;
  473. return call_int_hook(inode_mkdir, 0, dir, dentry, mode);
  474. }
  475. EXPORT_SYMBOL_GPL(security_inode_mkdir);
  476. int security_inode_rmdir(struct inode *dir, struct dentry *dentry)
  477. {
  478. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  479. return 0;
  480. return call_int_hook(inode_rmdir, 0, dir, dentry);
  481. }
  482. int security_inode_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
  483. {
  484. if (unlikely(IS_PRIVATE(dir)))
  485. return 0;
  486. return call_int_hook(inode_mknod, 0, dir, dentry, mode, dev);
  487. }
  488. int security_inode_rename(struct inode *old_dir, struct dentry *old_dentry,
  489. struct inode *new_dir, struct dentry *new_dentry,
  490. unsigned int flags)
  491. {
  492. if (unlikely(IS_PRIVATE(d_backing_inode(old_dentry)) ||
  493. (d_is_positive(new_dentry) && IS_PRIVATE(d_backing_inode(new_dentry)))))
  494. return 0;
  495. if (flags & RENAME_EXCHANGE) {
  496. int err = call_int_hook(inode_rename, 0, new_dir, new_dentry,
  497. old_dir, old_dentry);
  498. if (err)
  499. return err;
  500. }
  501. return call_int_hook(inode_rename, 0, old_dir, old_dentry,
  502. new_dir, new_dentry);
  503. }
  504. int security_inode_readlink(struct dentry *dentry)
  505. {
  506. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  507. return 0;
  508. return call_int_hook(inode_readlink, 0, dentry);
  509. }
  510. int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
  511. bool rcu)
  512. {
  513. if (unlikely(IS_PRIVATE(inode)))
  514. return 0;
  515. return call_int_hook(inode_follow_link, 0, dentry, inode, rcu);
  516. }
  517. int security_inode_permission(struct inode *inode, int mask)
  518. {
  519. if (unlikely(IS_PRIVATE(inode)))
  520. return 0;
  521. return call_int_hook(inode_permission, 0, inode, mask);
  522. }
  523. int security_inode_setattr(struct dentry *dentry, struct iattr *attr)
  524. {
  525. int ret;
  526. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  527. return 0;
  528. ret = call_int_hook(inode_setattr, 0, dentry, attr);
  529. if (ret)
  530. return ret;
  531. return evm_inode_setattr(dentry, attr);
  532. }
  533. EXPORT_SYMBOL_GPL(security_inode_setattr);
  534. int security_inode_getattr(const struct path *path)
  535. {
  536. if (unlikely(IS_PRIVATE(d_backing_inode(path->dentry))))
  537. return 0;
  538. return call_int_hook(inode_getattr, 0, path);
  539. }
  540. int security_inode_setxattr(struct dentry *dentry, const char *name,
  541. const void *value, size_t size, int flags)
  542. {
  543. int ret;
  544. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  545. return 0;
  546. /*
  547. * SELinux and Smack integrate the cap call,
  548. * so assume that all LSMs supplying this call do so.
  549. */
  550. ret = call_int_hook(inode_setxattr, 1, dentry, name, value, size,
  551. flags);
  552. if (ret == 1)
  553. ret = cap_inode_setxattr(dentry, name, value, size, flags);
  554. if (ret)
  555. return ret;
  556. ret = ima_inode_setxattr(dentry, name, value, size);
  557. if (ret)
  558. return ret;
  559. return evm_inode_setxattr(dentry, name, value, size);
  560. }
  561. void security_inode_post_setxattr(struct dentry *dentry, const char *name,
  562. const void *value, size_t size, int flags)
  563. {
  564. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  565. return;
  566. call_void_hook(inode_post_setxattr, dentry, name, value, size, flags);
  567. evm_inode_post_setxattr(dentry, name, value, size);
  568. }
  569. int security_inode_getxattr(struct dentry *dentry, const char *name)
  570. {
  571. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  572. return 0;
  573. return call_int_hook(inode_getxattr, 0, dentry, name);
  574. }
  575. int security_inode_listxattr(struct dentry *dentry)
  576. {
  577. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  578. return 0;
  579. return call_int_hook(inode_listxattr, 0, dentry);
  580. }
  581. int security_inode_removexattr(struct dentry *dentry, const char *name)
  582. {
  583. int ret;
  584. if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
  585. return 0;
  586. /*
  587. * SELinux and Smack integrate the cap call,
  588. * so assume that all LSMs supplying this call do so.
  589. */
  590. ret = call_int_hook(inode_removexattr, 1, dentry, name);
  591. if (ret == 1)
  592. ret = cap_inode_removexattr(dentry, name);
  593. if (ret)
  594. return ret;
  595. ret = ima_inode_removexattr(dentry, name);
  596. if (ret)
  597. return ret;
  598. return evm_inode_removexattr(dentry, name);
  599. }
  600. int security_inode_need_killpriv(struct dentry *dentry)
  601. {
  602. return call_int_hook(inode_need_killpriv, 0, dentry);
  603. }
  604. int security_inode_killpriv(struct dentry *dentry)
  605. {
  606. return call_int_hook(inode_killpriv, 0, dentry);
  607. }
  608. int security_inode_getsecurity(const struct inode *inode, const char *name, void **buffer, bool alloc)
  609. {
  610. if (unlikely(IS_PRIVATE(inode)))
  611. return -EOPNOTSUPP;
  612. return call_int_hook(inode_getsecurity, -EOPNOTSUPP, inode, name,
  613. buffer, alloc);
  614. }
  615. int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags)
  616. {
  617. if (unlikely(IS_PRIVATE(inode)))
  618. return -EOPNOTSUPP;
  619. return call_int_hook(inode_setsecurity, -EOPNOTSUPP, inode, name,
  620. value, size, flags);
  621. }
  622. int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffer_size)
  623. {
  624. if (unlikely(IS_PRIVATE(inode)))
  625. return 0;
  626. return call_int_hook(inode_listsecurity, 0, inode, buffer, buffer_size);
  627. }
  628. EXPORT_SYMBOL(security_inode_listsecurity);
  629. void security_inode_getsecid(const struct inode *inode, u32 *secid)
  630. {
  631. call_void_hook(inode_getsecid, inode, secid);
  632. }
  633. int security_file_permission(struct file *file, int mask)
  634. {
  635. int ret;
  636. ret = call_int_hook(file_permission, 0, file, mask);
  637. if (ret)
  638. return ret;
  639. return fsnotify_perm(file, mask);
  640. }
  641. int security_file_alloc(struct file *file)
  642. {
  643. return call_int_hook(file_alloc_security, 0, file);
  644. }
  645. void security_file_free(struct file *file)
  646. {
  647. call_void_hook(file_free_security, file);
  648. }
  649. int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  650. {
  651. return call_int_hook(file_ioctl, 0, file, cmd, arg);
  652. }
  653. static inline unsigned long mmap_prot(struct file *file, unsigned long prot)
  654. {
  655. /*
  656. * Does we have PROT_READ and does the application expect
  657. * it to imply PROT_EXEC? If not, nothing to talk about...
  658. */
  659. if ((prot & (PROT_READ | PROT_EXEC)) != PROT_READ)
  660. return prot;
  661. if (!(current->personality & READ_IMPLIES_EXEC))
  662. return prot;
  663. /*
  664. * if that's an anonymous mapping, let it.
  665. */
  666. if (!file)
  667. return prot | PROT_EXEC;
  668. /*
  669. * ditto if it's not on noexec mount, except that on !MMU we need
  670. * NOMMU_MAP_EXEC (== VM_MAYEXEC) in this case
  671. */
  672. if (!(file->f_path.mnt->mnt_flags & MNT_NOEXEC)) {
  673. #ifndef CONFIG_MMU
  674. if (file->f_op->mmap_capabilities) {
  675. unsigned caps = file->f_op->mmap_capabilities(file);
  676. if (!(caps & NOMMU_MAP_EXEC))
  677. return prot;
  678. }
  679. #endif
  680. return prot | PROT_EXEC;
  681. }
  682. /* anything on noexec mount won't get PROT_EXEC */
  683. return prot;
  684. }
  685. int security_mmap_file(struct file *file, unsigned long prot,
  686. unsigned long flags)
  687. {
  688. int ret;
  689. ret = call_int_hook(mmap_file, 0, file, prot,
  690. mmap_prot(file, prot), flags);
  691. if (ret)
  692. return ret;
  693. return ima_file_mmap(file, prot);
  694. }
  695. int security_mmap_addr(unsigned long addr)
  696. {
  697. return call_int_hook(mmap_addr, 0, addr);
  698. }
  699. int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
  700. unsigned long prot)
  701. {
  702. return call_int_hook(file_mprotect, 0, vma, reqprot, prot);
  703. }
  704. int security_file_lock(struct file *file, unsigned int cmd)
  705. {
  706. return call_int_hook(file_lock, 0, file, cmd);
  707. }
  708. int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
  709. {
  710. return call_int_hook(file_fcntl, 0, file, cmd, arg);
  711. }
  712. void security_file_set_fowner(struct file *file)
  713. {
  714. call_void_hook(file_set_fowner, file);
  715. }
  716. int security_file_send_sigiotask(struct task_struct *tsk,
  717. struct fown_struct *fown, int sig)
  718. {
  719. return call_int_hook(file_send_sigiotask, 0, tsk, fown, sig);
  720. }
  721. int security_file_receive(struct file *file)
  722. {
  723. return call_int_hook(file_receive, 0, file);
  724. }
  725. int security_file_open(struct file *file, const struct cred *cred)
  726. {
  727. int ret;
  728. ret = call_int_hook(file_open, 0, file, cred);
  729. if (ret)
  730. return ret;
  731. return fsnotify_perm(file, MAY_OPEN);
  732. }
  733. int security_task_create(unsigned long clone_flags)
  734. {
  735. return call_int_hook(task_create, 0, clone_flags);
  736. }
  737. void security_task_free(struct task_struct *task)
  738. {
  739. call_void_hook(task_free, task);
  740. }
  741. int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
  742. {
  743. return call_int_hook(cred_alloc_blank, 0, cred, gfp);
  744. }
  745. void security_cred_free(struct cred *cred)
  746. {
  747. call_void_hook(cred_free, cred);
  748. }
  749. int security_prepare_creds(struct cred *new, const struct cred *old, gfp_t gfp)
  750. {
  751. return call_int_hook(cred_prepare, 0, new, old, gfp);
  752. }
  753. void security_transfer_creds(struct cred *new, const struct cred *old)
  754. {
  755. call_void_hook(cred_transfer, new, old);
  756. }
  757. int security_kernel_act_as(struct cred *new, u32 secid)
  758. {
  759. return call_int_hook(kernel_act_as, 0, new, secid);
  760. }
  761. int security_kernel_create_files_as(struct cred *new, struct inode *inode)
  762. {
  763. return call_int_hook(kernel_create_files_as, 0, new, inode);
  764. }
  765. int security_kernel_fw_from_file(struct file *file, char *buf, size_t size)
  766. {
  767. int ret;
  768. ret = call_int_hook(kernel_fw_from_file, 0, file, buf, size);
  769. if (ret)
  770. return ret;
  771. return ima_fw_from_file(file, buf, size);
  772. }
  773. EXPORT_SYMBOL_GPL(security_kernel_fw_from_file);
  774. int security_kernel_module_request(char *kmod_name)
  775. {
  776. return call_int_hook(kernel_module_request, 0, kmod_name);
  777. }
  778. int security_kernel_module_from_file(struct file *file)
  779. {
  780. int ret;
  781. ret = call_int_hook(kernel_module_from_file, 0, file);
  782. if (ret)
  783. return ret;
  784. return ima_module_check(file);
  785. }
  786. int security_task_fix_setuid(struct cred *new, const struct cred *old,
  787. int flags)
  788. {
  789. return call_int_hook(task_fix_setuid, 0, new, old, flags);
  790. }
  791. int security_task_setpgid(struct task_struct *p, pid_t pgid)
  792. {
  793. return call_int_hook(task_setpgid, 0, p, pgid);
  794. }
  795. int security_task_getpgid(struct task_struct *p)
  796. {
  797. return call_int_hook(task_getpgid, 0, p);
  798. }
  799. int security_task_getsid(struct task_struct *p)
  800. {
  801. return call_int_hook(task_getsid, 0, p);
  802. }
  803. void security_task_getsecid(struct task_struct *p, u32 *secid)
  804. {
  805. *secid = 0;
  806. call_void_hook(task_getsecid, p, secid);
  807. }
  808. EXPORT_SYMBOL(security_task_getsecid);
  809. int security_task_setnice(struct task_struct *p, int nice)
  810. {
  811. return call_int_hook(task_setnice, 0, p, nice);
  812. }
  813. int security_task_setioprio(struct task_struct *p, int ioprio)
  814. {
  815. return call_int_hook(task_setioprio, 0, p, ioprio);
  816. }
  817. int security_task_getioprio(struct task_struct *p)
  818. {
  819. return call_int_hook(task_getioprio, 0, p);
  820. }
  821. int security_task_setrlimit(struct task_struct *p, unsigned int resource,
  822. struct rlimit *new_rlim)
  823. {
  824. return call_int_hook(task_setrlimit, 0, p, resource, new_rlim);
  825. }
  826. int security_task_setscheduler(struct task_struct *p)
  827. {
  828. return call_int_hook(task_setscheduler, 0, p);
  829. }
  830. int security_task_getscheduler(struct task_struct *p)
  831. {
  832. return call_int_hook(task_getscheduler, 0, p);
  833. }
  834. int security_task_movememory(struct task_struct *p)
  835. {
  836. return call_int_hook(task_movememory, 0, p);
  837. }
  838. int security_task_kill(struct task_struct *p, struct siginfo *info,
  839. int sig, u32 secid)
  840. {
  841. return call_int_hook(task_kill, 0, p, info, sig, secid);
  842. }
  843. int security_task_wait(struct task_struct *p)
  844. {
  845. return call_int_hook(task_wait, 0, p);
  846. }
  847. int security_task_prctl(int option, unsigned long arg2, unsigned long arg3,
  848. unsigned long arg4, unsigned long arg5)
  849. {
  850. int thisrc;
  851. int rc = -ENOSYS;
  852. struct security_hook_list *hp;
  853. list_for_each_entry(hp, &security_hook_heads.task_prctl, list) {
  854. thisrc = hp->hook.task_prctl(option, arg2, arg3, arg4, arg5);
  855. if (thisrc != -ENOSYS) {
  856. rc = thisrc;
  857. if (thisrc != 0)
  858. break;
  859. }
  860. }
  861. return rc;
  862. }
  863. void security_task_to_inode(struct task_struct *p, struct inode *inode)
  864. {
  865. call_void_hook(task_to_inode, p, inode);
  866. }
  867. int security_ipc_permission(struct kern_ipc_perm *ipcp, short flag)
  868. {
  869. return call_int_hook(ipc_permission, 0, ipcp, flag);
  870. }
  871. void security_ipc_getsecid(struct kern_ipc_perm *ipcp, u32 *secid)
  872. {
  873. *secid = 0;
  874. call_void_hook(ipc_getsecid, ipcp, secid);
  875. }
  876. int security_msg_msg_alloc(struct msg_msg *msg)
  877. {
  878. return call_int_hook(msg_msg_alloc_security, 0, msg);
  879. }
  880. void security_msg_msg_free(struct msg_msg *msg)
  881. {
  882. call_void_hook(msg_msg_free_security, msg);
  883. }
  884. int security_msg_queue_alloc(struct msg_queue *msq)
  885. {
  886. return call_int_hook(msg_queue_alloc_security, 0, msq);
  887. }
  888. void security_msg_queue_free(struct msg_queue *msq)
  889. {
  890. call_void_hook(msg_queue_free_security, msq);
  891. }
  892. int security_msg_queue_associate(struct msg_queue *msq, int msqflg)
  893. {
  894. return call_int_hook(msg_queue_associate, 0, msq, msqflg);
  895. }
  896. int security_msg_queue_msgctl(struct msg_queue *msq, int cmd)
  897. {
  898. return call_int_hook(msg_queue_msgctl, 0, msq, cmd);
  899. }
  900. int security_msg_queue_msgsnd(struct msg_queue *msq,
  901. struct msg_msg *msg, int msqflg)
  902. {
  903. return call_int_hook(msg_queue_msgsnd, 0, msq, msg, msqflg);
  904. }
  905. int security_msg_queue_msgrcv(struct msg_queue *msq, struct msg_msg *msg,
  906. struct task_struct *target, long type, int mode)
  907. {
  908. return call_int_hook(msg_queue_msgrcv, 0, msq, msg, target, type, mode);
  909. }
  910. int security_shm_alloc(struct shmid_kernel *shp)
  911. {
  912. return call_int_hook(shm_alloc_security, 0, shp);
  913. }
  914. void security_shm_free(struct shmid_kernel *shp)
  915. {
  916. call_void_hook(shm_free_security, shp);
  917. }
  918. int security_shm_associate(struct shmid_kernel *shp, int shmflg)
  919. {
  920. return call_int_hook(shm_associate, 0, shp, shmflg);
  921. }
  922. int security_shm_shmctl(struct shmid_kernel *shp, int cmd)
  923. {
  924. return call_int_hook(shm_shmctl, 0, shp, cmd);
  925. }
  926. int security_shm_shmat(struct shmid_kernel *shp, char __user *shmaddr, int shmflg)
  927. {
  928. return call_int_hook(shm_shmat, 0, shp, shmaddr, shmflg);
  929. }
  930. int security_sem_alloc(struct sem_array *sma)
  931. {
  932. return call_int_hook(sem_alloc_security, 0, sma);
  933. }
  934. void security_sem_free(struct sem_array *sma)
  935. {
  936. call_void_hook(sem_free_security, sma);
  937. }
  938. int security_sem_associate(struct sem_array *sma, int semflg)
  939. {
  940. return call_int_hook(sem_associate, 0, sma, semflg);
  941. }
  942. int security_sem_semctl(struct sem_array *sma, int cmd)
  943. {
  944. return call_int_hook(sem_semctl, 0, sma, cmd);
  945. }
  946. int security_sem_semop(struct sem_array *sma, struct sembuf *sops,
  947. unsigned nsops, int alter)
  948. {
  949. return call_int_hook(sem_semop, 0, sma, sops, nsops, alter);
  950. }
  951. void security_d_instantiate(struct dentry *dentry, struct inode *inode)
  952. {
  953. if (unlikely(inode && IS_PRIVATE(inode)))
  954. return;
  955. call_void_hook(d_instantiate, dentry, inode);
  956. }
  957. EXPORT_SYMBOL(security_d_instantiate);
  958. int security_getprocattr(struct task_struct *p, char *name, char **value)
  959. {
  960. return call_int_hook(getprocattr, -EINVAL, p, name, value);
  961. }
  962. int security_setprocattr(struct task_struct *p, char *name, void *value, size_t size)
  963. {
  964. return call_int_hook(setprocattr, -EINVAL, p, name, value, size);
  965. }
  966. int security_netlink_send(struct sock *sk, struct sk_buff *skb)
  967. {
  968. return call_int_hook(netlink_send, 0, sk, skb);
  969. }
  970. int security_ismaclabel(const char *name)
  971. {
  972. return call_int_hook(ismaclabel, 0, name);
  973. }
  974. EXPORT_SYMBOL(security_ismaclabel);
  975. int security_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
  976. {
  977. return call_int_hook(secid_to_secctx, -EOPNOTSUPP, secid, secdata,
  978. seclen);
  979. }
  980. EXPORT_SYMBOL(security_secid_to_secctx);
  981. int security_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid)
  982. {
  983. *secid = 0;
  984. return call_int_hook(secctx_to_secid, 0, secdata, seclen, secid);
  985. }
  986. EXPORT_SYMBOL(security_secctx_to_secid);
  987. void security_release_secctx(char *secdata, u32 seclen)
  988. {
  989. call_void_hook(release_secctx, secdata, seclen);
  990. }
  991. EXPORT_SYMBOL(security_release_secctx);
  992. int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen)
  993. {
  994. return call_int_hook(inode_notifysecctx, 0, inode, ctx, ctxlen);
  995. }
  996. EXPORT_SYMBOL(security_inode_notifysecctx);
  997. int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen)
  998. {
  999. return call_int_hook(inode_setsecctx, 0, dentry, ctx, ctxlen);
  1000. }
  1001. EXPORT_SYMBOL(security_inode_setsecctx);
  1002. int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
  1003. {
  1004. return call_int_hook(inode_getsecctx, -EOPNOTSUPP, inode, ctx, ctxlen);
  1005. }
  1006. EXPORT_SYMBOL(security_inode_getsecctx);
  1007. #ifdef CONFIG_SECURITY_NETWORK
  1008. int security_unix_stream_connect(struct sock *sock, struct sock *other, struct sock *newsk)
  1009. {
  1010. return call_int_hook(unix_stream_connect, 0, sock, other, newsk);
  1011. }
  1012. EXPORT_SYMBOL(security_unix_stream_connect);
  1013. int security_unix_may_send(struct socket *sock, struct socket *other)
  1014. {
  1015. return call_int_hook(unix_may_send, 0, sock, other);
  1016. }
  1017. EXPORT_SYMBOL(security_unix_may_send);
  1018. int security_socket_create(int family, int type, int protocol, int kern)
  1019. {
  1020. return call_int_hook(socket_create, 0, family, type, protocol, kern);
  1021. }
  1022. int security_socket_post_create(struct socket *sock, int family,
  1023. int type, int protocol, int kern)
  1024. {
  1025. return call_int_hook(socket_post_create, 0, sock, family, type,
  1026. protocol, kern);
  1027. }
  1028. int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen)
  1029. {
  1030. return call_int_hook(socket_bind, 0, sock, address, addrlen);
  1031. }
  1032. int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen)
  1033. {
  1034. return call_int_hook(socket_connect, 0, sock, address, addrlen);
  1035. }
  1036. int security_socket_listen(struct socket *sock, int backlog)
  1037. {
  1038. return call_int_hook(socket_listen, 0, sock, backlog);
  1039. }
  1040. int security_socket_accept(struct socket *sock, struct socket *newsock)
  1041. {
  1042. return call_int_hook(socket_accept, 0, sock, newsock);
  1043. }
  1044. int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size)
  1045. {
  1046. return call_int_hook(socket_sendmsg, 0, sock, msg, size);
  1047. }
  1048. int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,
  1049. int size, int flags)
  1050. {
  1051. return call_int_hook(socket_recvmsg, 0, sock, msg, size, flags);
  1052. }
  1053. int security_socket_getsockname(struct socket *sock)
  1054. {
  1055. return call_int_hook(socket_getsockname, 0, sock);
  1056. }
  1057. int security_socket_getpeername(struct socket *sock)
  1058. {
  1059. return call_int_hook(socket_getpeername, 0, sock);
  1060. }
  1061. int security_socket_getsockopt(struct socket *sock, int level, int optname)
  1062. {
  1063. return call_int_hook(socket_getsockopt, 0, sock, level, optname);
  1064. }
  1065. int security_socket_setsockopt(struct socket *sock, int level, int optname)
  1066. {
  1067. return call_int_hook(socket_setsockopt, 0, sock, level, optname);
  1068. }
  1069. int security_socket_shutdown(struct socket *sock, int how)
  1070. {
  1071. return call_int_hook(socket_shutdown, 0, sock, how);
  1072. }
  1073. int security_sock_rcv_skb(struct sock *sk, struct sk_buff *skb)
  1074. {
  1075. return call_int_hook(socket_sock_rcv_skb, 0, sk, skb);
  1076. }
  1077. EXPORT_SYMBOL(security_sock_rcv_skb);
  1078. int security_socket_getpeersec_stream(struct socket *sock, char __user *optval,
  1079. int __user *optlen, unsigned len)
  1080. {
  1081. return call_int_hook(socket_getpeersec_stream, -ENOPROTOOPT, sock,
  1082. optval, optlen, len);
  1083. }
  1084. int security_socket_getpeersec_dgram(struct socket *sock, struct sk_buff *skb, u32 *secid)
  1085. {
  1086. return call_int_hook(socket_getpeersec_dgram, 0, sock, 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_notifysecctx =
  1525. LIST_HEAD_INIT(security_hook_heads.inode_notifysecctx),
  1526. .inode_setsecctx =
  1527. LIST_HEAD_INIT(security_hook_heads.inode_setsecctx),
  1528. .inode_getsecctx =
  1529. LIST_HEAD_INIT(security_hook_heads.inode_getsecctx),
  1530. #ifdef CONFIG_SECURITY_NETWORK
  1531. .unix_stream_connect =
  1532. LIST_HEAD_INIT(security_hook_heads.unix_stream_connect),
  1533. .unix_may_send =
  1534. LIST_HEAD_INIT(security_hook_heads.unix_may_send),
  1535. .socket_create =
  1536. LIST_HEAD_INIT(security_hook_heads.socket_create),
  1537. .socket_post_create =
  1538. LIST_HEAD_INIT(security_hook_heads.socket_post_create),
  1539. .socket_bind = LIST_HEAD_INIT(security_hook_heads.socket_bind),
  1540. .socket_connect =
  1541. LIST_HEAD_INIT(security_hook_heads.socket_connect),
  1542. .socket_listen =
  1543. LIST_HEAD_INIT(security_hook_heads.socket_listen),
  1544. .socket_accept =
  1545. LIST_HEAD_INIT(security_hook_heads.socket_accept),
  1546. .socket_sendmsg =
  1547. LIST_HEAD_INIT(security_hook_heads.socket_sendmsg),
  1548. .socket_recvmsg =
  1549. LIST_HEAD_INIT(security_hook_heads.socket_recvmsg),
  1550. .socket_getsockname =
  1551. LIST_HEAD_INIT(security_hook_heads.socket_getsockname),
  1552. .socket_getpeername =
  1553. LIST_HEAD_INIT(security_hook_heads.socket_getpeername),
  1554. .socket_getsockopt =
  1555. LIST_HEAD_INIT(security_hook_heads.socket_getsockopt),
  1556. .socket_setsockopt =
  1557. LIST_HEAD_INIT(security_hook_heads.socket_setsockopt),
  1558. .socket_shutdown =
  1559. LIST_HEAD_INIT(security_hook_heads.socket_shutdown),
  1560. .socket_sock_rcv_skb =
  1561. LIST_HEAD_INIT(security_hook_heads.socket_sock_rcv_skb),
  1562. .socket_getpeersec_stream =
  1563. LIST_HEAD_INIT(security_hook_heads.socket_getpeersec_stream),
  1564. .socket_getpeersec_dgram =
  1565. LIST_HEAD_INIT(security_hook_heads.socket_getpeersec_dgram),
  1566. .sk_alloc_security =
  1567. LIST_HEAD_INIT(security_hook_heads.sk_alloc_security),
  1568. .sk_free_security =
  1569. LIST_HEAD_INIT(security_hook_heads.sk_free_security),
  1570. .sk_clone_security =
  1571. LIST_HEAD_INIT(security_hook_heads.sk_clone_security),
  1572. .sk_getsecid = LIST_HEAD_INIT(security_hook_heads.sk_getsecid),
  1573. .sock_graft = LIST_HEAD_INIT(security_hook_heads.sock_graft),
  1574. .inet_conn_request =
  1575. LIST_HEAD_INIT(security_hook_heads.inet_conn_request),
  1576. .inet_csk_clone =
  1577. LIST_HEAD_INIT(security_hook_heads.inet_csk_clone),
  1578. .inet_conn_established =
  1579. LIST_HEAD_INIT(security_hook_heads.inet_conn_established),
  1580. .secmark_relabel_packet =
  1581. LIST_HEAD_INIT(security_hook_heads.secmark_relabel_packet),
  1582. .secmark_refcount_inc =
  1583. LIST_HEAD_INIT(security_hook_heads.secmark_refcount_inc),
  1584. .secmark_refcount_dec =
  1585. LIST_HEAD_INIT(security_hook_heads.secmark_refcount_dec),
  1586. .req_classify_flow =
  1587. LIST_HEAD_INIT(security_hook_heads.req_classify_flow),
  1588. .tun_dev_alloc_security =
  1589. LIST_HEAD_INIT(security_hook_heads.tun_dev_alloc_security),
  1590. .tun_dev_free_security =
  1591. LIST_HEAD_INIT(security_hook_heads.tun_dev_free_security),
  1592. .tun_dev_create =
  1593. LIST_HEAD_INIT(security_hook_heads.tun_dev_create),
  1594. .tun_dev_attach_queue =
  1595. LIST_HEAD_INIT(security_hook_heads.tun_dev_attach_queue),
  1596. .tun_dev_attach =
  1597. LIST_HEAD_INIT(security_hook_heads.tun_dev_attach),
  1598. .tun_dev_open = LIST_HEAD_INIT(security_hook_heads.tun_dev_open),
  1599. .skb_owned_by = LIST_HEAD_INIT(security_hook_heads.skb_owned_by),
  1600. #endif /* CONFIG_SECURITY_NETWORK */
  1601. #ifdef CONFIG_SECURITY_NETWORK_XFRM
  1602. .xfrm_policy_alloc_security =
  1603. LIST_HEAD_INIT(security_hook_heads.xfrm_policy_alloc_security),
  1604. .xfrm_policy_clone_security =
  1605. LIST_HEAD_INIT(security_hook_heads.xfrm_policy_clone_security),
  1606. .xfrm_policy_free_security =
  1607. LIST_HEAD_INIT(security_hook_heads.xfrm_policy_free_security),
  1608. .xfrm_policy_delete_security =
  1609. LIST_HEAD_INIT(security_hook_heads.xfrm_policy_delete_security),
  1610. .xfrm_state_alloc =
  1611. LIST_HEAD_INIT(security_hook_heads.xfrm_state_alloc),
  1612. .xfrm_state_alloc_acquire =
  1613. LIST_HEAD_INIT(security_hook_heads.xfrm_state_alloc_acquire),
  1614. .xfrm_state_free_security =
  1615. LIST_HEAD_INIT(security_hook_heads.xfrm_state_free_security),
  1616. .xfrm_state_delete_security =
  1617. LIST_HEAD_INIT(security_hook_heads.xfrm_state_delete_security),
  1618. .xfrm_policy_lookup =
  1619. LIST_HEAD_INIT(security_hook_heads.xfrm_policy_lookup),
  1620. .xfrm_state_pol_flow_match =
  1621. LIST_HEAD_INIT(security_hook_heads.xfrm_state_pol_flow_match),
  1622. .xfrm_decode_session =
  1623. LIST_HEAD_INIT(security_hook_heads.xfrm_decode_session),
  1624. #endif /* CONFIG_SECURITY_NETWORK_XFRM */
  1625. #ifdef CONFIG_KEYS
  1626. .key_alloc = LIST_HEAD_INIT(security_hook_heads.key_alloc),
  1627. .key_free = LIST_HEAD_INIT(security_hook_heads.key_free),
  1628. .key_permission =
  1629. LIST_HEAD_INIT(security_hook_heads.key_permission),
  1630. .key_getsecurity =
  1631. LIST_HEAD_INIT(security_hook_heads.key_getsecurity),
  1632. #endif /* CONFIG_KEYS */
  1633. #ifdef CONFIG_AUDIT
  1634. .audit_rule_init =
  1635. LIST_HEAD_INIT(security_hook_heads.audit_rule_init),
  1636. .audit_rule_known =
  1637. LIST_HEAD_INIT(security_hook_heads.audit_rule_known),
  1638. .audit_rule_match =
  1639. LIST_HEAD_INIT(security_hook_heads.audit_rule_match),
  1640. .audit_rule_free =
  1641. LIST_HEAD_INIT(security_hook_heads.audit_rule_free),
  1642. #endif /* CONFIG_AUDIT */
  1643. };