linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: linux-kernel@vger.kernel.org
Subject: sizeof (siginfo_t) problem
Date: Mon, 14 Jul 2003 08:40:00 -0400	[thread overview]
Message-ID: <20030714084000.J15481@devserv.devel.redhat.com> (raw)

Hi!

When siginfo_t was added, the intent obviously was that its size
be 128 bytes on all arches.
This is true on all 32-bit arches and what glibc has in its siginfo_t
definition on all arches:
# if __WORDSIZE == 64
#  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 4)
# else
#  define __SI_PAD_SIZE     ((__SI_MAX_SIZE / sizeof (int)) - 3)
# endif

typedef struct siginfo
  {
    int si_signo;               /* Signal number.  */
    int si_errno;               /* If non-zero, an errno value associated with
                                   this signal, as defined in <errno.h>.  */
    int si_code;                /* Signal code.  */

    union
      {
        int _pad[__SI_PAD_SIZE];
...
        struct
          {
            void *si_addr;      /* Faulting insn/memory ref.  */
          } _sigfault;
...
      } _sifields;
  } siginfo_t;

The kernel unfortunately does this right on sparc64 and alpha from 64-bit
arches only; ia64, s390x, ppc64 etc. got it wrong.

This is a bad problem, since e.g. sigwaitinfo(3) is supported ABI,
and apps - as they are compiled against glibc headers, not kernel ones -
will thus reserve on the stack 8 bytes less than the kernel fills
(this is hidden in copy_siginfo_to_user, so usually only if si_code >= 0
all 136 bytes will be copied).
Note that glibc had such siginfo_t definitions from the beggining,
ie. it is not something changed recently. E.g. on s390x,
such definition was already in -r1.1 checkin in March 2001, x86_64/ia64
never had its own siginfo.h but used a generic one which had the
above __SI_PAD_SIZE definition since early 2000 (x86_64 was added in 2001,
ia64 about 5 months later than that change).

I have noticed this on s390x in a different place:
MD_FALLBACK_FRAME_STATE_FOR in gcc, in order to unwind through
signal frames, needs to locate ucontext, and looking at
stack pointer + 8 + sizeof(siginfo_t) (which works on s390 32-bit)
did not work at all, everything was shifted by 8 bytes.
This though means that the kernel siginfo_t change cannot be done
just in asm-*/siginfo.h headers - at least places where siginfo_t
is present within some structures ever visible to userland a dummy
8 byte pad needs to be inserted.

	Jakub

             reply	other threads:[~2003-07-14 12:37 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-14 12:40 Jakub Jelinek [this message]
2003-07-14 13:55 ` sizeof (siginfo_t) problem Jamie Lokier
2003-07-14 15:02   ` Andreas Schwab
2003-07-14 15:48 ` David Mosberger
2003-07-14 15:57   ` Jakub Jelinek
2003-07-14 16:52 ` Stephen Rothwell
2003-07-14 17:00   ` Jakub Jelinek
2003-07-14 17:11     ` Stephen Rothwell
2003-07-14 17:14       ` Jakub Jelinek
2003-07-14 17:25         ` Stephen Rothwell
2003-07-14 17:45           ` Jakub Jelinek
2003-07-19 18:32   ` Anton Blanchard
2003-07-21  0:08     ` Stephen Rothwell
2003-07-22 13:42       ` Russell King
2003-07-22 13:57         ` Stephen Rothwell
2003-07-14 18:31 Ulrich Weigand
2003-07-14 18:35 ` Jakub Jelinek
2003-07-14 18:52 Ulrich Weigand
2003-07-15 11:58 Martin Schwidefsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030714084000.J15481@devserv.devel.redhat.com \
    --to=jakub@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).