summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-16 10:22:39 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-19 06:59:45 -0500
commit64e90a8acb8590c2468c919f803652f081e3a4bf (patch)
treec2a4f4cadffb2858aada1be1285b09bbdf64e8cb
parent377e7a27c049d6df9c1804454904e438ed12f1a4 (diff)
Introduce STATIC_USERMODEHELPER to mediate call_usermodehelper()
Some usermode helper applications are defined at kernel build time, while others can be changed at runtime. To provide a sane way to filter these, add a new kernel option "STATIC_USERMODEHELPER". This option routes all call_usermodehelper() calls through this binary, no matter what the caller wishes to have called. The new binary (by default set to /sbin/usermode-helper, but can be changed through the STATIC_USERMODEHELPER_PATH option) can properly filter the requested programs to be run by the kernel by looking at the first argument that is passed to it. All other options should then be passed onto the proper program if so desired. To disable all call_usermodehelper() calls by the kernel, set STATIC_USERMODEHELPER_PATH to an empty string. Thanks to Neil Brown for the idea of this feature. Cc: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--kernel/kmod.c14
-rw-r--r--security/Kconfig35
2 files changed, 49 insertions, 0 deletions
diff --git a/kernel/kmod.c b/kernel/kmod.c
index 426a614e97fe..0c407f905ca4 100644
--- a/kernel/kmod.c
+++ b/kernel/kmod.c
@@ -528,7 +528,12 @@ struct subprocess_info *call_usermodehelper_setup(const char *path, char **argv,
528 goto out; 528 goto out;
529 529
530 INIT_WORK(&sub_info->work, call_usermodehelper_exec_work); 530 INIT_WORK(&sub_info->work, call_usermodehelper_exec_work);
531
532#ifdef CONFIG_STATIC_USERMODEHELPER
533 sub_info->path = CONFIG_STATIC_USERMODEHELPER_PATH;
534#else
531 sub_info->path = path; 535 sub_info->path = path;
536#endif
532 sub_info->argv = argv; 537 sub_info->argv = argv;
533 sub_info->envp = envp; 538 sub_info->envp = envp;
534 539
@@ -566,6 +571,15 @@ int call_usermodehelper_exec(struct subprocess_info *sub_info, int wait)
566 retval = -EBUSY; 571 retval = -EBUSY;
567 goto out; 572 goto out;
568 } 573 }
574
575 /*
576 * If there is no binary for us to call, then just return and get out of
577 * here. This allows us to set STATIC_USERMODEHELPER_PATH to "" and
578 * disable all call_usermodehelper() calls.
579 */
580 if (strlen(sub_info->path) == 0)
581 goto out;
582
569 /* 583 /*
570 * Set the completion pointer only if there is a waiter. 584 * Set the completion pointer only if there is a waiter.
571 * This makes it possible to use umh_complete to free 585 * This makes it possible to use umh_complete to free
diff --git a/security/Kconfig b/security/Kconfig
index 118f4549404e..d900f47eaa68 100644
--- a/security/Kconfig
+++ b/security/Kconfig
@@ -158,6 +158,41 @@ config HARDENED_USERCOPY_PAGESPAN
158 been removed. This config is intended to be used only while 158 been removed. This config is intended to be used only while
159 trying to find such users. 159 trying to find such users.
160 160
161config STATIC_USERMODEHELPER
162 bool "Force all usermode helper calls through a single binary"
163 help
164 By default, the kernel can call many different userspace
165 binary programs through the "usermode helper" kernel
166 interface. Some of these binaries are statically defined
167 either in the kernel code itself, or as a kernel configuration
168 option. However, some of these are dynamically created at
169 runtime, or can be modified after the kernel has started up.
170 To provide an additional layer of security, route all of these
171 calls through a single executable that can not have its name
172 changed.
173
174 Note, it is up to this single binary to then call the relevant
175 "real" usermode helper binary, based on the first argument
176 passed to it. If desired, this program can filter and pick
177 and choose what real programs are called.
178
179 If you wish for all usermode helper programs are to be
180 disabled, choose this option and then set
181 STATIC_USERMODEHELPER_PATH to an empty string.
182
183config STATIC_USERMODEHELPER_PATH
184 string "Path to the static usermode helper binary"
185 depends on STATIC_USERMODEHELPER
186 default "/sbin/usermode-helper"
187 help
188 The binary called by the kernel when any usermode helper
189 program is wish to be run. The "real" application's name will
190 be in the first argument passed to this program on the command
191 line.
192
193 If you wish for all usermode helper programs to be disabled,
194 specify an empty string here (i.e. "").
195
161source security/selinux/Kconfig 196source security/selinux/Kconfig
162source security/smack/Kconfig 197source security/smack/Kconfig
163source security/tomoyo/Kconfig 198source security/tomoyo/Kconfig