11// SPDX-License-Identifier: GPL-2.0
22/*
3- * security/tomoyo/tomoyo.c
3+ * security/tomoyo/hooks.h
44 *
55 * Copyright (C) 2005-2011 NTT DATA CORPORATION
66 */
77
8- #include <linux/lsm_hooks.h>
9- #include <uapi/linux/lsm.h>
108#include "common.h"
119
1210/**
@@ -18,10 +16,6 @@ struct tomoyo_domain_info *tomoyo_domain(void)
1816{
1917 struct tomoyo_task * s = tomoyo_task (current );
2018
21- if (s -> old_domain_info && !current -> in_execve ) {
22- atomic_dec (& s -> old_domain_info -> users );
23- s -> old_domain_info = NULL ;
24- }
2519 return s -> domain_info ;
2620}
2721
@@ -62,26 +56,6 @@ static void tomoyo_bprm_committed_creds(const struct linux_binprm *bprm)
6256 s -> old_domain_info = NULL ;
6357}
6458
65- #ifndef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER
66- /**
67- * tomoyo_bprm_creds_for_exec - Target for security_bprm_creds_for_exec().
68- *
69- * @bprm: Pointer to "struct linux_binprm".
70- *
71- * Returns 0.
72- */
73- static int tomoyo_bprm_creds_for_exec (struct linux_binprm * bprm )
74- {
75- /*
76- * Load policy if /sbin/tomoyo-init exists and /sbin/init is requested
77- * for the first time.
78- */
79- if (!tomoyo_policy_loaded )
80- tomoyo_load_policy (bprm -> filename );
81- return 0 ;
82- }
83- #endif
84-
8559/**
8660 * tomoyo_bprm_check_security - Target for security_bprm_check().
8761 *
@@ -501,10 +475,6 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
501475 return tomoyo_socket_sendmsg_permission (sock , msg , size );
502476}
503477
504- struct lsm_blob_sizes tomoyo_blob_sizes __ro_after_init = {
505- .lbs_task = sizeof (struct tomoyo_task ),
506- };
507-
508478/**
509479 * tomoyo_task_alloc - Target for security_task_alloc().
510480 *
@@ -543,81 +513,3 @@ static void tomoyo_task_free(struct task_struct *task)
543513 s -> old_domain_info = NULL ;
544514 }
545515}
546-
547- static const struct lsm_id tomoyo_lsmid = {
548- .name = "tomoyo" ,
549- .id = LSM_ID_TOMOYO ,
550- };
551-
552- /*
553- * tomoyo_security_ops is a "struct security_operations" which is used for
554- * registering TOMOYO.
555- */
556- static struct security_hook_list tomoyo_hooks [] __ro_after_init = {
557- LSM_HOOK_INIT (cred_prepare , tomoyo_cred_prepare ),
558- LSM_HOOK_INIT (bprm_committed_creds , tomoyo_bprm_committed_creds ),
559- LSM_HOOK_INIT (task_alloc , tomoyo_task_alloc ),
560- LSM_HOOK_INIT (task_free , tomoyo_task_free ),
561- #ifndef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER
562- LSM_HOOK_INIT (bprm_creds_for_exec , tomoyo_bprm_creds_for_exec ),
563- #endif
564- LSM_HOOK_INIT (bprm_check_security , tomoyo_bprm_check_security ),
565- LSM_HOOK_INIT (file_fcntl , tomoyo_file_fcntl ),
566- LSM_HOOK_INIT (file_open , tomoyo_file_open ),
567- LSM_HOOK_INIT (file_truncate , tomoyo_file_truncate ),
568- LSM_HOOK_INIT (path_truncate , tomoyo_path_truncate ),
569- LSM_HOOK_INIT (path_unlink , tomoyo_path_unlink ),
570- LSM_HOOK_INIT (path_mkdir , tomoyo_path_mkdir ),
571- LSM_HOOK_INIT (path_rmdir , tomoyo_path_rmdir ),
572- LSM_HOOK_INIT (path_symlink , tomoyo_path_symlink ),
573- LSM_HOOK_INIT (path_mknod , tomoyo_path_mknod ),
574- LSM_HOOK_INIT (path_link , tomoyo_path_link ),
575- LSM_HOOK_INIT (path_rename , tomoyo_path_rename ),
576- LSM_HOOK_INIT (inode_getattr , tomoyo_inode_getattr ),
577- LSM_HOOK_INIT (file_ioctl , tomoyo_file_ioctl ),
578- LSM_HOOK_INIT (file_ioctl_compat , tomoyo_file_ioctl ),
579- LSM_HOOK_INIT (path_chmod , tomoyo_path_chmod ),
580- LSM_HOOK_INIT (path_chown , tomoyo_path_chown ),
581- LSM_HOOK_INIT (path_chroot , tomoyo_path_chroot ),
582- LSM_HOOK_INIT (sb_mount , tomoyo_sb_mount ),
583- LSM_HOOK_INIT (sb_umount , tomoyo_sb_umount ),
584- LSM_HOOK_INIT (sb_pivotroot , tomoyo_sb_pivotroot ),
585- LSM_HOOK_INIT (socket_bind , tomoyo_socket_bind ),
586- LSM_HOOK_INIT (socket_connect , tomoyo_socket_connect ),
587- LSM_HOOK_INIT (socket_listen , tomoyo_socket_listen ),
588- LSM_HOOK_INIT (socket_sendmsg , tomoyo_socket_sendmsg ),
589- };
590-
591- /* Lock for GC. */
592- DEFINE_SRCU (tomoyo_ss );
593-
594- int tomoyo_enabled __ro_after_init = 1 ;
595-
596- /**
597- * tomoyo_init - Register TOMOYO Linux as a LSM module.
598- *
599- * Returns 0.
600- */
601- static int __init tomoyo_init (void )
602- {
603- struct tomoyo_task * s = tomoyo_task (current );
604-
605- /* register ourselves with the security framework */
606- security_add_hooks (tomoyo_hooks , ARRAY_SIZE (tomoyo_hooks ),
607- & tomoyo_lsmid );
608- pr_info ("TOMOYO Linux initialized\n" );
609- s -> domain_info = & tomoyo_kernel_domain ;
610- atomic_inc (& tomoyo_kernel_domain .users );
611- s -> old_domain_info = NULL ;
612- tomoyo_mm_init ();
613-
614- return 0 ;
615- }
616-
617- DEFINE_LSM (tomoyo ) = {
618- .name = "tomoyo" ,
619- .enabled = & tomoyo_enabled ,
620- .flags = LSM_FLAG_LEGACY_MAJOR ,
621- .blobs = & tomoyo_blob_sizes ,
622- .init = tomoyo_init ,
623- };
0 commit comments