* [PATCH] Don't run personality syscall at configure time; don't check it at all
@ 2021-05-06 22:43 Pedro Alves
2021-05-07 14:13 ` Tom Tromey
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Pedro Alves @ 2021-05-06 22:43 UTC (permalink / raw)
To: gdb-patches
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],
In that case we need to fix configure. The fact that personality works on the build machine says nothing about if configure works on the test machine.
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: Remove references to HAVE_PERSONALITY.
(linux_process_target::supports_disable_randomization): Remove
reference to HAVE_PERSONALITY.
* config.in, configure: Regenerate.
gdbsupport/ChangeLog:
* common.m4 (personality test): Remove.
---
gdb/config.in | 7 ----
gdb/configure | 74 -------------------------------------
gdb/linux-nat.c | 4 --
gdb/nat/linux-personality.c | 12 +-----
gdbserver/config.in | 7 ----
gdbserver/configure | 74 -------------------------------------
gdbserver/linux-low.cc | 11 +-----
gdbsupport/common.m4 | 23 ------------
8 files changed, 2 insertions(+), 210 deletions(-)
diff --git a/gdb/config.in b/gdb/config.in
index 5d10377b736..99c924f9ba0 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -96,10 +96,6 @@
/* define if the compiler supports basic C++11 syntax */
#undef HAVE_CXX11
-/* Define to 1 if you have the declaration of `ADDR_NO_RANDOMIZE', and to 0 if
- you don't. */
-#undef HAVE_DECL_ADDR_NO_RANDOMIZE
-
/* Define to 1 if you have the declaration of `asprintf', and to 0 if you
don't. */
#undef HAVE_DECL_ASPRINTF
@@ -301,9 +297,6 @@
/* Define to 1 if you have the <nlist.h> header file. */
#undef HAVE_NLIST_H
-/* Define if you support the personality syscall. */
-#undef HAVE_PERSONALITY
-
/* Define to 1 if you have the `pipe' function. */
#undef HAVE_PIPE
diff --git a/gdb/configure b/gdb/configure
index b47de77bf64..cdc112e10dc 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -13819,80 +13819,6 @@ fi
done
- ac_fn_c_check_decl "$LINENO" "ADDR_NO_RANDOMIZE" "ac_cv_have_decl_ADDR_NO_RANDOMIZE" "#include <sys/personality.h>
-"
-if test "x$ac_cv_have_decl_ADDR_NO_RANDOMIZE" = xyes; then :
- ac_have_decl=1
-else
- ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_ADDR_NO_RANDOMIZE $ac_have_decl
-_ACEOF
-
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/personality.h>
-int
-main ()
-{
-
- # 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
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- have_personality=true
-else
- have_personality=false
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/personality.h>
-int
-main ()
-{
-
- # 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
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- have_personality=true
-else
- have_personality=false
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
- if $have_personality
- then
-
-$as_echo "#define HAVE_PERSONALITY 1" >>confdefs.h
-
- fi
-
ac_fn_c_check_decl "$LINENO" "strstr" "ac_cv_have_decl_strstr" "$ac_includes_default"
if test "x$ac_cv_have_decl_strstr" = xyes; then :
ac_have_decl=1
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index c45e335a762..e595c71c3d3 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -4022,11 +4022,7 @@ linux_nat_target::supports_multi_process ()
bool
linux_nat_target::supports_disable_randomization ()
{
-#ifdef HAVE_PERSONALITY
return true;
-#else
- return false;
-#endif
}
/* SIGCHLD handler that serves two purposes: In non-stop/async mode,
diff --git a/gdb/nat/linux-personality.c b/gdb/nat/linux-personality.c
index 87d19218626..9ce345bc6de 100644
--- a/gdb/nat/linux-personality.c
+++ b/gdb/nat/linux-personality.c
@@ -20,12 +20,7 @@
#include "gdbsupport/common-defs.h"
#include "nat/linux-personality.h"
-#ifdef HAVE_PERSONALITY
-# include <sys/personality.h>
-# if !HAVE_DECL_ADDR_NO_RANDOMIZE
-# define ADDR_NO_RANDOMIZE 0x0040000
-# endif /* ! HAVE_DECL_ADDR_NO_RANDOMIZE */
-#endif /* HAVE_PERSONALITY */
+#include <sys/personality.h>
/* See comment on nat/linux-personality.h. */
@@ -34,7 +29,6 @@ maybe_disable_address_space_randomization (int disable_randomization)
: m_personality_set (false),
m_personality_orig (0)
{
-#ifdef HAVE_PERSONALITY
if (disable_randomization)
{
errno = 0;
@@ -49,14 +43,11 @@ maybe_disable_address_space_randomization (int disable_randomization)
warning (_("Error disabling address space randomization: %s"),
safe_strerror (errno));
}
-#endif /* HAVE_PERSONALITY */
}
maybe_disable_address_space_randomization::
~maybe_disable_address_space_randomization ()
{
-#ifdef HAVE_PERSONALITY
-
if (m_personality_set)
{
errno = 0;
@@ -65,5 +56,4 @@ maybe_disable_address_space_randomization::
warning (_("Error restoring address space randomization: %s"),
safe_strerror (errno));
}
-#endif /* HAVE_PERSONALITY */
}
diff --git a/gdbserver/config.in b/gdbserver/config.in
index 99391b4acff..611bfd7aa76 100644
--- a/gdbserver/config.in
+++ b/gdbserver/config.in
@@ -31,10 +31,6 @@
/* define if the compiler supports basic C++11 syntax */
#undef HAVE_CXX11
-/* Define to 1 if you have the declaration of `ADDR_NO_RANDOMIZE', and to 0 if
- you don't. */
-#undef HAVE_DECL_ADDR_NO_RANDOMIZE
-
/* Define to 1 if you have the declaration of `asprintf', and to 0 if you
don't. */
#undef HAVE_DECL_ASPRINTF
@@ -182,9 +178,6 @@
/* Define to 1 if you have the <netinet/tcp.h> header file. */
#undef HAVE_NETINET_TCP_H
-/* Define if you support the personality syscall. */
-#undef HAVE_PERSONALITY
-
/* Define to 1 if you have the `pipe' function. */
#undef HAVE_PIPE
diff --git a/gdbserver/configure b/gdbserver/configure
index 032b4ae65bb..aab72c0b8c5 100755
--- a/gdbserver/configure
+++ b/gdbserver/configure
@@ -7130,80 +7130,6 @@ fi
done
- ac_fn_c_check_decl "$LINENO" "ADDR_NO_RANDOMIZE" "ac_cv_have_decl_ADDR_NO_RANDOMIZE" "#include <sys/personality.h>
-"
-if test "x$ac_cv_have_decl_ADDR_NO_RANDOMIZE" = xyes; then :
- ac_have_decl=1
-else
- ac_have_decl=0
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_DECL_ADDR_NO_RANDOMIZE $ac_have_decl
-_ACEOF
-
-
- if test "$cross_compiling" = yes; then :
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/personality.h>
-int
-main ()
-{
-
- # 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
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- have_personality=true
-else
- have_personality=false
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <sys/personality.h>
-int
-main ()
-{
-
- # 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
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- have_personality=true
-else
- have_personality=false
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
- if $have_personality
- then
-
-$as_echo "#define HAVE_PERSONALITY 1" >>confdefs.h
-
- fi
-
ac_fn_c_check_decl "$LINENO" "strstr" "ac_cv_have_decl_strstr" "$ac_includes_default"
if test "x$ac_cv_have_decl_strstr" = xyes; then :
ac_have_decl=1
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 251a54f5c4a..27556ffb88a 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -60,12 +60,7 @@
#endif
#include "nat/linux-namespaces.h"
-#ifdef HAVE_PERSONALITY
-# include <sys/personality.h>
-# if !HAVE_DECL_ADDR_NO_RANDOMIZE
-# define ADDR_NO_RANDOMIZE 0x0040000
-# endif
-#endif
+#include <sys/personality.h>
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
@@ -6231,11 +6226,7 @@ linux_process_target::core_of_thread (ptid_t ptid)
bool
linux_process_target::supports_disable_randomization ()
{
-#ifdef HAVE_PERSONALITY
return true;
-#else
- return false;
-#endif
}
bool
diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4
index 3ed95dabc85..2e709dbbdbb 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])
# ----------------------- #
base-commit: ec66d6ea54679d00c1f0d52a5a9fa0cbb8b86d47
--
2.26.2
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [PATCH] Don't run personality syscall at configure time; don't check it at all
2021-05-06 22:43 [PATCH] Don't run personality syscall at configure time; don't check it at all Pedro Alves
@ 2021-05-07 14:13 ` Tom Tromey
2021-05-07 17:42 ` Lancelot SIX via Gdb-patches
2021-05-12 18:24 ` [PATCH] Don't run personality syscall at configure time; don't check it at all Tom Tromey
2 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2021-05-07 14:13 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
>>>>> "Pedro" == Pedro Alves <pedro@palves.net> writes:
Pedro> Since HAVE_PERSONALITY is only checked in Linux code, and
Pedro> ADDR_NO_RANDOMIZE exists for over 15 years, I propose just completely
Pedro> removing the configure checks.
Seems fine to me. Thank you.
Pedro> If for some odd reason, some remotely modern system still needs a
Pedro> configure check, then we can revert this commit but drop the
Pedro> AC_RUN_IFELSE in favor of always doing the AC_LINK_IFELSE
Pedro> cross-compile fallback.
Also makes sense.
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Don't run personality syscall at configure time; don't check it at all
2021-05-06 22:43 [PATCH] Don't run personality syscall at configure time; don't check it at all Pedro Alves
2021-05-07 14:13 ` Tom Tromey
@ 2021-05-07 17:42 ` Lancelot SIX via Gdb-patches
2021-05-08 12:11 ` [pushed] Don't include sys/personality.h in linux-low.cc anymore Pedro Alves
2021-05-12 18:24 ` [PATCH] Don't run personality syscall at configure time; don't check it at all Tom Tromey
2 siblings, 1 reply; 7+ messages in thread
From: Lancelot SIX via Gdb-patches @ 2021-05-07 17:42 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On Thu, May 06, 2021 at 11:43:41PM +0100, Pedro Alves wrote:
> 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],
>
> In that case we need to fix configure. The fact that personality works on the build machine says nothing about if configure works on the test machine.
>
>
> 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: Remove references to HAVE_PERSONALITY.
> (linux_process_target::supports_disable_randomization): Remove
> reference to HAVE_PERSONALITY.
> * config.in, configure: Regenerate.
>
> gdbsupport/ChangeLog:
>
> * common.m4 (personality test): Remove.
> ---
> gdb/config.in | 7 ----
> gdb/configure | 74 -------------------------------------
> gdb/linux-nat.c | 4 --
> gdb/nat/linux-personality.c | 12 +-----
> gdbserver/config.in | 7 ----
> gdbserver/configure | 74 -------------------------------------
> gdbserver/linux-low.cc | 11 +-----
> gdbsupport/common.m4 | 23 ------------
> 8 files changed, 2 insertions(+), 210 deletions(-)
>
> diff --git a/gdb/config.in b/gdb/config.in
> index 5d10377b736..99c924f9ba0 100644
> --- a/gdb/config.in
> +++ b/gdb/config.in
> @@ -96,10 +96,6 @@
> /* define if the compiler supports basic C++11 syntax */
> #undef HAVE_CXX11
>
> -/* Define to 1 if you have the declaration of `ADDR_NO_RANDOMIZE', and to 0 if
> - you don't. */
> -#undef HAVE_DECL_ADDR_NO_RANDOMIZE
> -
> /* Define to 1 if you have the declaration of `asprintf', and to 0 if you
> don't. */
> #undef HAVE_DECL_ASPRINTF
> @@ -301,9 +297,6 @@
> /* Define to 1 if you have the <nlist.h> header file. */
> #undef HAVE_NLIST_H
>
> -/* Define if you support the personality syscall. */
> -#undef HAVE_PERSONALITY
> -
> /* Define to 1 if you have the `pipe' function. */
> #undef HAVE_PIPE
>
> diff --git a/gdb/configure b/gdb/configure
> index b47de77bf64..cdc112e10dc 100755
> --- a/gdb/configure
> +++ b/gdb/configure
> @@ -13819,80 +13819,6 @@ fi
> done
>
>
> - ac_fn_c_check_decl "$LINENO" "ADDR_NO_RANDOMIZE" "ac_cv_have_decl_ADDR_NO_RANDOMIZE" "#include <sys/personality.h>
> -"
> -if test "x$ac_cv_have_decl_ADDR_NO_RANDOMIZE" = xyes; then :
> - ac_have_decl=1
> -else
> - ac_have_decl=0
> -fi
> -
> -cat >>confdefs.h <<_ACEOF
> -#define HAVE_DECL_ADDR_NO_RANDOMIZE $ac_have_decl
> -_ACEOF
> -
> -
> - if test "$cross_compiling" = yes; then :
> - cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h. */
> -#include <sys/personality.h>
> -int
> -main ()
> -{
> -
> - # 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
> - ;
> - return 0;
> -}
> -_ACEOF
> -if ac_fn_c_try_link "$LINENO"; then :
> - have_personality=true
> -else
> - have_personality=false
> -fi
> -rm -f core conftest.err conftest.$ac_objext \
> - conftest$ac_exeext conftest.$ac_ext
> -else
> - cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h. */
> -#include <sys/personality.h>
> -int
> -main ()
> -{
> -
> - # 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
> - ;
> - return 0;
> -}
> -_ACEOF
> -if ac_fn_c_try_run "$LINENO"; then :
> - have_personality=true
> -else
> - have_personality=false
> -fi
> -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
> - conftest.$ac_objext conftest.beam conftest.$ac_ext
> -fi
> -
> - if $have_personality
> - then
> -
> -$as_echo "#define HAVE_PERSONALITY 1" >>confdefs.h
> -
> - fi
> -
> ac_fn_c_check_decl "$LINENO" "strstr" "ac_cv_have_decl_strstr" "$ac_includes_default"
> if test "x$ac_cv_have_decl_strstr" = xyes; then :
> ac_have_decl=1
> diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
> index c45e335a762..e595c71c3d3 100644
> --- a/gdb/linux-nat.c
> +++ b/gdb/linux-nat.c
> @@ -4022,11 +4022,7 @@ linux_nat_target::supports_multi_process ()
> bool
> linux_nat_target::supports_disable_randomization ()
> {
> -#ifdef HAVE_PERSONALITY
> return true;
> -#else
> - return false;
> -#endif
> }
>
> /* SIGCHLD handler that serves two purposes: In non-stop/async mode,
> diff --git a/gdb/nat/linux-personality.c b/gdb/nat/linux-personality.c
> index 87d19218626..9ce345bc6de 100644
> --- a/gdb/nat/linux-personality.c
> +++ b/gdb/nat/linux-personality.c
> @@ -20,12 +20,7 @@
> #include "gdbsupport/common-defs.h"
> #include "nat/linux-personality.h"
>
> -#ifdef HAVE_PERSONALITY
> -# include <sys/personality.h>
> -# if !HAVE_DECL_ADDR_NO_RANDOMIZE
> -# define ADDR_NO_RANDOMIZE 0x0040000
> -# endif /* ! HAVE_DECL_ADDR_NO_RANDOMIZE */
> -#endif /* HAVE_PERSONALITY */
> +#include <sys/personality.h>
>
> /* See comment on nat/linux-personality.h. */
>
> @@ -34,7 +29,6 @@ maybe_disable_address_space_randomization (int disable_randomization)
> : m_personality_set (false),
> m_personality_orig (0)
> {
> -#ifdef HAVE_PERSONALITY
> if (disable_randomization)
> {
> errno = 0;
> @@ -49,14 +43,11 @@ maybe_disable_address_space_randomization (int disable_randomization)
> warning (_("Error disabling address space randomization: %s"),
> safe_strerror (errno));
> }
> -#endif /* HAVE_PERSONALITY */
> }
>
> maybe_disable_address_space_randomization::
> ~maybe_disable_address_space_randomization ()
> {
> -#ifdef HAVE_PERSONALITY
> -
> if (m_personality_set)
> {
> errno = 0;
> @@ -65,5 +56,4 @@ maybe_disable_address_space_randomization::
> warning (_("Error restoring address space randomization: %s"),
> safe_strerror (errno));
> }
> -#endif /* HAVE_PERSONALITY */
> }
> diff --git a/gdbserver/config.in b/gdbserver/config.in
> index 99391b4acff..611bfd7aa76 100644
> --- a/gdbserver/config.in
> +++ b/gdbserver/config.in
> @@ -31,10 +31,6 @@
> /* define if the compiler supports basic C++11 syntax */
> #undef HAVE_CXX11
>
> -/* Define to 1 if you have the declaration of `ADDR_NO_RANDOMIZE', and to 0 if
> - you don't. */
> -#undef HAVE_DECL_ADDR_NO_RANDOMIZE
> -
> /* Define to 1 if you have the declaration of `asprintf', and to 0 if you
> don't. */
> #undef HAVE_DECL_ASPRINTF
> @@ -182,9 +178,6 @@
> /* Define to 1 if you have the <netinet/tcp.h> header file. */
> #undef HAVE_NETINET_TCP_H
>
> -/* Define if you support the personality syscall. */
> -#undef HAVE_PERSONALITY
> -
> /* Define to 1 if you have the `pipe' function. */
> #undef HAVE_PIPE
>
> diff --git a/gdbserver/configure b/gdbserver/configure
> index 032b4ae65bb..aab72c0b8c5 100755
> --- a/gdbserver/configure
> +++ b/gdbserver/configure
> @@ -7130,80 +7130,6 @@ fi
> done
>
>
> - ac_fn_c_check_decl "$LINENO" "ADDR_NO_RANDOMIZE" "ac_cv_have_decl_ADDR_NO_RANDOMIZE" "#include <sys/personality.h>
> -"
> -if test "x$ac_cv_have_decl_ADDR_NO_RANDOMIZE" = xyes; then :
> - ac_have_decl=1
> -else
> - ac_have_decl=0
> -fi
> -
> -cat >>confdefs.h <<_ACEOF
> -#define HAVE_DECL_ADDR_NO_RANDOMIZE $ac_have_decl
> -_ACEOF
> -
> -
> - if test "$cross_compiling" = yes; then :
> - cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h. */
> -#include <sys/personality.h>
> -int
> -main ()
> -{
> -
> - # 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
> - ;
> - return 0;
> -}
> -_ACEOF
> -if ac_fn_c_try_link "$LINENO"; then :
> - have_personality=true
> -else
> - have_personality=false
> -fi
> -rm -f core conftest.err conftest.$ac_objext \
> - conftest$ac_exeext conftest.$ac_ext
> -else
> - cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h. */
> -#include <sys/personality.h>
> -int
> -main ()
> -{
> -
> - # 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
> - ;
> - return 0;
> -}
> -_ACEOF
> -if ac_fn_c_try_run "$LINENO"; then :
> - have_personality=true
> -else
> - have_personality=false
> -fi
> -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
> - conftest.$ac_objext conftest.beam conftest.$ac_ext
> -fi
> -
> - if $have_personality
> - then
> -
> -$as_echo "#define HAVE_PERSONALITY 1" >>confdefs.h
> -
> - fi
> -
> ac_fn_c_check_decl "$LINENO" "strstr" "ac_cv_have_decl_strstr" "$ac_includes_default"
> if test "x$ac_cv_have_decl_strstr" = xyes; then :
> ac_have_decl=1
> diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
> index 251a54f5c4a..27556ffb88a 100644
> --- a/gdbserver/linux-low.cc
> +++ b/gdbserver/linux-low.cc
> @@ -60,12 +60,7 @@
> #endif
> #include "nat/linux-namespaces.h"
>
> -#ifdef HAVE_PERSONALITY
> -# include <sys/personality.h>
> -# if !HAVE_DECL_ADDR_NO_RANDOMIZE
> -# define ADDR_NO_RANDOMIZE 0x0040000
> -# endif
> -#endif
> +#include <sys/personality.h>
Hi,
From what I can see, this include is not needed in this file anymore and
could be removed altogether. It seems to have been forgotten in a past
refactoring[1].
Lancelot.
[1] https://sourceware.org/pipermail/gdb-patches/2015-January/120503.html
>
> #ifndef O_LARGEFILE
> #define O_LARGEFILE 0
> @@ -6231,11 +6226,7 @@ linux_process_target::core_of_thread (ptid_t ptid)
> bool
> linux_process_target::supports_disable_randomization ()
> {
> -#ifdef HAVE_PERSONALITY
> return true;
> -#else
> - return false;
> -#endif
> }
>
> bool
> diff --git a/gdbsupport/common.m4 b/gdbsupport/common.m4
> index 3ed95dabc85..2e709dbbdbb 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])
>
> # ----------------------- #
>
> base-commit: ec66d6ea54679d00c1f0d52a5a9fa0cbb8b86d47
> --
> 2.26.2
>
--
Lancelot SIX
^ permalink raw reply [flat|nested] 7+ messages in thread* [pushed] Don't include sys/personality.h in linux-low.cc anymore
2021-05-07 17:42 ` Lancelot SIX via Gdb-patches
@ 2021-05-08 12:11 ` Pedro Alves
0 siblings, 0 replies; 7+ messages in thread
From: Pedro Alves @ 2021-05-08 12:11 UTC (permalink / raw)
To: Lancelot SIX; +Cc: gdb-patches
On 2021-05-07 6:42 p.m., Lancelot SIX wrote:
> Hi,
>
> From what I can see, this include is not needed in this file anymore and
> could be removed altogether. It seems to have been forgotten in a past
> refactoring[1].
>
> Lancelot.
>
> [1] https://sourceware.org/pipermail/gdb-patches/2015-January/120503.html
>
Indeed. I've pushed this patch below. Thanks!
From e2ea3a381a4a7c739419a8b76a2fd132f7c1f9b1 Mon Sep 17 00:00:00 2001
From: Pedro Alves <pedro@palves.net>
Date: Sat, 8 May 2021 12:54:43 +0100
Subject: [PATCH] Don't include sys/personality.h in linux-low.cc anymore
Lancelot pointed out that since the refactor at:
https://sourceware.org/pipermail/gdb-patches/2015-January/120503.html
the sys/personality.h include is not needed in linux-low.cc anymore,
as it does not call personality directly itself anymore.
gdbserver/ChangeLog:
* linux-low.cc: Don't include sys/personality.h or define
ADDR_NO_RANDOMIZE.
---
gdbserver/ChangeLog | 5 +++++
gdbserver/linux-low.cc | 7 -------
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/gdbserver/ChangeLog b/gdbserver/ChangeLog
index 94e489939c1..1047697b0ed 100644
--- a/gdbserver/ChangeLog
+++ b/gdbserver/ChangeLog
@@ -1,3 +1,8 @@
+2021-05-08 Pedro Alves <pedro@palves.net>
+
+ * linux-low.cc: Don't include sys/personality.h or define
+ ADDR_NO_RANDOMIZE.
+
2021-05-06 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* server.cc (handle_v_attach)
diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index 251a54f5c4a..ca3d25943df 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -60,13 +60,6 @@
#endif
#include "nat/linux-namespaces.h"
-#ifdef HAVE_PERSONALITY
-# include <sys/personality.h>
-# if !HAVE_DECL_ADDR_NO_RANDOMIZE
-# define ADDR_NO_RANDOMIZE 0x0040000
-# endif
-#endif
-
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
#endif
base-commit: 8a16cc4b934b2dee897837b7c68b9393cfd5ef5a
--
2.26.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Don't run personality syscall at configure time; don't check it at all
2021-05-06 22:43 [PATCH] Don't run personality syscall at configure time; don't check it at all Pedro Alves
2021-05-07 14:13 ` Tom Tromey
2021-05-07 17:42 ` Lancelot SIX via Gdb-patches
@ 2021-05-12 18:24 ` Tom Tromey
2021-05-12 19:56 ` Pedro Alves
2 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2021-05-12 18:24 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
>>>>> "Pedro" == Pedro Alves <pedro@palves.net> writes:
Pedro> "man 2 personality" says:
Pedro> This system call first appeared in Linux 1.1.20 (and thus first
Pedro> in a stable kernel release with Linux 1.2.0); library support
Pedro> was added in glibc 2.3.
Pedro> ...
Pedro> ADDR_NO_RANDOMIZE (since Linux 2.6.12)
Pedro> With this flag set, disable address-space-layout randomization.
Pedro> glibc 2.3 was released in 2002.
Pedro> Linux 2.6.12 was released in 2005.
It turns out that this caused the build to fail on RH ES5.
Address space randomization works fine there, and 'personality' exists
-- but ADDR_NO_RANDOMIZE is only defined in <linux/personality.h>, not
<sys/personality.h>.
I have a patch to work around this by restoring this check:
Pedro> - AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
... and the corresponding define in nat/linux-personality.c.
(I tried just including the linux/ header but it doesn't declare
'personality'.)
I don't know if anybody else cares about this old system. If so, let me
know and I can send the patch. Otherwise I may not bother.
thanks,
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Don't run personality syscall at configure time; don't check it at all
2021-05-12 18:24 ` [PATCH] Don't run personality syscall at configure time; don't check it at all Tom Tromey
@ 2021-05-12 19:56 ` Pedro Alves
2021-05-12 19:58 ` Tom Tromey
0 siblings, 1 reply; 7+ messages in thread
From: Pedro Alves @ 2021-05-12 19:56 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 2021-05-12 7:24 p.m., Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <pedro@palves.net> writes:
>
> Pedro> "man 2 personality" says:
>
> Pedro> This system call first appeared in Linux 1.1.20 (and thus first
> Pedro> in a stable kernel release with Linux 1.2.0); library support
> Pedro> was added in glibc 2.3.
>
> Pedro> ...
>
> Pedro> ADDR_NO_RANDOMIZE (since Linux 2.6.12)
> Pedro> With this flag set, disable address-space-layout randomization.
>
> Pedro> glibc 2.3 was released in 2002.
> Pedro> Linux 2.6.12 was released in 2005.
>
> It turns out that this caused the build to fail on RH ES5.
Wow, talk about ancient. Sorry about the breakage. That's no longer maintained by RH,
so I don't think we/RH really care about it. But if you have to support it, fine with
me to keep GDB building there, especially as it doesn't block anything or is complicated.
>
> Address space randomization works fine there, and 'personality' exists
> -- but ADDR_NO_RANDOMIZE is only defined in <linux/personality.h>, not
> <sys/personality.h>.
>
> I have a patch to work around this by restoring this check:
>
> Pedro> - AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
>
> ... and the corresponding define in nat/linux-personality.c.
>
> (I tried just including the linux/ header but it doesn't declare
> 'personality'.)
Would it work to just include both?
Otherwise, do we really need the configure check? Wouldn't just:
#ifndef ADDR_NO_RANDOMIZE
# define ADDR_NO_RANDOMIZE 0x0040000
#endif
work the same?
>
> I don't know if anybody else cares about this old system. If so, let me
> know and I can send the patch. Otherwise I may not bother.
Up to you.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Don't run personality syscall at configure time; don't check it at all
2021-05-12 19:56 ` Pedro Alves
@ 2021-05-12 19:58 ` Tom Tromey
0 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2021-05-12 19:58 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches, Tom Tromey
Pedro> - AC_CHECK_DECLS([ADDR_NO_RANDOMIZE],,, [#include <sys/personality.h>])
>> ... and the corresponding define in nat/linux-personality.c.
>>
>> (I tried just including the linux/ header but it doesn't declare
>> 'personality'.)
Pedro> Would it work to just include both?
No, they both define the same enum constants, so I think this wouldn't
work.
Pedro> Otherwise, do we really need the configure check? Wouldn't just:
Pedro> #ifndef ADDR_NO_RANDOMIZE
Pedro> # define ADDR_NO_RANDOMIZE 0x0040000
Pedro> #endif
Pedro> work the same?
They neglected to use the self-#define trick for these constants.
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-05-12 19:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06 22:43 [PATCH] Don't run personality syscall at configure time; don't check it at all Pedro Alves
2021-05-07 14:13 ` Tom Tromey
2021-05-07 17:42 ` Lancelot SIX via Gdb-patches
2021-05-08 12:11 ` [pushed] Don't include sys/personality.h in linux-low.cc anymore Pedro Alves
2021-05-12 18:24 ` [PATCH] Don't run personality syscall at configure time; don't check it at all Tom Tromey
2021-05-12 19:56 ` Pedro Alves
2021-05-12 19:58 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox