summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-12-02 00:07:06 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-12-02 00:07:06 +0000
commit79a0860311f5ec209b8bd9905f52cafa77f33fac (patch)
treeac900560723b9ed223bce93a665171e7478be895 /sys
parent1f451a7c41cc7a1ba2b807cc42d8a449b68c008d (diff)
If i386, and COMPAT_LINUX is enabled, if setegid() is called with an out
of range value recognize it as the Linux personality() system call, and switch into Linux emulation mode.... At least they could have picked an unused system call number!
Diffstat (limited to 'sys')
-rw-r--r--sys/compat/svr4/svr4_misc.c37
-rw-r--r--sys/compat/svr4/syscalls.master4
2 files changed, 38 insertions, 3 deletions
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c
index 1f34a282438..c9d7155fb26 100644
--- a/sys/compat/svr4/svr4_misc.c
+++ b/sys/compat/svr4/svr4_misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: svr4_misc.c,v 1.17 1997/11/14 21:22:52 deraadt Exp $ */
+/* $OpenBSD: svr4_misc.c,v 1.18 1997/12/02 00:07:04 deraadt Exp $ */
/* $NetBSD: svr4_misc.c,v 1.42 1996/12/06 03:22:34 christos Exp $ */
/*
@@ -48,6 +48,7 @@
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
+#include <sys/ktrace.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/resource.h>
@@ -1338,3 +1339,37 @@ svr4_sys_nice(p, v, retval)
return 0;
}
+
+/* ARGSUSED */
+int
+svr4_sys_setegid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sys_setegid_args /* {
+ syscallarg(gid_t) egid;
+ } */ *uap = v;
+
+#if defined(COMPAT_LINUX) && defined(i386)
+ if (SCARG(uap, egid) > 60000) {
+ /*
+ * One great fuckup deserves another. The Linux people
+ * made this their personality system call. But we can't
+ * tell if a binary is SVR4 or Linux until they do that
+ * system call, in some cases. So when we get it, and the
+ * value is out of some magical range, switch to Linux
+ * emulation and pray.
+ */
+ extern struct emul emul_linux_elf;
+
+ p->p_emul = &emul_linux_elf;
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_EMUL))
+ ktremul(p->p_tracep, p->p_emul->e_name);
+#endif
+ return (0);
+ }
+#endif
+ return sys_setegid(p, v, retval);
+}
diff --git a/sys/compat/svr4/syscalls.master b/sys/compat/svr4/syscalls.master
index 87aaea71445..d30b50c4513 100644
--- a/sys/compat/svr4/syscalls.master
+++ b/sys/compat/svr4/syscalls.master
@@ -1,4 +1,4 @@
- $OpenBSD: syscalls.master,v 1.19 1997/11/13 06:23:06 deraadt Exp $
+ $OpenBSD: syscalls.master,v 1.20 1997/12/02 00:07:05 deraadt Exp $
; $NetBSD: syscalls.master,v 1.17 1996/02/10 17:12:51 christos Exp $
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@@ -234,7 +234,7 @@
134 NOARGS { int sys_rename(char *from, char *to); }
135 STD { int svr4_sys_uname(struct svr4_utsname* name, \
int dummy); }
-136 NOARGS { int sys_setegid(gid_t egid); }
+136 STD { int svr4_sys_setegid(gid_t egid); }
137 STD { int svr4_sys_sysconfig(int name); }
138 NOARGS { int sys_adjtime(struct timeval *delta, \
struct timeval *olddelta); }