diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2016-03-21 00:41:14 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2016-03-21 00:41:14 +0000 |
commit | d4c8db29044b848271e1a2a3de2d895b0df21c40 (patch) | |
tree | 88c86320f71355c915d72337a7a679b97b10299a | |
parent | 9a3f69d151bba1d087d38b790d50ba4970018753 (diff) |
The asm in the MD_DISABLE_KBIND macro was too fragile and broke alpha and hppa.
So instead, do the kbind disabling with syscall().
debugging and ok deraadt@, ok kettenis@
-rw-r--r-- | lib/libc/arch/alpha/gdtoa/kbind.h | 28 | ||||
-rw-r--r-- | lib/libc/arch/amd64/gdtoa/kbind.h | 26 | ||||
-rw-r--r-- | lib/libc/arch/arm/gdtoa/kbind.h | 27 | ||||
-rw-r--r-- | lib/libc/arch/hppa/gdtoa/kbind.h | 30 | ||||
-rw-r--r-- | lib/libc/arch/hppa64/gdtoa/kbind.h | 4 | ||||
-rw-r--r-- | lib/libc/arch/i386/gdtoa/kbind.h | 27 | ||||
-rw-r--r-- | lib/libc/arch/m88k/gdtoa/kbind.h | 27 | ||||
-rw-r--r-- | lib/libc/arch/mips64/gdtoa/kbind.h | 27 | ||||
-rw-r--r-- | lib/libc/arch/powerpc/gdtoa/kbind.h | 23 | ||||
-rw-r--r-- | lib/libc/arch/sh/gdtoa/kbind.h | 27 | ||||
-rw-r--r-- | lib/libc/arch/sparc/gdtoa/kbind.h | 27 | ||||
-rw-r--r-- | lib/libc/arch/sparc64/gdtoa/kbind.h | 27 | ||||
-rw-r--r-- | lib/libc/dlfcn/init.c | 9 |
13 files changed, 5 insertions, 304 deletions
diff --git a/lib/libc/arch/alpha/gdtoa/kbind.h b/lib/libc/arch/alpha/gdtoa/kbind.h deleted file mode 100644 index a0b474b72e1..00000000000 --- a/lib/libc/arch/alpha/gdtoa/kbind.h +++ /dev/null @@ -1,28 +0,0 @@ -/* $OpenBSD: kbind.h,v 1.1 2016/03/20 02:32:39 guenther Exp $ */ - -/* - * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/syscall.h> -#include <machine/pal.h> - -#define MD_DISABLE_KBIND \ - do { \ - register long syscall_num __asm("$0") /* v0 */ = SYS_kbind;\ - register void *arg1 __asm("$16") /* a0 */ = NULL; \ - __asm volatile("call_pal %1" : "+r" (syscall_num) \ - : "i" (PAL_OSF1_callsys), "r" (arg1) : "$19", "$20");\ - } while (0) diff --git a/lib/libc/arch/amd64/gdtoa/kbind.h b/lib/libc/arch/amd64/gdtoa/kbind.h deleted file mode 100644 index 7fa6b1df640..00000000000 --- a/lib/libc/arch/amd64/gdtoa/kbind.h +++ /dev/null @@ -1,26 +0,0 @@ -/* $OpenBSD: kbind.h,v 1.1 2016/03/20 02:32:39 guenther Exp $ */ - -/* - * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/syscall.h> - -#define MD_DISABLE_KBIND \ - do { \ - register long syscall_num __asm("rax") = SYS_kbind; \ - __asm volatile("syscall" : "+r" (syscall_num) : \ - "D" (0) : "cc", "rdx", "rcx", "r11", "memory"); \ - } while (0) diff --git a/lib/libc/arch/arm/gdtoa/kbind.h b/lib/libc/arch/arm/gdtoa/kbind.h deleted file mode 100644 index bfa8c493a16..00000000000 --- a/lib/libc/arch/arm/gdtoa/kbind.h +++ /dev/null @@ -1,27 +0,0 @@ -/* $OpenBSD: kbind.h,v 1.1 2016/03/20 02:32:39 guenther Exp $ */ - -/* - * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/syscall.h> - -#define MD_DISABLE_KBIND \ - do { \ - register long syscall_num __asm("r12") = SYS_kbind; \ - register void *arg1 __asm("r0") = NULL; \ - __asm volatile("swi 0" : "+r" (arg1) \ - : "r" (syscall_num) : "r1", "cc"); \ - } while (0) diff --git a/lib/libc/arch/hppa/gdtoa/kbind.h b/lib/libc/arch/hppa/gdtoa/kbind.h deleted file mode 100644 index 26a5099296b..00000000000 --- a/lib/libc/arch/hppa/gdtoa/kbind.h +++ /dev/null @@ -1,30 +0,0 @@ -/* $OpenBSD: kbind.h,v 1.1 2016/03/20 02:32:39 guenther Exp $ */ - -/* - * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/syscall.h> -#include <machine/vmparam.h> /* SYSCALLGATE */ - -#define MD_DISABLE_KBIND \ -do { \ - register long r1 __asm__("r1") = SYSCALLGATE; \ - register void *arg0 __asm__("r26") = NULL; \ - __asm__ __volatile__ ("ble 4(%%sr7, %%r1) ! ldi %0, %%r22" \ - : \ - : "i" (SYS_kbind), "r" (r1), "r"(arg0) \ - : "r22", "r28", "r29", "cc", "memory"); \ -} while (0) diff --git a/lib/libc/arch/hppa64/gdtoa/kbind.h b/lib/libc/arch/hppa64/gdtoa/kbind.h deleted file mode 100644 index 5ad40bb38eb..00000000000 --- a/lib/libc/arch/hppa64/gdtoa/kbind.h +++ /dev/null @@ -1,4 +0,0 @@ -/* $OpenBSD: kbind.h,v 1.1 2016/03/20 02:32:39 guenther Exp $ */ - -/* kbind disabled in the kernel for hppa64 until we do dynamic linking */ -#define MD_DISABLE_KBIND do { } while (0) diff --git a/lib/libc/arch/i386/gdtoa/kbind.h b/lib/libc/arch/i386/gdtoa/kbind.h deleted file mode 100644 index ddba710c51d..00000000000 --- a/lib/libc/arch/i386/gdtoa/kbind.h +++ /dev/null @@ -1,27 +0,0 @@ -/* $OpenBSD: kbind.h,v 1.1 2016/03/20 02:32:39 guenther Exp $ */ - -/* - * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/syscall.h> - -#define MD_DISABLE_KBIND \ - do { \ - register long syscall_num __asm("eax") = SYS_kbind; \ - __asm volatile("pushl $0; push %%eax; int $0x80;" \ - " addl $8, %%esp" : "+a" (syscall_num) : \ - : "edx", "cc"); \ - } while (0) diff --git a/lib/libc/arch/m88k/gdtoa/kbind.h b/lib/libc/arch/m88k/gdtoa/kbind.h deleted file mode 100644 index 329e2060236..00000000000 --- a/lib/libc/arch/m88k/gdtoa/kbind.h +++ /dev/null @@ -1,27 +0,0 @@ -/* $OpenBSD: kbind.h,v 1.1 2016/03/20 02:32:39 guenther Exp $ */ - -/* - * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/syscall.h> - -#define MD_DISABLE_KBIND \ - do { \ - register long syscall_num __asm("r13") = SYS_kbind; \ - register void *arg1 __asm("r2") = NULL; \ - __asm volatile("tb0 0, %%r0, 450; or %%r0, %%r0, %%r0" \ - : "+r" (arg1) : "r" (syscall_num) : "r3", "cc"); \ - } while (0) diff --git a/lib/libc/arch/mips64/gdtoa/kbind.h b/lib/libc/arch/mips64/gdtoa/kbind.h deleted file mode 100644 index 06ecc4f0758..00000000000 --- a/lib/libc/arch/mips64/gdtoa/kbind.h +++ /dev/null @@ -1,27 +0,0 @@ -/* $OpenBSD: kbind.h,v 1.1 2016/03/20 02:32:39 guenther Exp $ */ - -/* - * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/syscall.h> - -#define MD_DISABLE_KBIND \ - do { \ - register long syscall_num __asm("v0") = SYS_kbind; \ - register void *arg1 __asm("a0") = NULL; \ - __asm volatile("syscall" : "+r" (syscall_num) \ - : "r" (arg1) : "v1", "a3"); \ - } while (0) diff --git a/lib/libc/arch/powerpc/gdtoa/kbind.h b/lib/libc/arch/powerpc/gdtoa/kbind.h deleted file mode 100644 index 3e324d59636..00000000000 --- a/lib/libc/arch/powerpc/gdtoa/kbind.h +++ /dev/null @@ -1,23 +0,0 @@ -/* $OpenBSD: kbind.h,v 1.1 2016/03/20 02:32:39 guenther Exp $ */ - -/* - * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/syscall.h> - -#define MD_DISABLE_KBIND \ - __asm volatile("li %%r3, 0; li %%r0, %0; sc" : \ - : "i" (SYS_kbind) : "r0", "r3", "r4", "cc") diff --git a/lib/libc/arch/sh/gdtoa/kbind.h b/lib/libc/arch/sh/gdtoa/kbind.h deleted file mode 100644 index 597556f8a33..00000000000 --- a/lib/libc/arch/sh/gdtoa/kbind.h +++ /dev/null @@ -1,27 +0,0 @@ -/* $OpenBSD: kbind.h,v 1.1 2016/03/20 02:32:39 guenther Exp $ */ - -/* - * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/syscall.h> - -#define MD_DISABLE_KBIND \ - do { \ - register long syscall_num __asm("r0") = SYS_kbind; \ - register void *arg1 __asm("r4") = NULL; \ - __asm volatile("trapa #0x80" : "+r" (syscall_num) \ - : "r" (arg1) : "r1", "cc"); \ - } while (0) diff --git a/lib/libc/arch/sparc/gdtoa/kbind.h b/lib/libc/arch/sparc/gdtoa/kbind.h deleted file mode 100644 index 62db01ad881..00000000000 --- a/lib/libc/arch/sparc/gdtoa/kbind.h +++ /dev/null @@ -1,27 +0,0 @@ -/* $OpenBSD: kbind.h,v 1.1 2016/03/20 02:32:39 guenther Exp $ */ - -/* - * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/syscall.h> - -#define MD_DISABLE_KBIND \ - do { \ - register long syscall_num __asm("g1") = SYS_kbind; \ - register void *arg1 __asm("o0") = NULL; \ - __asm volatile("t 0" : "+r" (arg1) : "r" (syscall_num) \ - : "o1", "cc"); \ - } while (0) diff --git a/lib/libc/arch/sparc64/gdtoa/kbind.h b/lib/libc/arch/sparc64/gdtoa/kbind.h deleted file mode 100644 index 62db01ad881..00000000000 --- a/lib/libc/arch/sparc64/gdtoa/kbind.h +++ /dev/null @@ -1,27 +0,0 @@ -/* $OpenBSD: kbind.h,v 1.1 2016/03/20 02:32:39 guenther Exp $ */ - -/* - * Copyright (c) 2016 Philip Guenther <guenther@openbsd.org> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include <sys/syscall.h> - -#define MD_DISABLE_KBIND \ - do { \ - register long syscall_num __asm("g1") = SYS_kbind; \ - register void *arg1 __asm("o0") = NULL; \ - __asm volatile("t 0" : "+r" (arg1) : "r" (syscall_num) \ - : "o1", "cc"); \ - } while (0) diff --git a/lib/libc/dlfcn/init.c b/lib/libc/dlfcn/init.c index c0589dffb1a..9e6af9d92f2 100644 --- a/lib/libc/dlfcn/init.c +++ b/lib/libc/dlfcn/init.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init.c,v 1.2 2016/03/20 03:01:57 guenther Exp $ */ +/* $OpenBSD: init.c,v 1.3 2016/03/21 00:41:13 guenther Exp $ */ /* * Copyright (c) 2014,2015 Philip Guenther <guenther@openbsd.org> * @@ -20,12 +20,12 @@ #include <sys/types.h> #include <sys/exec_elf.h> +#include <sys/syscall.h> #include <limits.h> /* NAME_MAX */ #include <stdlib.h> /* atexit */ #include <string.h> #include <unistd.h> /* _pagesize */ -#include "kbind.h" /* XXX should be in an include file shared with csu */ char ***_csu_finish(char **_argv, char **_envp, void (*_cleanup)(void)); @@ -87,9 +87,10 @@ _csu_finish(char **argv, char **envp, void (*cleanup)(void)) static inline void early_static_init(char **argv, char **envp) { - static char progname_storage[NAME_MAX+1] = ""; + static char progname_storage[NAME_MAX+1]; - MD_DISABLE_KBIND; + /* disable kbind */ + syscall(SYS_kbind, (void *)NULL, (size_t)0, (long long)0); environ = envp; |