tomoyo.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * security/tomoyo/tomoyo.c
  4. *
  5. * Copyright (C) 2005-2011 NTT DATA CORPORATION
  6. */
  7. #include <linux/lsm_hooks.h>
  8. #include <uapi/linux/lsm.h>
  9. #include "common.h"
  10. /**
  11. * tomoyo_domain - Get "struct tomoyo_domain_info" for current thread.
  12. *
  13. * Returns pointer to "struct tomoyo_domain_info" for current thread.
  14. */
  15. struct tomoyo_domain_info *tomoyo_domain(void)
  16. {
  17. struct tomoyo_task *s = tomoyo_task(current);
  18. if (s->old_domain_info && !current->in_execve) {
  19. atomic_dec(&s->old_domain_info->users);
  20. s->old_domain_info = NULL;
  21. }
  22. return s->domain_info;
  23. }
  24. /**
  25. * tomoyo_cred_prepare - Target for security_prepare_creds().
  26. *
  27. * @new: Pointer to "struct cred".
  28. * @old: Pointer to "struct cred".
  29. * @gfp: Memory allocation flags.
  30. *
  31. * Returns 0.
  32. */
  33. static int tomoyo_cred_prepare(struct cred *new, const struct cred *old,
  34. gfp_t gfp)
  35. {
  36. /* Restore old_domain_info saved by previous execve() request. */
  37. struct tomoyo_task *s = tomoyo_task(current);
  38. if (s->old_domain_info && !current->in_execve) {
  39. atomic_dec(&s->domain_info->users);
  40. s->domain_info = s->old_domain_info;
  41. s->old_domain_info = NULL;
  42. }
  43. return 0;
  44. }
  45. /**
  46. * tomoyo_bprm_committed_creds - Target for security_bprm_committed_creds().
  47. *
  48. * @bprm: Pointer to "struct linux_binprm".
  49. */
  50. static void tomoyo_bprm_committed_creds(const struct linux_binprm *bprm)
  51. {
  52. /* Clear old_domain_info saved by execve() request. */
  53. struct tomoyo_task *s = tomoyo_task(current);
  54. atomic_dec(&s->old_domain_info->users);
  55. s->old_domain_info = NULL;
  56. }
  57. #ifndef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER
  58. /**
  59. * tomoyo_bprm_creds_for_exec - Target for security_bprm_creds_for_exec().
  60. *
  61. * @bprm: Pointer to "struct linux_binprm".
  62. *
  63. * Returns 0.
  64. */
  65. static int tomoyo_bprm_creds_for_exec(struct linux_binprm *bprm)
  66. {
  67. /*
  68. * Load policy if /sbin/tomoyo-init exists and /sbin/init is requested
  69. * for the first time.
  70. */
  71. if (!tomoyo_policy_loaded)
  72. tomoyo_load_policy(bprm->filename);
  73. return 0;
  74. }
  75. #endif
  76. /**
  77. * tomoyo_bprm_check_security - Target for security_bprm_check().
  78. *
  79. * @bprm: Pointer to "struct linux_binprm".
  80. *
  81. * Returns 0 on success, negative value otherwise.
  82. */
  83. static int tomoyo_bprm_check_security(struct linux_binprm *bprm)
  84. {
  85. struct tomoyo_task *s = tomoyo_task(current);
  86. /*
  87. * Execute permission is checked against pathname passed to execve()
  88. * using current domain.
  89. */
  90. if (!s->old_domain_info) {
  91. const int idx = tomoyo_read_lock();
  92. const int err = tomoyo_find_next_domain(bprm);
  93. tomoyo_read_unlock(idx);
  94. return err;
  95. }
  96. /*
  97. * Read permission is checked against interpreters using next domain.
  98. */
  99. return tomoyo_check_open_permission(s->domain_info,
  100. &bprm->file->f_path, O_RDONLY);
  101. }
  102. /**
  103. * tomoyo_inode_getattr - Target for security_inode_getattr().
  104. *
  105. * @path: Pointer to "struct path".
  106. *
  107. * Returns 0 on success, negative value otherwise.
  108. */
  109. static int tomoyo_inode_getattr(const struct path *path)
  110. {
  111. return tomoyo_path_perm(TOMOYO_TYPE_GETATTR, path, NULL);
  112. }
  113. /**
  114. * tomoyo_path_truncate - Target for security_path_truncate().
  115. *
  116. * @path: Pointer to "struct path".
  117. *
  118. * Returns 0 on success, negative value otherwise.
  119. */
  120. static int tomoyo_path_truncate(const struct path *path)
  121. {
  122. return tomoyo_path_perm(TOMOYO_TYPE_TRUNCATE, path, NULL);
  123. }
  124. /**
  125. * tomoyo_file_truncate - Target for security_file_truncate().
  126. *
  127. * @file: Pointer to "struct file".
  128. *
  129. * Returns 0 on success, negative value otherwise.
  130. */
  131. static int tomoyo_file_truncate(struct file *file)
  132. {
  133. return tomoyo_path_truncate(&file->f_path);
  134. }
  135. /**
  136. * tomoyo_path_unlink - Target for security_path_unlink().
  137. *
  138. * @parent: Pointer to "struct path".
  139. * @dentry: Pointer to "struct dentry".
  140. *
  141. * Returns 0 on success, negative value otherwise.
  142. */
  143. static int tomoyo_path_unlink(const struct path *parent, struct dentry *dentry)
  144. {
  145. struct path path = { .mnt = parent->mnt, .dentry = dentry };
  146. return tomoyo_path_perm(TOMOYO_TYPE_UNLINK, &path, NULL);
  147. }
  148. /**
  149. * tomoyo_path_mkdir - Target for security_path_mkdir().
  150. *
  151. * @parent: Pointer to "struct path".
  152. * @dentry: Pointer to "struct dentry".
  153. * @mode: DAC permission mode.
  154. *
  155. * Returns 0 on success, negative value otherwise.
  156. */
  157. static int tomoyo_path_mkdir(const struct path *parent, struct dentry *dentry,
  158. umode_t mode)
  159. {
  160. struct path path = { .mnt = parent->mnt, .dentry = dentry };
  161. return tomoyo_path_number_perm(TOMOYO_TYPE_MKDIR, &path,
  162. mode & S_IALLUGO);
  163. }
  164. /**
  165. * tomoyo_path_rmdir - Target for security_path_rmdir().
  166. *
  167. * @parent: Pointer to "struct path".
  168. * @dentry: Pointer to "struct dentry".
  169. *
  170. * Returns 0 on success, negative value otherwise.
  171. */
  172. static int tomoyo_path_rmdir(const struct path *parent, struct dentry *dentry)
  173. {
  174. struct path path = { .mnt = parent->mnt, .dentry = dentry };
  175. return tomoyo_path_perm(TOMOYO_TYPE_RMDIR, &path, NULL);
  176. }
  177. /**
  178. * tomoyo_path_symlink - Target for security_path_symlink().
  179. *
  180. * @parent: Pointer to "struct path".
  181. * @dentry: Pointer to "struct dentry".
  182. * @old_name: Symlink's content.
  183. *
  184. * Returns 0 on success, negative value otherwise.
  185. */
  186. static int tomoyo_path_symlink(const struct path *parent, struct dentry *dentry,
  187. const char *old_name)
  188. {
  189. struct path path = { .mnt = parent->mnt, .dentry = dentry };
  190. return tomoyo_path_perm(TOMOYO_TYPE_SYMLINK, &path, old_name);
  191. }
  192. /**
  193. * tomoyo_path_mknod - Target for security_path_mknod().
  194. *
  195. * @parent: Pointer to "struct path".
  196. * @dentry: Pointer to "struct dentry".
  197. * @mode: DAC permission mode.
  198. * @dev: Device attributes.
  199. *
  200. * Returns 0 on success, negative value otherwise.
  201. */
  202. static int tomoyo_path_mknod(const struct path *parent, struct dentry *dentry,
  203. umode_t mode, unsigned int dev)
  204. {
  205. struct path path = { .mnt = parent->mnt, .dentry = dentry };
  206. int type = TOMOYO_TYPE_CREATE;
  207. const unsigned int perm = mode & S_IALLUGO;
  208. switch (mode & S_IFMT) {
  209. case S_IFCHR:
  210. type = TOMOYO_TYPE_MKCHAR;
  211. break;
  212. case S_IFBLK:
  213. type = TOMOYO_TYPE_MKBLOCK;
  214. break;
  215. default:
  216. goto no_dev;
  217. }
  218. return tomoyo_mkdev_perm(type, &path, perm, dev);
  219. no_dev:
  220. switch (mode & S_IFMT) {
  221. case S_IFIFO:
  222. type = TOMOYO_TYPE_MKFIFO;
  223. break;
  224. case S_IFSOCK:
  225. type = TOMOYO_TYPE_MKSOCK;
  226. break;
  227. }
  228. return tomoyo_path_number_perm(type, &path, perm);
  229. }
  230. /**
  231. * tomoyo_path_link - Target for security_path_link().
  232. *
  233. * @old_dentry: Pointer to "struct dentry".
  234. * @new_dir: Pointer to "struct path".
  235. * @new_dentry: Pointer to "struct dentry".
  236. *
  237. * Returns 0 on success, negative value otherwise.
  238. */
  239. static int tomoyo_path_link(struct dentry *old_dentry, const struct path *new_dir,
  240. struct dentry *new_dentry)
  241. {
  242. struct path path1 = { .mnt = new_dir->mnt, .dentry = old_dentry };
  243. struct path path2 = { .mnt = new_dir->mnt, .dentry = new_dentry };
  244. return tomoyo_path2_perm(TOMOYO_TYPE_LINK, &path1, &path2);
  245. }
  246. /**
  247. * tomoyo_path_rename - Target for security_path_rename().
  248. *
  249. * @old_parent: Pointer to "struct path".
  250. * @old_dentry: Pointer to "struct dentry".
  251. * @new_parent: Pointer to "struct path".
  252. * @new_dentry: Pointer to "struct dentry".
  253. * @flags: Rename options.
  254. *
  255. * Returns 0 on success, negative value otherwise.
  256. */
  257. static int tomoyo_path_rename(const struct path *old_parent,
  258. struct dentry *old_dentry,
  259. const struct path *new_parent,
  260. struct dentry *new_dentry,
  261. const unsigned int flags)
  262. {
  263. struct path path1 = { .mnt = old_parent->mnt, .dentry = old_dentry };
  264. struct path path2 = { .mnt = new_parent->mnt, .dentry = new_dentry };
  265. if (flags & RENAME_EXCHANGE) {
  266. const int err = tomoyo_path2_perm(TOMOYO_TYPE_RENAME, &path2,
  267. &path1);
  268. if (err)
  269. return err;
  270. }
  271. return tomoyo_path2_perm(TOMOYO_TYPE_RENAME, &path1, &path2);
  272. }
  273. /**
  274. * tomoyo_file_fcntl - Target for security_file_fcntl().
  275. *
  276. * @file: Pointer to "struct file".
  277. * @cmd: Command for fcntl().
  278. * @arg: Argument for @cmd.
  279. *
  280. * Returns 0 on success, negative value otherwise.
  281. */
  282. static int tomoyo_file_fcntl(struct file *file, unsigned int cmd,
  283. unsigned long arg)
  284. {
  285. if (!(cmd == F_SETFL && ((arg ^ file->f_flags) & O_APPEND)))
  286. return 0;
  287. return tomoyo_check_open_permission(tomoyo_domain(), &file->f_path,
  288. O_WRONLY | (arg & O_APPEND));
  289. }
  290. /**
  291. * tomoyo_file_open - Target for security_file_open().
  292. *
  293. * @f: Pointer to "struct file".
  294. *
  295. * Returns 0 on success, negative value otherwise.
  296. */
  297. static int tomoyo_file_open(struct file *f)
  298. {
  299. /* Don't check read permission here if called from execve(). */
  300. /* Illogically, FMODE_EXEC is in f_flags, not f_mode. */
  301. if (f->f_flags & __FMODE_EXEC)
  302. return 0;
  303. return tomoyo_check_open_permission(tomoyo_domain(), &f->f_path,
  304. f->f_flags);
  305. }
  306. /**
  307. * tomoyo_file_ioctl - Target for security_file_ioctl().
  308. *
  309. * @file: Pointer to "struct file".
  310. * @cmd: Command for ioctl().
  311. * @arg: Argument for @cmd.
  312. *
  313. * Returns 0 on success, negative value otherwise.
  314. */
  315. static int tomoyo_file_ioctl(struct file *file, unsigned int cmd,
  316. unsigned long arg)
  317. {
  318. return tomoyo_path_number_perm(TOMOYO_TYPE_IOCTL, &file->f_path, cmd);
  319. }
  320. /**
  321. * tomoyo_path_chmod - Target for security_path_chmod().
  322. *
  323. * @path: Pointer to "struct path".
  324. * @mode: DAC permission mode.
  325. *
  326. * Returns 0 on success, negative value otherwise.
  327. */
  328. static int tomoyo_path_chmod(const struct path *path, umode_t mode)
  329. {
  330. return tomoyo_path_number_perm(TOMOYO_TYPE_CHMOD, path,
  331. mode & S_IALLUGO);
  332. }
  333. /**
  334. * tomoyo_path_chown - Target for security_path_chown().
  335. *
  336. * @path: Pointer to "struct path".
  337. * @uid: Owner ID.
  338. * @gid: Group ID.
  339. *
  340. * Returns 0 on success, negative value otherwise.
  341. */
  342. static int tomoyo_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
  343. {
  344. int error = 0;
  345. if (uid_valid(uid))
  346. error = tomoyo_path_number_perm(TOMOYO_TYPE_CHOWN, path,
  347. from_kuid(&init_user_ns, uid));
  348. if (!error && gid_valid(gid))
  349. error = tomoyo_path_number_perm(TOMOYO_TYPE_CHGRP, path,
  350. from_kgid(&init_user_ns, gid));
  351. return error;
  352. }
  353. /**
  354. * tomoyo_path_chroot - Target for security_path_chroot().
  355. *
  356. * @path: Pointer to "struct path".
  357. *
  358. * Returns 0 on success, negative value otherwise.
  359. */
  360. static int tomoyo_path_chroot(const struct path *path)
  361. {
  362. return tomoyo_path_perm(TOMOYO_TYPE_CHROOT, path, NULL);
  363. }
  364. /**
  365. * tomoyo_sb_mount - Target for security_sb_mount().
  366. *
  367. * @dev_name: Name of device file. Maybe NULL.
  368. * @path: Pointer to "struct path".
  369. * @type: Name of filesystem type. Maybe NULL.
  370. * @flags: Mount options.
  371. * @data: Optional data. Maybe NULL.
  372. *
  373. * Returns 0 on success, negative value otherwise.
  374. */
  375. static int tomoyo_sb_mount(const char *dev_name, const struct path *path,
  376. const char *type, unsigned long flags, void *data)
  377. {
  378. return tomoyo_mount_permission(dev_name, path, type, flags, data);
  379. }
  380. /**
  381. * tomoyo_sb_umount - Target for security_sb_umount().
  382. *
  383. * @mnt: Pointer to "struct vfsmount".
  384. * @flags: Unmount options.
  385. *
  386. * Returns 0 on success, negative value otherwise.
  387. */
  388. static int tomoyo_sb_umount(struct vfsmount *mnt, int flags)
  389. {
  390. struct path path = { .mnt = mnt, .dentry = mnt->mnt_root };
  391. return tomoyo_path_perm(TOMOYO_TYPE_UMOUNT, &path, NULL);
  392. }
  393. /**
  394. * tomoyo_sb_pivotroot - Target for security_sb_pivotroot().
  395. *
  396. * @old_path: Pointer to "struct path".
  397. * @new_path: Pointer to "struct path".
  398. *
  399. * Returns 0 on success, negative value otherwise.
  400. */
  401. static int tomoyo_sb_pivotroot(const struct path *old_path, const struct path *new_path)
  402. {
  403. return tomoyo_path2_perm(TOMOYO_TYPE_PIVOT_ROOT, new_path, old_path);
  404. }
  405. /**
  406. * tomoyo_socket_listen - Check permission for listen().
  407. *
  408. * @sock: Pointer to "struct socket".
  409. * @backlog: Backlog parameter.
  410. *
  411. * Returns 0 on success, negative value otherwise.
  412. */
  413. static int tomoyo_socket_listen(struct socket *sock, int backlog)
  414. {
  415. return tomoyo_socket_listen_permission(sock);
  416. }
  417. /**
  418. * tomoyo_socket_connect - Check permission for connect().
  419. *
  420. * @sock: Pointer to "struct socket".
  421. * @addr: Pointer to "struct sockaddr".
  422. * @addr_len: Size of @addr.
  423. *
  424. * Returns 0 on success, negative value otherwise.
  425. */
  426. static int tomoyo_socket_connect(struct socket *sock, struct sockaddr *addr,
  427. int addr_len)
  428. {
  429. return tomoyo_socket_connect_permission(sock, addr, addr_len);
  430. }
  431. /**
  432. * tomoyo_socket_bind - Check permission for bind().
  433. *
  434. * @sock: Pointer to "struct socket".
  435. * @addr: Pointer to "struct sockaddr".
  436. * @addr_len: Size of @addr.
  437. *
  438. * Returns 0 on success, negative value otherwise.
  439. */
  440. static int tomoyo_socket_bind(struct socket *sock, struct sockaddr *addr,
  441. int addr_len)
  442. {
  443. return tomoyo_socket_bind_permission(sock, addr, addr_len);
  444. }
  445. /**
  446. * tomoyo_socket_sendmsg - Check permission for sendmsg().
  447. *
  448. * @sock: Pointer to "struct socket".
  449. * @msg: Pointer to "struct msghdr".
  450. * @size: Size of message.
  451. *
  452. * Returns 0 on success, negative value otherwise.
  453. */
  454. static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
  455. int size)
  456. {
  457. return tomoyo_socket_sendmsg_permission(sock, msg, size);
  458. }
  459. struct lsm_blob_sizes tomoyo_blob_sizes __ro_after_init = {
  460. .lbs_task = sizeof(struct tomoyo_task),
  461. };
  462. /**
  463. * tomoyo_task_alloc - Target for security_task_alloc().
  464. *
  465. * @task: Pointer to "struct task_struct".
  466. * @clone_flags: clone() flags.
  467. *
  468. * Returns 0.
  469. */
  470. static int tomoyo_task_alloc(struct task_struct *task,
  471. unsigned long clone_flags)
  472. {
  473. struct tomoyo_task *old = tomoyo_task(current);
  474. struct tomoyo_task *new = tomoyo_task(task);
  475. new->domain_info = old->domain_info;
  476. atomic_inc(&new->domain_info->users);
  477. new->old_domain_info = NULL;
  478. return 0;
  479. }
  480. /**
  481. * tomoyo_task_free - Target for security_task_free().
  482. *
  483. * @task: Pointer to "struct task_struct".
  484. */
  485. static void tomoyo_task_free(struct task_struct *task)
  486. {
  487. struct tomoyo_task *s = tomoyo_task(task);
  488. if (s->domain_info) {
  489. atomic_dec(&s->domain_info->users);
  490. s->domain_info = NULL;
  491. }
  492. if (s->old_domain_info) {
  493. atomic_dec(&s->old_domain_info->users);
  494. s->old_domain_info = NULL;
  495. }
  496. }
  497. static const struct lsm_id tomoyo_lsmid = {
  498. .name = "tomoyo",
  499. .id = LSM_ID_TOMOYO,
  500. };
  501. /*
  502. * tomoyo_security_ops is a "struct security_operations" which is used for
  503. * registering TOMOYO.
  504. */
  505. static struct security_hook_list tomoyo_hooks[] __ro_after_init = {
  506. LSM_HOOK_INIT(cred_prepare, tomoyo_cred_prepare),
  507. LSM_HOOK_INIT(bprm_committed_creds, tomoyo_bprm_committed_creds),
  508. LSM_HOOK_INIT(task_alloc, tomoyo_task_alloc),
  509. LSM_HOOK_INIT(task_free, tomoyo_task_free),
  510. #ifndef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER
  511. LSM_HOOK_INIT(bprm_creds_for_exec, tomoyo_bprm_creds_for_exec),
  512. #endif
  513. LSM_HOOK_INIT(bprm_check_security, tomoyo_bprm_check_security),
  514. LSM_HOOK_INIT(file_fcntl, tomoyo_file_fcntl),
  515. LSM_HOOK_INIT(file_open, tomoyo_file_open),
  516. LSM_HOOK_INIT(file_truncate, tomoyo_file_truncate),
  517. LSM_HOOK_INIT(path_truncate, tomoyo_path_truncate),
  518. LSM_HOOK_INIT(path_unlink, tomoyo_path_unlink),
  519. LSM_HOOK_INIT(path_mkdir, tomoyo_path_mkdir),
  520. LSM_HOOK_INIT(path_rmdir, tomoyo_path_rmdir),
  521. LSM_HOOK_INIT(path_symlink, tomoyo_path_symlink),
  522. LSM_HOOK_INIT(path_mknod, tomoyo_path_mknod),
  523. LSM_HOOK_INIT(path_link, tomoyo_path_link),
  524. LSM_HOOK_INIT(path_rename, tomoyo_path_rename),
  525. LSM_HOOK_INIT(inode_getattr, tomoyo_inode_getattr),
  526. LSM_HOOK_INIT(file_ioctl, tomoyo_file_ioctl),
  527. LSM_HOOK_INIT(file_ioctl_compat, tomoyo_file_ioctl),
  528. LSM_HOOK_INIT(path_chmod, tomoyo_path_chmod),
  529. LSM_HOOK_INIT(path_chown, tomoyo_path_chown),
  530. LSM_HOOK_INIT(path_chroot, tomoyo_path_chroot),
  531. LSM_HOOK_INIT(sb_mount, tomoyo_sb_mount),
  532. LSM_HOOK_INIT(sb_umount, tomoyo_sb_umount),
  533. LSM_HOOK_INIT(sb_pivotroot, tomoyo_sb_pivotroot),
  534. LSM_HOOK_INIT(socket_bind, tomoyo_socket_bind),
  535. LSM_HOOK_INIT(socket_connect, tomoyo_socket_connect),
  536. LSM_HOOK_INIT(socket_listen, tomoyo_socket_listen),
  537. LSM_HOOK_INIT(socket_sendmsg, tomoyo_socket_sendmsg),
  538. };
  539. /* Lock for GC. */
  540. DEFINE_SRCU(tomoyo_ss);
  541. int tomoyo_enabled __ro_after_init = 1;
  542. /**
  543. * tomoyo_init - Register TOMOYO Linux as a LSM module.
  544. *
  545. * Returns 0.
  546. */
  547. static int __init tomoyo_init(void)
  548. {
  549. struct tomoyo_task *s = tomoyo_task(current);
  550. /* register ourselves with the security framework */
  551. security_add_hooks(tomoyo_hooks, ARRAY_SIZE(tomoyo_hooks),
  552. &tomoyo_lsmid);
  553. pr_info("TOMOYO Linux initialized\n");
  554. s->domain_info = &tomoyo_kernel_domain;
  555. atomic_inc(&tomoyo_kernel_domain.users);
  556. s->old_domain_info = NULL;
  557. tomoyo_mm_init();
  558. return 0;
  559. }
  560. DEFINE_LSM(tomoyo) = {
  561. .name = "tomoyo",
  562. .enabled = &tomoyo_enabled,
  563. .flags = LSM_FLAG_LEGACY_MAJOR,
  564. .blobs = &tomoyo_blob_sizes,
  565. .init = tomoyo_init,
  566. };