summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exec.c
diff options
context:
space:
mode:
authorjonathan <jonathan@FreeBSD.org>2011-06-30 10:56:02 +0000
committerjonathan <jonathan@FreeBSD.org>2011-06-30 10:56:02 +0000
commit8c932faae446ada0bed49a41fbb164c821227122 (patch)
tree4124774c8a367f5606513084c5f950e1a12d2ac0 /sys/kern/kern_exec.c
parentced9bcf26f7e7107339e61b56b9ba7ceba6049ac (diff)
downloadFreeBSD-src-8c932faae446ada0bed49a41fbb164c821227122.zip
FreeBSD-src-8c932faae446ada0bed49a41fbb164c821227122.tar.gz
Add some checks to ensure that Capsicum is behaving correctly, and add some
more explicit comments about what's going on and what future maintainers need to do when e.g. adding a new operation to a sys_machdep.c. Approved by: mentor(rwatson), re(bz)
Diffstat (limited to 'sys/kern/kern_exec.c')
-rw-r--r--sys/kern/kern_exec.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index c51cc39..f30f89a 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -27,12 +27,14 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "opt_capsicum.h"
#include "opt_hwpmc_hooks.h"
#include "opt_kdtrace.h"
#include "opt_ktrace.h"
#include "opt_vm.h"
#include <sys/param.h>
+#include <sys/capability.h>
#include <sys/systm.h>
#include <sys/eventhandler.h>
#include <sys/lock.h>
@@ -415,6 +417,18 @@ do_execve(td, args, mac_p)
interpret:
if (args->fname != NULL) {
+#ifdef CAPABILITY_MODE
+ /*
+ * While capability mode can't reach this point via direct
+ * path arguments to execve(), we also don't allow
+ * interpreters to be used in capability mode (for now).
+ * Catch indirect lookups and return a permissions error.
+ */
+ if (IN_CAPABILITY_MODE(td)) {
+ error = ECAPMODE;
+ goto exec_fail;
+ }
+#endif
error = namei(&nd);
if (error)
goto exec_fail;
@@ -631,6 +645,13 @@ interpret:
* Don't honor setuid/setgid if the filesystem prohibits it or if
* the process is being traced.
*
+ * We disable setuid/setgid/etc in compatibility mode on the basis
+ * that most setugid applications are not written with that
+ * environment in mind, and will therefore almost certainly operate
+ * incorrectly. In principle there's no reason that setugid
+ * applications might not be useful in capability mode, so we may want
+ * to reconsider this conservative design choice in the future.
+ *
* XXXMAC: For the time being, use NOSUID to also prohibit
* transitions on the file system.
*/
@@ -646,6 +667,9 @@ interpret:
#endif
if (credential_changing &&
+#ifdef CAPABILITY_MODE
+ ((oldcred->cr_flags & CRED_FLAG_CAPMODE) == 0) &&
+#endif
(imgp->vp->v_mount->mnt_flag & MNT_NOSUID) == 0 &&
(p->p_flag & P_TRACED) == 0) {
/*
OpenPOWER on IntegriCloud