aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2021-04-28 23:05:15 +0100
committerPedro Alves <pedro@palves.net>2021-05-08 13:45:36 +0100
commit4655f8509fd44e6efabefa373650d9982ff37fd6 (patch)
tree06c9df0c5eb22692fde447475a1cef56851568e1 /gdbsupport
parente2ea3a381a4a7c739419a8b76a2fd132f7c1f9b1 (diff)
downloadgdb-4655f8509fd44e6efabefa373650d9982ff37fd6.zip
gdb-4655f8509fd44e6efabefa373650d9982ff37fd6.tar.gz
gdb-4655f8509fd44e6efabefa373650d9982ff37fd6.tar.bz2
Don't run personality syscall at configure time; don't check it at all
Currently, in order to tell whether support for disabling address space randomization on Linux is available, GDB checks if the personality syscall works, at configure time. I.e., it does a run test, instead of a compile/link test: AC_RUN_IFELSE([PERSONALITY_TEST], [have_personality=true], [have_personality=false], This is a bit bogus, because the machine the build is done on may not (and is when you consider distro gdbs) be the machine that eventually runs gdb. It would be better if this were a compile/link test instead, and then at runtime, GDB coped with the personality syscall failing. Actually, GDB already copes. One environment where this is problematic is building GDB in a Docker container -- by default, Docker runs the container with seccomp, with a profile that disables the personality syscall. You can tell Docker to use a less restricted seccomp profile, but I think we should just fix it in GDB. "man 2 personality" says: This system call first appeared in Linux 1.1.20 (and thus first in a stable kernel release with Linux 1.2.0); library support was added in glibc 2.3. ... ADDR_NO_RANDOMIZE (since Linux 2.6.12) With this flag set, disable address-space-layout randomization. glibc 2.3 was released in 2002. Linux 2.6.12 was released in 2005. The original patch that added the configure checks was submitted in 2008. The first version of the patch that was submitted to the list called personality from common code: https://sourceware.org/pipermail/gdb-patches/2008-June/058204.html and then was moved to Linux-specific code: https://sourceware.org/pipermail/gdb-patches/2008-June/058209.html Since HAVE_PERSONALITY is only checked in Linux code, and ADDR_NO_RANDOMIZE exists for over 15 years, I propose just completely removing the configure checks. If for some odd reason, some remotely modern system still needs a configure check, then we can revert this commit but drop the AC_RUN_IFELSE in favor of always doing the AC_LINK_IFELSE cross-compile fallback. gdb/ChangeLog: * linux-nat.c (linux_nat_target::supports_disable_randomization): Remove references to HAVE_PERSONALITY. * nat/linux-personality.c: Remove references to HAVE_PERSONALITY. (maybe_disable_address_space_randomization) (~maybe_disable_address_space_randomizatio): Remove references to HAVE_PERSONALITY. * config.in, configure: Regenerate. gdbserver/ChangeLog: * linux-low.cc: (linux_process_target::supports_disable_randomization): Remove reference to HAVE_PERSONALITY. * config.in, configure: Regenerate. gdbsupport/ChangeLog: * common.m4 (personality test): Remove.
Diffstat (limited to 'gdbsupport')
-rw-r--r--gdbsupport/ChangeLog4
-rw-r--r--gdbsupport/common.m423
2 files changed, 4 insertions, 23 deletions
diff --git a/gdbsupport/ChangeLog b/gdbsupport/ChangeLog
index 72802c6..8b9077c 100644
--- a/gdbsupport/ChangeLog
+++ b/gdbsupport/ChangeLog
@@ -1,3 +1,7 @@
+2021-05-08 Pedro Alves <pedro@palves.net>
+
+ * common.m4 (personality test): Remove.
+
2021-04-30 Tom Tromey <tromey@adacore.com>
* thread-pool.cc (thread_pool::post_task): Update.
diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4
index 3ed95da..2e709db 100644
--- a/gdbsupport/common.m4
+++ b/gdbsupport/common.m4
@@ -55,29 +55,6 @@ AC_DEFUN([GDB_AC_COMMON], [
ptrace64 sbrk setns sigaltstack sigprocmask \
setpgid setpgrp getrusage getauxval])
- dnl Check if we can disable the virtual address space randomization.
- dnl The functionality of setarch -R.
- AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
- define([PERSONALITY_TEST], [AC_LANG_PROGRAM([#include <sys/personality.h>], [
- # if !HAVE_DECL_ADDR_NO_RANDOMIZE
- # define ADDR_NO_RANDOMIZE 0x0040000
- # endif
- /* Test the flag could be set and stays set. */
- personality (personality (0xffffffff) | ADDR_NO_RANDOMIZE);
- if (!(personality (personality (0xffffffff)) & ADDR_NO_RANDOMIZE))
- return 1])])
- AC_RUN_IFELSE([PERSONALITY_TEST],
- [have_personality=true],
- [have_personality=false],
- [AC_LINK_IFELSE([PERSONALITY_TEST],
- [have_personality=true],
- [have_personality=false])])
- if $have_personality
- then
- AC_DEFINE([HAVE_PERSONALITY], 1,
- [Define if you support the personality syscall.])
- fi
-
AC_CHECK_DECLS([strstr])
# ----------------------- #