Bug 24813 - <asm/sigcontext.h> and <signal.h> are mutually incompatible on Linux
Summary: <asm/sigcontext.h> and <signal.h> are mutually incompatible on Linux
Status: UNCONFIRMED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.29
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-15 23:08 UTC by Andy Lutomirski
Modified: 2019-10-04 21:08 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Lutomirski 2019-07-15 23:08:04 UTC
This tiny program:

#define _GNU_SOURCE
#include <signal.h>
#include <asm/sigcontext.h>

fails to compile with many errors like this:

In file included from test_ucontext.c:5:
/usr/include/asm/sigcontext.h:40:8: error: redefinition of ‘struct _fpx_sw_bytes’
   40 | struct _fpx_sw_bytes {
      |        ^~~~~~~~~~~~~
In file included from /usr/include/signal.h:291,
                 from test_ucontext.c:2:
/usr/include/bits/sigcontext.h:31:8: note: originally defined here
   31 | struct _fpx_sw_bytes
      |        ^~~~~~~~~~~~~

Glibc's bits/sycontext.h is very similar to the kernel's asm/sigcontext.h, except that glibc's is a bit out of date and uses "__glibc_reserved1" instead of "padding".

Could glibc be switched to use sigcontext.h from the kernel headers?  This awful hack does indeed compile:

#define _GNU_SOURCE
#define _BITS_SIGCONTEXT_H 1
#include <asm/sigcontext.h>
#include <signal.h>

NB: this is a bit related to PR 21457 and, in particular, to commit  251287734e89.  The latter made <asm/ucontext.h> start working.
Comment 1 Carlos O'Donell 2019-07-23 19:56:48 UTC
Andy, Thanks. This looks like the usual header coordination issues we face. Thanks for filling a bug for this so we can track it.