linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHSET] saner elf compat
@ 2020-12-03 21:45 Al Viro
  2020-12-03 21:46 ` [PATCH 01/10] binfmt_elf: partially sanitize PRSTATUS_SIZE and SET_PR_FPVALID Al Viro
  2020-12-03 22:09 ` [PATCHSET] saner elf compat Linus Torvalds
  0 siblings, 2 replies; 26+ messages in thread
From: Al Viro @ 2020-12-03 21:45 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: linux-kernel, x86, linux-mips, Randy Dunlap

	This series deals with the warts in ELF compat on triarch
architectures (x86_64 and mips64, that is).

	x86_64 at least does use compat_binfmt_elf.c for both
32bit ABIs; the way it is done is ugly as hell, though, and more
than slightly brittle (see asm/compat.h for PRSTATUS_SIZE and SET_PR_FPVALID
definitions - IMO that kind of magic is too ugly to live).

	mips64, OTOH, does not use compat_binfmt_elf.c for either of its
32bit ABIs.  It has a couple of analogues (each with include of
../../../fs/binfmt_elf.c, BTW), with quite a bit of ancient cruft
accumulated in those.

	Fortunately, cleanup of i386/x32 mess (first 3 commits in
the series) provides a fairly straightforward way for mips64 to use
fs/compat_binfmt_elf.c for both n32 and o32.

	That stuff had been sitting around since June; lately rdd has
spotted Kconfig problems around COMPAT_BINFMT_ELF selects.  All of them
had been on configs that had COMPAT_BINFMT_ELF != COMPAT && BINFMT_ELF.
For most of the architectures that's impossible to achieve, but some
(sparc, e.g.) can end up with that.  Randy posted a patch adding
if BINFMT_ELF to selects that lacked it, but that looked wrong to me -
why not centralize that logics into fs/Kconfig.binfmt?  IOW, what's
the point of having any such selects in arch/*/Kconfig?

	The answer (for mainline) is that mips compat does *NOT* want
COMPAT_BINFMT_ELF.  Not a problem with that series, though, so I'd
retested it (seems to work, both for x86_64 and mips64, execs and
coredumps for all ABIs alike), with centralization of Kconfig logics
thrown in.

	It's based at 5.10-rc1 and lives in
git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git#work.elf-compat
I'll post the individual patches in followups.

Shortlog:
      binfmt_elf: partially sanitize PRSTATUS_SIZE and SET_PR_FPVALID
      elf_prstatus: collect the common part (everything before pr_reg) into a struct
      [elfcore-compat][amd64] clean PRSTATUS_SIZE/SET_PR_FPVALID up properly
      mips binfmt_elf*32.c: use elfcore-compat.h
      mips: kill unused definitions in binfmt_elf[on]32.c
      mips: KVM_GUEST makes no sense for 64bit builds...
      mips compat: don't bother with ELF_ET_DYN_BASE
      mips: don't bother with ELF_CORE_EFLAGS
      mips compat: switch to compat_binfmt_elf.c
      Kconfig: regularize selection of CONFIG_BINFMT_ELF

Diffstat:
 arch/Kconfig                               |   3 +
 arch/arm64/Kconfig                         |   1 -
 arch/ia64/kernel/crash.c                   |   2 +-
 arch/mips/Kconfig                          |   8 +--
 arch/mips/include/asm/elf.h                |  56 +++++----------
 arch/mips/include/asm/elfcore-compat.h     |  29 ++++++++
 arch/mips/kernel/Makefile                  |   4 +-
 arch/mips/kernel/binfmt_elfn32.c           | 106 ----------------------------
 arch/mips/kernel/binfmt_elfo32.c           | 109 -----------------------------
 arch/mips/kernel/scall64-n64.S             |   2 +-
 arch/parisc/Kconfig                        |   1 -
 arch/powerpc/Kconfig                       |   1 -
 arch/powerpc/platforms/powernv/opal-core.c |   6 +-
 arch/s390/Kconfig                          |   1 -
 arch/s390/kernel/crash_dump.c              |   2 +-
 arch/sparc/Kconfig                         |   1 -
 arch/x86/Kconfig                           |   2 +-
 arch/x86/include/asm/compat.h              |  11 ---
 arch/x86/include/asm/elfcore-compat.h      |  31 ++++++++
 fs/Kconfig.binfmt                          |   2 +-
 fs/binfmt_elf.c                            |  19 +++--
 fs/binfmt_elf_fdpic.c                      |  22 ++----
 fs/compat_binfmt_elf.c                     |   1 +
 include/linux/elfcore-compat.h             |  15 +++-
 include/linux/elfcore.h                    |   7 +-
 kernel/kexec_core.c                        |   2 +-
 26 files changed, 127 insertions(+), 317 deletions(-)
 create mode 100644 arch/mips/include/asm/elfcore-compat.h
 delete mode 100644 arch/mips/kernel/binfmt_elfn32.c
 delete mode 100644 arch/mips/kernel/binfmt_elfo32.c
 create mode 100644 arch/x86/include/asm/elfcore-compat.h

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2020-12-29 15:10 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 21:45 [PATCHSET] saner elf compat Al Viro
2020-12-03 21:46 ` [PATCH 01/10] binfmt_elf: partially sanitize PRSTATUS_SIZE and SET_PR_FPVALID Al Viro
2020-12-03 21:46   ` [PATCH 02/10] elf_prstatus: collect the common part (everything before pr_reg) into a struct Al Viro
2020-12-03 21:46   ` [PATCH 03/10] [elfcore-compat][amd64] clean PRSTATUS_SIZE/SET_PR_FPVALID up properly Al Viro
2020-12-03 21:46   ` [PATCH 04/10] mips binfmt_elf*32.c: use elfcore-compat.h Al Viro
2020-12-03 21:46   ` [PATCH 05/10] mips: kill unused definitions in binfmt_elf[on]32.c Al Viro
2020-12-03 21:46   ` [PATCH 06/10] mips: KVM_GUEST makes no sense for 64bit builds Al Viro
2020-12-03 21:46   ` [PATCH 07/10] mips compat: don't bother with ELF_ET_DYN_BASE Al Viro
2020-12-03 21:46   ` [PATCH 08/10] mips: don't bother with ELF_CORE_EFLAGS Al Viro
2020-12-03 21:46   ` [PATCH 09/10] mips compat: switch to compat_binfmt_elf.c Al Viro
2020-12-03 21:46   ` [PATCH 10/10] Kconfig: regularize selection of CONFIG_BINFMT_ELF Al Viro
2020-12-03 22:09 ` [PATCHSET] saner elf compat Linus Torvalds
2020-12-03 23:03   ` Al Viro
2020-12-06  3:23     ` Al Viro
2020-12-07  3:36       ` hpa
2020-12-07 18:01     ` Maciej W. Rozycki
2020-12-16  3:01       ` Al Viro
2020-12-16  9:44         ` Maciej W. Rozycki
2020-12-22 20:04           ` Al Viro
2020-12-22 21:38             ` Al Viro
2020-12-22 22:57               ` Al Viro
2020-12-23  7:03           ` Al Viro
2020-12-23  7:12             ` Al Viro
2020-12-24 19:44               ` [RFC][PATCH] NT_FILE/NT_SIGINFO breakage on mips compat coredumps Al Viro
2020-12-29 15:09                 ` Thomas Bogendoerfer
2020-12-15 19:54     ` [PATCHSET] saner elf compat Thomas Bogendoerfer

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).