unexport linux/elfcore.h
Subsystems (5)
Al Viro
maintainer In include/uapi/linux/elfcore.h we have
...
#include <linux/elf.h>
...
struct elf_prstatus
{
...
elf_gregset_t pr_reg; /* GP registers */
and that ends up in glibc /usr/include/linux/elfcore.h. What does *not* end up in exported headers is
1) include of asm/elf.h from linux/elf.h - asm/elf.h
is not exported at all and linux/elf.h is our uapi/linux/elf.h, which doesn't include asm/elf.h at all
2) and definitions of elf_gregset_t whatsoever.
Now, glibc (as well as other libc variants) does contain such definition - in /usr/include/sys/procfs.h. Along with a definition of struct elf_prstatus.
IOW, #include <linux/elfcore.h> in any userland program is going to blow - either due to redefinition of struct elf_prstatus or due to incomplete type of member in that definition, depending upon the headers we'd pulled in earlier.
Seeing that there's no userland code that would manage to pull that file, is there any point exporting it at all?
Al Viro
maintainerQuoted 20 lines · Al Viro
In
include/uapi/linux/elfcore.hwe have
...
#include <linux/elf.h>
...
structelf_prstatus
{
...
elf_gregset_tpr_reg; /* GP registers */and that ends up in glibc
/usr/include/linux/elfcore.h. What does *not* end up in exported headers is
1) include ofasm/elf.hfromlinux/elf.h-asm/elf.h
is not exported at all andlinux/elf.his ouruapi/linux/elf.h, which doesn't includeasm/elf.hat all
2) and definitions ofelf_gregset_twhatsoever.Now, glibc (as well as other libc variants) does contain such definition - in
/usr/include/sys/procfs.h. Along with a definition of structelf_prstatus.
Quoted 7 lines
IOW, #include <
linux/elfcore.h> in any userland program is going to blow - either due to redefinition of structelf_prstatusor due to incomplete type of member in that definition, depending upon the headers we'd pulled in earlier.Seeing that there's no userland code that would manage to pull that file, is there any point exporting it at all?
I mean something like this. Objections?
commit 4d0380050642e4bf4b7a4d90d4bafeceacb1340d
Author: Al Viro <[email protected]> Date: Thu Jun 11 11:11:32 2020 -0400
unexport linux/elfcore.h
It's unusable from userland - it uses elf_gregset_t, which is not provided by exported headers. glibc has it in sys/procfs.h, but the same file defines struct elf_prstatus, so linux/elfcore.h can't be included once sys/procfs.h has been pulled. Same goes for uclibc and dietlibc simply doesn't have elf_gregset_t defined anywhere.
IOW, no userland source is including that thing.
arch/x86/kernel/crash_core_32.c +1 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only #include <linux/crash_core.h> +#include <linux/mmzone.h> #include <asm/pgtable.h> #include <asm/setup.h>
arch/x86/kernel/crash_core_64.c +1 -0
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only #include <linux/crash_core.h> +#include <linux/mmzone.h> #include <asm/pgtable.h> #include <asm/setup.h>
fs/binfmt_elf.c +1 -0
@@ -43,6 +43,7 @@#include <linux/cred.h> #include <linux/dax.h> #include <linux/uaccess.h> +#include <linux/ptrace.h> #include <asm/param.h> #include <asm/page.h>
include/linux/elfcore.h +62 -3
74 lines not on this page · raw message
include/uapi/linux/elfcore.h deleted +0 -101
101 lines not on this page · raw message
scripts/headers_install.sh +0 -1
@@ -89,7 +89,6 @@ arch/x86/include/uapi/asm/auxvec.h:CONFIG_X86_64 arch/x86/include/uapi/asm/mman.h:CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS include/uapi/asm-generic/fcntl.h:CONFIG_64BIT include/uapi/linux/atmdev.h:CONFIG_COMPAT -include/uapi/linux/elfcore.h:CONFIG_BINFMT_ELF_FDPIC include/uapi/linux/eventpoll.h:CONFIG_PM_SLEEP include/uapi/linux/hw_breakpoint.h:CONFIG_HAVE_MIXED_BREAKPOINTS_REGS include/uapi/linux/pktcdvd.h:CONFIG_CDROM_PKTCDVD_WCACHE
usr/include/Makefile +0 -1
@@ -24,7 +24,6 @@ no-header-test += linux/am437x-vpfe.h no-header-test += linux/android/binder.h no-header-test += linux/android/binderfs.h no-header-test += linux/coda.h -no-header-test += linux/elfcore.h no-header-test += linux/errqueue.h no-header-test += linux/fsmap.h no-header-test += linux/hdlc/ioctl.h
Quoted 2 lines · Al Viro
I mean something like this. Objections?
I'm not seeing that alot of people would care.
That said, is there any reason not to try to fix it instead and expose elf_gregset_t some way?
But I do suspect it all really boils down to "nobody cares". If you can't find somebody to speak up for it, might as well remove it.
Linus
Al Viro
maintainerQuoted 11 lines · Linus Torvalds
Quoted 2 lines · Al Viro
I mean something like this. Objections?
I'm not seeing that alot of people would care.
That said, is there any reason not to try to fix it instead and expose
elf_gregset_tsome way?But I do suspect it all really boils down to "nobody cares". If you can't find somebody to speak up for it, might as well remove it.
Anyone who wants to use that stuff includes sys/procfs.h anyway (since 1996). As for the reasons... I would love to kill off these gems, for example:
#define PRSTATUS_SIZE(S, R) (R != sizeof(S.pr_reg) ? 144 : 296) #define SET_PR_FPVALID(S, V, R) \
do { *(int *) (((void *) &((S)->pr_reg)) + R) = (V); } \
while (0)
(x86 asm/compat.h) And being able to massage the definition of elf_prstatus (while keeping the size and layout - it describes a part of file format, after all) would simplify the life alot.
struct __kernel_elf_prstatus would be an obvious solution, but... nobody in userland pulls the definition in linux/elfcore.h and hadn't been able to do that for at least a decade (if not more than that). So I'd rather get rid of exporting it.