~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/security/tomoyo/load_policy.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /security/tomoyo/load_policy.c (Version linux-6.12-rc7) and /security/tomoyo/load_policy.c (Version linux-4.12.14)


  1 // SPDX-License-Identifier: GPL-2.0            << 
  2 /*                                                  1 /*
  3  * security/tomoyo/load_policy.c                    2  * security/tomoyo/load_policy.c
  4  *                                                  3  *
  5  * Copyright (C) 2005-2011  NTT DATA CORPORATI      4  * Copyright (C) 2005-2011  NTT DATA CORPORATION
  6  */                                                 5  */
  7                                                     6 
  8 #include "common.h"                                 7 #include "common.h"
  9                                                     8 
 10 #ifndef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_      9 #ifndef CONFIG_SECURITY_TOMOYO_OMIT_USERSPACE_LOADER
 11                                                    10 
 12 /*                                                 11 /*
 13  * Path to the policy loader. (default = CONFI     12  * Path to the policy loader. (default = CONFIG_SECURITY_TOMOYO_POLICY_LOADER)
 14  */                                                13  */
 15 static const char *tomoyo_loader;                  14 static const char *tomoyo_loader;
 16                                                    15 
 17 /**                                                16 /**
 18  * tomoyo_loader_setup - Set policy loader.        17  * tomoyo_loader_setup - Set policy loader.
 19  *                                                 18  *
 20  * @str: Program to use as a policy loader (e.     19  * @str: Program to use as a policy loader (e.g. /sbin/tomoyo-init ).
 21  *                                                 20  *
 22  * Returns 0.                                      21  * Returns 0.
 23  */                                                22  */
 24 static int __init tomoyo_loader_setup(char *st     23 static int __init tomoyo_loader_setup(char *str)
 25 {                                                  24 {
 26         tomoyo_loader = str;                       25         tomoyo_loader = str;
 27         return 1;                              !!  26         return 0;
 28 }                                                  27 }
 29                                                    28 
 30 __setup("TOMOYO_loader=", tomoyo_loader_setup)     29 __setup("TOMOYO_loader=", tomoyo_loader_setup);
 31                                                    30 
 32 /**                                                31 /**
 33  * tomoyo_policy_loader_exists - Check whether     32  * tomoyo_policy_loader_exists - Check whether /sbin/tomoyo-init exists.
 34  *                                                 33  *
 35  * Returns true if /sbin/tomoyo-init exists, f     34  * Returns true if /sbin/tomoyo-init exists, false otherwise.
 36  */                                                35  */
 37 static bool tomoyo_policy_loader_exists(void)      36 static bool tomoyo_policy_loader_exists(void)
 38 {                                                  37 {
 39         struct path path;                          38         struct path path;
 40                                                << 
 41         if (!tomoyo_loader)                        39         if (!tomoyo_loader)
 42                 tomoyo_loader = CONFIG_SECURIT     40                 tomoyo_loader = CONFIG_SECURITY_TOMOYO_POLICY_LOADER;
 43         if (kern_path(tomoyo_loader, LOOKUP_FO     41         if (kern_path(tomoyo_loader, LOOKUP_FOLLOW, &path)) {
 44                 pr_info("Not activating Mandat !!  42                 printk(KERN_INFO "Not activating Mandatory Access Control "
 45                         tomoyo_loader);        !!  43                        "as %s does not exist.\n", tomoyo_loader);
 46                 return false;                      44                 return false;
 47         }                                          45         }
 48         path_put(&path);                           46         path_put(&path);
 49         return true;                               47         return true;
 50 }                                                  48 }
 51                                                    49 
 52 /*                                                 50 /*
 53  * Path to the trigger. (default = CONFIG_SECU     51  * Path to the trigger. (default = CONFIG_SECURITY_TOMOYO_ACTIVATION_TRIGGER)
 54  */                                                52  */
 55 static const char *tomoyo_trigger;                 53 static const char *tomoyo_trigger;
 56                                                    54 
 57 /**                                                55 /**
 58  * tomoyo_trigger_setup - Set trigger for acti     56  * tomoyo_trigger_setup - Set trigger for activation.
 59  *                                                 57  *
 60  * @str: Program to use as an activation trigg     58  * @str: Program to use as an activation trigger (e.g. /sbin/init ).
 61  *                                                 59  *
 62  * Returns 0.                                      60  * Returns 0.
 63  */                                                61  */
 64 static int __init tomoyo_trigger_setup(char *s     62 static int __init tomoyo_trigger_setup(char *str)
 65 {                                                  63 {
 66         tomoyo_trigger = str;                      64         tomoyo_trigger = str;
 67         return 1;                              !!  65         return 0;
 68 }                                                  66 }
 69                                                    67 
 70 __setup("TOMOYO_trigger=", tomoyo_trigger_setu     68 __setup("TOMOYO_trigger=", tomoyo_trigger_setup);
 71                                                    69 
 72 /**                                                70 /**
 73  * tomoyo_load_policy - Run external policy lo     71  * tomoyo_load_policy - Run external policy loader to load policy.
 74  *                                                 72  *
 75  * @filename: The program about to start.          73  * @filename: The program about to start.
 76  *                                                 74  *
 77  * This function checks whether @filename is /     75  * This function checks whether @filename is /sbin/init , and if so
 78  * invoke /sbin/tomoyo-init and wait for the t     76  * invoke /sbin/tomoyo-init and wait for the termination of /sbin/tomoyo-init
 79  * and then continues invocation of /sbin/init     77  * and then continues invocation of /sbin/init.
 80  * /sbin/tomoyo-init reads policy files in /et     78  * /sbin/tomoyo-init reads policy files in /etc/tomoyo/ directory and
 81  * writes to /sys/kernel/security/tomoyo/ inte     79  * writes to /sys/kernel/security/tomoyo/ interfaces.
 82  *                                                 80  *
 83  * Returns nothing.                                81  * Returns nothing.
 84  */                                                82  */
 85 void tomoyo_load_policy(const char *filename)      83 void tomoyo_load_policy(const char *filename)
 86 {                                                  84 {
 87         static bool done;                          85         static bool done;
 88         char *argv[2];                             86         char *argv[2];
 89         char *envp[3];                             87         char *envp[3];
 90                                                    88 
 91         if (tomoyo_policy_loaded || done)          89         if (tomoyo_policy_loaded || done)
 92                 return;                            90                 return;
 93         if (!tomoyo_trigger)                       91         if (!tomoyo_trigger)
 94                 tomoyo_trigger = CONFIG_SECURI     92                 tomoyo_trigger = CONFIG_SECURITY_TOMOYO_ACTIVATION_TRIGGER;
 95         if (strcmp(filename, tomoyo_trigger))      93         if (strcmp(filename, tomoyo_trigger))
 96                 return;                            94                 return;
 97         if (!tomoyo_policy_loader_exists())        95         if (!tomoyo_policy_loader_exists())
 98                 return;                            96                 return;
 99         done = true;                               97         done = true;
100         pr_info("Calling %s to load policy. Pl !!  98         printk(KERN_INFO "Calling %s to load policy. Please wait.\n",
                                                   >>  99                tomoyo_loader);
101         argv[0] = (char *) tomoyo_loader;         100         argv[0] = (char *) tomoyo_loader;
102         argv[1] = NULL;                           101         argv[1] = NULL;
103         envp[0] = "HOME=/";                       102         envp[0] = "HOME=/";
104         envp[1] = "PATH=/sbin:/bin:/usr/sbin:/    103         envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
105         envp[2] = NULL;                           104         envp[2] = NULL;
106         call_usermodehelper(argv[0], argv, env    105         call_usermodehelper(argv[0], argv, envp, UMH_WAIT_PROC);
107         tomoyo_check_profile();                   106         tomoyo_check_profile();
108 }                                                 107 }
109                                                   108 
110 #endif                                            109 #endif
111                                                   110 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php