-/* $OpenBSD: kern_exec.c,v 1.166 2015/10/02 15:49:22 deraadt Exp $ */
+/* $OpenBSD: kern_exec.c,v 1.167 2015/10/07 03:47:43 deraadt Exp $ */
/* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */
/*-
#include <sys/signalvar.h>
#include <sys/stat.h>
#include <sys/conf.h>
+#include <sys/tame.h>
#ifdef SYSVSHM
#include <sys/shm.h>
#endif
else
atomic_clearbits_int(&pr->ps_flags, PS_SUGIDEXEC);
+ atomic_clearbits_int(&pr->ps_flags, PS_TAMED);
+ tame_dropwpaths(pr);
+
/*
* deal with set[ug]id.
* MNT_NOEXEC has already been used to disable s[ug]id.
-/* $OpenBSD: kern_exit.c,v 1.152 2015/09/11 08:22:31 guenther Exp $ */
+/* $OpenBSD: kern_exit.c,v 1.153 2015/10/07 03:47:43 deraadt Exp $ */
/* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */
/*
*/
(void)chgproccnt(pr->ps_ucred->cr_ruid, -1);
- if (pr->ps_tamepaths && --pr->ps_tamepaths->wl_ref == 0) {
- struct whitepaths *wl = pr->ps_tamepaths;
- int i;
-
- for (i = 0; i < wl->wl_count; i++)
- free(wl->wl_paths[i].name, M_TEMP, wl->wl_paths[i].len);
- free(wl, M_TEMP, wl->wl_size);
- }
- pr->ps_tamepaths = NULL;
+ tame_dropwpaths(pr);
/*
* Release reference to text vnode
-/* $OpenBSD: kern_tame.c,v 1.65 2015/10/06 18:35:09 deraadt Exp $ */
+/* $OpenBSD: kern_tame.c,v 1.66 2015/10/07 03:47:43 deraadt Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
[SYS_sigsuspend] = TAME_PROC,
[SYS_setrlimit] = TAME_PROC,
+ [SYS_execve] = TAME_EXEC,
+
[SYS_setgroups] = TAME_PROC,
[SYS_setresgid] = TAME_PROC,
[SYS_setresuid] = TAME_PROC,
{ "ioctl", TAME_IOCTL },
{ "tty", TAME_TTY },
{ "proc", TAME_PROC },
+ { "exec", TAME_EXEC },
{ "cpath", TAME_CPATH },
{ "abort", TAME_ABORT },
{ "fattr", TAME_FATTR },
return (EPERM);
}
+void
+tame_dropwpaths(struct process *pr)
+{
+ if (pr->ps_tamepaths && --pr->ps_tamepaths->wl_ref == 0) {
+ struct whitepaths *wl = pr->ps_tamepaths;
+ int i;
+
+ for (i = 0; i < wl->wl_count; i++)
+ free(wl->wl_paths[i].name, M_TEMP, wl->wl_paths[i].len);
+ free(wl, M_TEMP, wl->wl_size);
+ }
+ pr->ps_tamepaths = NULL;
+}
+
int
canonpath(const char *input, char *buf, size_t bufsize)
{
-/* $OpenBSD: tame.h,v 1.10 2015/10/06 15:21:26 deraadt Exp $ */
+/* $OpenBSD: tame.h,v 1.11 2015/10/07 03:47:43 deraadt Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
#define TAME_TTY 0x00010000 /* tty setting */
#define TAME_SENDFD 0x00020000 /* AF_UNIX CMSG fd sending */
#define TAME_RECVFD 0x00040000 /* AF_UNIX CMSG fd receiving */
+#define TAME_EXEC 0x00080000 /* execve, child is free of tame */
#define TAME_ABORT 0x08000000 /* SIGABRT instead of SIGKILL */
size_t len;
} wl_paths[0];
};
+void tame_dropwpaths(struct process *);
#endif /* _KERNEL */