]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix struct sigaltstack namespace (bug 21517).
authorJoseph Myers <joseph@codesourcery.com>
Mon, 5 Jun 2017 10:17:46 +0000 (10:17 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Mon, 5 Jun 2017 10:17:46 +0000 (10:17 +0000)
glibc defines the stack_t type with the tag struct sigaltstack.  This
is not permitted by POSIX; sigaltstack is only reserved with file
scope in the namespace of ordinary identifiers, not the tag namespace,
and in the case where stack_t is obtained from ucontext.h rather than
signal.h, it's not reserved with file scope at all.

This patch removes the tag accordingly and updates uses in glibc of
struct sigaltstack.  This is similar to the removal of the "struct
siginfo" tag a few years ago: C++ name mangling changes are an
unavoidable consequence.  A NEWS item is added to note the changed
mangling.  There is inevitably some risk of breaking builds of
anything that relies on the struct sigaltstack name (though the first
few hits I looked at from codesearch.debian.net generally seemed to
involve code that could use the stack_t name conditionally, so
depending on how they determine the conditionals they may work with
glibc not defining the struct tag anyway).

Tested for x86_64 and x86, and with build-many-glibcs.py.

[BZ #21517]
* bits/types/stack_t.h (stack_t): Remove struct tag.
* sysdeps/unix/sysv/linux/bits/types/stack_t.h (stack_t):
Likewise.
* sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h (stack_t):
Likewise.
* debug/segfault.c (install_handler): Use stack_t instead of
struct sigaltstack.
* hurd/hurd/signal.h (struct hurd_sigstate): Likewise.
* hurd/trampoline.c (_hurd_setup_sighandler): Likewise.
* include/signal.h (__sigaltstack): Likwise.
* signal/sigaltstack.c (__sigaltstack): Likewise.
* signal/signal.h (sigaltstack): Likewise.
* sysdeps/mach/hurd/i386/signal-defines.sym
(SIGALTSTACK__SS_SP__OFFSET): Likewise.
(SIGALTSTACK__SS_SIZE__OFFSET): Likewise.
(SIGALTSTACK__SS_FLAGS__OFFSET): Likewise.
* sysdeps/mach/hurd/sigaltstack.c (__sigaltstack): Likewise.
* sysdeps/mach/hurd/sigstack.c (sigstack): Likewise.
* sysdeps/unix/sysv/linux/alpha/sys/procfs.h (struct
elf_prstatus): Likewise.
* sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c (CHECK_SP):
Likewise.
* sysdeps/unix/sysv/linux/ia64/sys/procfs.h (struct elf_prstatus):
Likewise.
* sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c (CHECK_SP):
Likewise.
* sysdeps/unix/sysv/linux/powerpc/sys/procfs.h (struct
elf_prstatus): Likewise.
* sysdeps/unix/sysv/linux/sh/sys/procfs.h (struct elf_prstatus):
Likewise.
* sysdeps/unix/sysv/linux/sys/procfs.h (struct elf_prstatus):
Likewise.

21 files changed:
ChangeLog
NEWS
bits/types/stack_t.h
debug/segfault.c
hurd/hurd/signal.h
hurd/trampoline.c
include/signal.h
signal/sigaltstack.c
signal/signal.h
sysdeps/mach/hurd/i386/signal-defines.sym
sysdeps/mach/hurd/sigaltstack.c
sysdeps/mach/hurd/sigstack.c
sysdeps/unix/sysv/linux/alpha/sys/procfs.h
sysdeps/unix/sysv/linux/bits/types/stack_t.h
sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c
sysdeps/unix/sysv/linux/ia64/sys/procfs.h
sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c
sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h
sysdeps/unix/sysv/linux/powerpc/sys/procfs.h
sysdeps/unix/sysv/linux/sh/sys/procfs.h
sysdeps/unix/sysv/linux/sys/procfs.h

index 78a8afc2e8c5637f6716b098d4ad4162ee67f68a..6cc3067dae882140332b011276f4eaa7645a295e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,39 @@
+2017-06-05  Joseph Myers  <joseph@codesourcery.com>
+
+       [BZ #21517]
+       * bits/types/stack_t.h (stack_t): Remove struct tag.
+       * sysdeps/unix/sysv/linux/bits/types/stack_t.h (stack_t):
+       Likewise.
+       * sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h (stack_t):
+       Likewise.
+       * debug/segfault.c (install_handler): Use stack_t instead of
+       struct sigaltstack.
+       * hurd/hurd/signal.h (struct hurd_sigstate): Likewise.
+       * hurd/trampoline.c (_hurd_setup_sighandler): Likewise.
+       * include/signal.h (__sigaltstack): Likwise.
+       * signal/sigaltstack.c (__sigaltstack): Likewise.
+       * signal/signal.h (sigaltstack): Likewise.
+       * sysdeps/mach/hurd/i386/signal-defines.sym
+       (SIGALTSTACK__SS_SP__OFFSET): Likewise.
+       (SIGALTSTACK__SS_SIZE__OFFSET): Likewise.
+       (SIGALTSTACK__SS_FLAGS__OFFSET): Likewise.
+       * sysdeps/mach/hurd/sigaltstack.c (__sigaltstack): Likewise.
+       * sysdeps/mach/hurd/sigstack.c (sigstack): Likewise.
+       * sysdeps/unix/sysv/linux/alpha/sys/procfs.h (struct
+       elf_prstatus): Likewise.
+       * sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c (CHECK_SP):
+       Likewise.
+       * sysdeps/unix/sysv/linux/ia64/sys/procfs.h (struct elf_prstatus):
+       Likewise.
+       * sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c (CHECK_SP):
+       Likewise.
+       * sysdeps/unix/sysv/linux/powerpc/sys/procfs.h (struct
+       elf_prstatus): Likewise.
+       * sysdeps/unix/sysv/linux/sh/sys/procfs.h (struct elf_prstatus):
+       Likewise.
+       * sysdeps/unix/sysv/linux/sys/procfs.h (struct elf_prstatus):
+       Likewise.
+
 2017-06-04  Zack Weinberg  <zackw@panix.com>
 
        * sysdeps/gnu/errlist.c: Regenerate.
diff --git a/NEWS b/NEWS
index 256d8f0e3fe76d159ec405134c11e1114fc94b01..608538f77f829112f55b9522d02681d7738cfa23 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -77,6 +77,9 @@ Version 2.26
   compat implementation will be used (which refuses all flags and routes it
   to preadv or pwritev).
 
+* The stack_t type no longer has the name struct sigaltstack.  This changes
+  the C++ name mangling for interfaces involving this type.
+
 Security related changes:
 
 * The DNS stub resolver limits the advertised UDP buffer size to 1200 bytes,
index 3cf0a4019a044f9235477606c45eb2642d0307a7..47149fce94de992048f322133dee84fcbab5cd16 100644 (file)
@@ -23,7 +23,7 @@
 #include <stddef.h>
 
 /* Structure describing a signal stack.  */
-typedef struct sigaltstack
+typedef struct
   {
     void *ss_sp;
     size_t ss_size;
index dac9efb76523616694b05a7e6197062d4f7e9c81..78c1cf5d1d93f072dfcd2ae1c418a3a638cdebce 100644 (file)
@@ -156,7 +156,7 @@ install_handler (void)
   if (getenv ("SEGFAULT_USE_ALTSTACK") != 0)
     {
       void *stack_mem = malloc (2 * SIGSTKSZ);
-      struct sigaltstack ss;
+      stack_t ss;
 
       if (stack_mem != NULL)
        {
index f899e818622582b6c3af0fd266746877f267228c..e03d53e6d789eb41d7e2063fdb9ce5169a530627 100644 (file)
@@ -70,7 +70,7 @@ struct hurd_sigstate
     sigset_t blocked;          /* What signals are blocked.  */
     sigset_t pending;          /* Pending signals, possibly blocked.  */
     struct sigaction actions[NSIG];
-    struct sigaltstack sigaltstack;
+    stack_t sigaltstack;
 
     /* Chain of thread-local signal preemptors; see <hurd/sigpreempt.h>.
        Each element of this chain is in local stack storage, and the chain
index 8216e22b7ac3e166c8aac07257a481767c5fa6f4..e506fd8c964a7ae88e978d5a8cad668dde68c7ff 100644 (file)
@@ -28,7 +28,7 @@
 struct sigcontext *
 _hurd_setup_sighandler (int flags,
                        __sighandler_t handler,
-                       struct sigaltstack *sigaltstack,
+                       stack_t *sigaltstack,
                        int signo, int sigcode,
                        void *state)
 {
index e39ddc60b95c2ae325f5178a0c757a8b8a2faabe..bcf1455ae77086e282544ce45fc361357d4b8204 100644 (file)
@@ -41,8 +41,8 @@ extern int __sigqueue (__pid_t __pid, int __sig,
 #ifdef __USE_MISC
 extern int __sigreturn (struct sigcontext *__scp);
 #endif
-extern int __sigaltstack (const struct sigaltstack *__ss,
-                         struct sigaltstack *__oss);
+extern int __sigaltstack (const stack_t *__ss,
+                         stack_t *__oss);
 extern int __libc_sigaction (int sig, const struct sigaction *act,
                             struct sigaction *oact);
 libc_hidden_proto (__libc_sigaction)
index e4d23195a0b48c262cf1989f9aa054f9b19de23e..b70afa712795d09d4a29486ac4c3fc880339c241 100644 (file)
@@ -21,7 +21,7 @@
 /* Run signals handlers on the stack specified by SS (if not NULL).
    If OSS is not NULL, it is filled in with the old signal stack status.  */
 int
-sigaltstack (const struct sigaltstack *ss, struct sigaltstack *oss)
+sigaltstack (const stack_t *ss, stack_t *oss)
 {
   __set_errno (ENOSYS);
   return -1;
index 21d628dbd26e6ef8d9a3217a662ba28bd992e375..b3114736a528c942e184a7a98a78048edf00a7ee 100644 (file)
@@ -309,8 +309,8 @@ extern int siginterrupt (int __sig, int __interrupt) __THROW;
 
 /* Alternate signal handler stack interface.
    This interface should always be preferred over `sigstack'.  */
-extern int sigaltstack (const struct sigaltstack *__restrict __ss,
-                       struct sigaltstack *__restrict __oss) __THROW;
+extern int sigaltstack (const stack_t *__restrict __ss,
+                       stack_t *__restrict __oss) __THROW;
 
 #endif /* Use POSIX.1-2008 or X/Open Unix.  */
 
index 9521bd723cf1ea38127db39d6ca677d3b5f6da37..e42bbbe0619de47e7ba92a5b8bed66a7eaf929aa 100644 (file)
@@ -5,6 +5,6 @@
 
 HURD_SIGSTATE__SIGALTSTACK__OFFSET     offsetof(struct hurd_sigstate, sigaltstack)
 
-SIGALTSTACK__SS_SP__OFFSET             offsetof(struct sigaltstack, ss_sp)
-SIGALTSTACK__SS_SIZE__OFFSET           offsetof(struct sigaltstack, ss_size)
-SIGALTSTACK__SS_FLAGS__OFFSET          offsetof(struct sigaltstack, ss_flags)
+SIGALTSTACK__SS_SP__OFFSET             offsetof(stack_t, ss_sp)
+SIGALTSTACK__SS_SIZE__OFFSET           offsetof(stack_t, ss_size)
+SIGALTSTACK__SS_FLAGS__OFFSET          offsetof(stack_t, ss_flags)
index 06a6a5c1124999d4332e8b3d8d149960f8c7e8a0..4fba69e76673cff0b49f5323579dc9d6de643c19 100644 (file)
 /* Run signals handlers on the stack specified by SS (if not NULL).
    If OSS is not NULL, it is filled in with the old signal stack status.  */
 int
-__sigaltstack (const struct sigaltstack *argss, struct sigaltstack *oss)
+__sigaltstack (const stack_t *argss, stack_t *oss)
 {
   struct hurd_sigstate *s;
-  struct sigaltstack ss, old;
+  stack_t ss, old;
 
   /* Fault before taking any locks.  */
   if (argss != NULL)
     ss = *argss;
   if (oss != NULL)
-    *(volatile struct sigaltstack *) oss = *oss;
+    *(volatile stack_t *) oss = *oss;
 
   s = _hurd_self_sigstate ();
   __spin_lock (&s->lock);
index a3a11f9772b5e6d4f049668c5e0b414b7e30d9a7..484efb627a9f76e0ebf09bee6b0451f97236aa09 100644 (file)
@@ -24,7 +24,7 @@
 int
 sigstack (struct sigstack *ss, struct sigstack *oss)
 {
-  struct sigaltstack as, oas;
+  stack_t as, oas;
 
   as.ss_sp = ss->ss_sp;
   as.ss_size = 0;
index 2cd69d442eb056de410aa53863fb28f78591fa2b..abc9fd8d6ec3832f1dd1b8cc5734a4bc1184aaf5 100644 (file)
@@ -71,7 +71,7 @@ struct elf_prstatus
     unsigned long int pr_sigpend;      /* Set of pending signals.  */
     unsigned long int pr_sighold;      /* Set of held signals.  */
 #if 0
-    struct sigaltstack pr_altstack;    /* Alternate stack info.  */
+    stack_t pr_altstack;               /* Alternate stack info.  */
     struct sigaction pr_action;                /* Signal action for current sig.  */
 #endif
     __pid_t pr_pid;
index 497e42b0ff6d19cdd287478d12ac4916d7889d89..373c227930736faaf47d8c6b3d26541a8a4667b4 100644 (file)
@@ -23,7 +23,7 @@
 #include <stddef.h>
 
 /* Structure describing a signal stack.  */
-typedef struct sigaltstack
+typedef struct
   {
     void *ss_sp;
     int ss_flags;
index 3a04250add06ecf25b569fbca19815fcb6529661..48aaeb36c967f3f9e4ee99ccfce39aaced31976f 100644 (file)
@@ -27,7 +27,7 @@
        destroyed must all have stack values higher than ours.  */      \
     if ((unsigned long) (sp) > this_sp)                                        \
       {                                                                        \
-        struct sigaltstack oss;                                                \
+        stack_t oss;                                                   \
         INTERNAL_SYSCALL_DECL (err);                                   \
         int result = INTERNAL_SYSCALL (sigaltstack, err, 2, NULL, &oss);\
        /* If we aren't using an alternate stack then we have already   \
index 93e569b2ccb9794adcc174e22588cb8a4ec6e806..afe54fbd539aac4bec41a65da012bacb4b3b7aba 100644 (file)
@@ -73,7 +73,7 @@ struct elf_prstatus
     unsigned long int pr_sigpend;      /* Set of pending signals.  */
     unsigned long int pr_sighold;      /* Set of held signals.  */
 #if 0
-    struct sigaltstack pr_altstack;    /* Alternate stack info.  */
+    stack_t pr_altstack;               /* Alternate stack info.  */
     struct sigaction pr_action;                /* Signal action for current sig.  */
 #endif
     __pid_t pr_pid;
index 3539b54d7ac39d336cdac1f79feaa74cbadf6866..030e46389eae454d1f2c0278e9f6fe0974a8122e 100644 (file)
@@ -24,7 +24,7 @@
     register unsigned long this_sp asm ("sp");                               \
     if ((unsigned long) (sp) < this_sp)                                              \
       {                                                                              \
-       struct sigaltstack oss;                                               \
+       stack_t oss;                                                          \
        INTERNAL_SYSCALL_DECL (err);                                          \
        int result = INTERNAL_SYSCALL (sigaltstack, err, 2, NULL, &oss);      \
        if (!INTERNAL_SYSCALL_ERROR_P (result, err)                           \
index ef06072e94c868b0cd52c1b2df3124fb91c650ac..b9635ad18aa0675f5cb36780d40b4407792cb130 100644 (file)
@@ -23,7 +23,7 @@
 #include <stddef.h>
 
 /* Structure describing a signal stack.  */
-typedef struct sigaltstack
+typedef struct
   {
     void *ss_sp;
     size_t ss_size;
index b7b7b0b904aefedf6bff6aa129fc2634eb3539f6..61ded2295555133f194be986f0bbbe7a51ce71f2 100644 (file)
@@ -83,7 +83,7 @@ struct elf_prstatus
     unsigned long int pr_sigpend;      /* Set of pending signals.  */
     unsigned long int pr_sighold;      /* Set of held signals.  */
 #if 0
-    struct sigaltstack pr_altstack;    /* Alternate stack info.  */
+    stack_t pr_altstack;               /* Alternate stack info.  */
     struct sigaction pr_action;                /* Signal action for current sig.  */
 #endif
     __pid_t pr_pid;
index c41c87788b5ca270b42da6cc3c2a20e3e2aef061..414911a66185818f2c3ddd5bdfd0b575c0075832 100644 (file)
@@ -55,7 +55,7 @@ struct elf_prstatus
     unsigned long int pr_sigpend;      /* Set of pending signals.  */
     unsigned long int pr_sighold;      /* Set of held signals.  */
 #if 0
-    struct sigaltstack pr_altstack;    /* Alternate stack info.  */
+    stack_t pr_altstack;               /* Alternate stack info.  */
     struct sigaction pr_action;                /* Signal action for current sig.  */
 #endif
     __pid_t pr_pid;
index 8dfa0c08d54b9253386397f639b5b08eb39cb5be..b3b2cf3e12a7da292190bc753416866b7ca18db9 100644 (file)
@@ -58,7 +58,7 @@ struct elf_prstatus
     unsigned long int pr_sigpend;      /* Set of pending signals.  */
     unsigned long int pr_sighold;      /* Set of held signals.  */
 #if 0
-    struct sigaltstack pr_altstack;    /* Alternate stack info.  */
+    stack_t pr_altstack;               /* Alternate stack info.  */
     struct sigaction pr_action;                /* Signal action for current sig.  */
 #endif
     __pid_t pr_pid;