Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Jun 19, 2024
  2. Aug 23, 2023
  3. Sep 27, 2022
  4. Sep 13, 2022
    • Max Filippov's avatar
      xtensa: add FDPIC and static PIE support for noMMU · e3ddb8bb
      Max Filippov authored
      
      Define ELFOSABI_XTENSA_FDPIC and use it as an OSABI tag in the ELF
      header to distinguish FDPIC ELF files from regular ELF files.
      Define ELF_FDPIC_PLAT_INIT and put executable map, interpreter map and
      executable dynamic section addresses into registers a4..a6.
      Update start_thread macro to preserve register values in the current
      register window.
      Add definitions for PTRACE_GETFDPIC, PTRACE_GETFDPIC_EXEC and
      PTRACE_GETFDPIC_INTERP.
      
      Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
      e3ddb8bb
  5. May 15, 2022
  6. Apr 22, 2022
  7. Mar 03, 2022
    • Kees Cook's avatar
      binfmt_elf: Introduce KUnit test · 9e1a3ce0
      Kees Cook authored
      
      Adds simple KUnit test for some binfmt_elf internals: specifically a
      regression test for the problem fixed by commit 8904d9cd90ee ("ELF:
      fix overflow in total mapping size calculation").
      
      $ ./tools/testing/kunit/kunit.py run --arch x86_64 \
          --kconfig_add CONFIG_IA32_EMULATION=y '*binfmt_elf'
      ...
      [19:41:08] ================== binfmt_elf (1 subtest) ==================
      [19:41:08] [PASSED] total_mapping_size_test
      [19:41:08] =================== [PASSED] binfmt_elf ====================
      [19:41:08] ============== compat_binfmt_elf (1 subtest) ===============
      [19:41:08] [PASSED] total_mapping_size_test
      [19:41:08] ================ [PASSED] compat_binfmt_elf ================
      [19:41:08] ============================================================
      [19:41:08] Testing complete. Passed: 2, Failed: 0, Crashed: 0, Skipped: 0, Errors: 0
      
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: David Gow <davidgow@google.com>
      Cc: Alexey Dobriyan <adobriyan@gmail.com>
      Cc: "Magnus Groß" <magnus.gross@rwth-aachen.de>
      Cc: kunit-dev@googlegroups.com
      Cc: linux-fsdevel@vger.kernel.org
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      ---
      v1: https://lore.kernel.org/lkml/20220224054332.1852813-1-keescook@chromium.org
      v2:
       - improve commit log
       - fix comment URL (Daniel)
       - drop redundant KUnit Kconfig help info (Daniel)
       - note in Kconfig help that COMPAT builds add a compat test (David)
      9e1a3ce0
  8. Feb 15, 2022
  9. Jul 26, 2021
    • David Hildenbrand's avatar
      binfmt: remove support for em86 (alpha only) · 6208721f
      David Hildenbrand authored
      We have a fairly specific alpha binary loader in Linux: running x86
      (i386, i486) binaries via the em86 [1] emulator. As noted in the Kconfig
      option, the same behavior can be achieved via binfmt_misc, for example,
      more nowadays used for running qemu-user.
      
      An example on how to get binfmt_misc running with em86 can be found in
      Documentation/admin-guide/binfmt-misc.rst
      
      The defconfig does not have CONFIG_BINFMT_EM86=y set. And doing a
      	make defconfig && make olddefconfig
      results in
      	# CONFIG_BINFMT_EM86 is not set
      
      ... as we don't seem to have any supported Linux distirbution for alpha
      anymore, there isn't really any "default" user of that feature anymore.
      
      Searching for "CONFIG_BINFMT_EM86=y" reveals mostly discussions from
      around 20 years ago, like [2] describing how to get netscape via em86
      running via em86, or [3] discussing that running wine or installing
      Win 3.11 through em86 would be a nice feature.
      
      The latest binaries available for em86 are from 2000, version 2.2.1 [4] --
      which translates to "unsupported"; further, em86 doesn't even work with
      glibc-2.x but only with glibc-2.0 [4, 5]. These are clear signs that
      there might not be too many em86 users out there, especially users
      relying on modern Linux kernels.
      
      Even though the code footprint is relatively small, let's just get rid
      of this blast from the past that's effectively unused.
      
      [1] http://ftp.dreamtime.org/pub/linux/Linux-Alpha/em86/v0.4/docs/em86.html
      [2] https://static.lwn.net/1998/1119/a/alpha-netscape.html
      [3] https://groups.google.com/g/linux.debian.alpha/c/AkGuQHeCe0Y
      [4] http://zeniv.linux.org.uk/pub/linux/alpha/em86/v2.2-1/relnotes.2.2.1.html
      [5] https://forum.teamspeak.com/archive/index.php/t-1477.html
      
      
      
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: linux-fsdevel@vger.kernel.org
      Cc: linux-api@vger.kernel.org
      Cc: linux-alpha@vger.kernel.org
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Signed-off-by: default avatarMatt Turner <mattst88@gmail.com>
      6208721f
  10. Apr 18, 2021
    • Damien Le Moal's avatar
      binfmt_flat: allow not offsetting data start · 04d82a6d
      Damien Le Moal authored
      Commit 2217b982
      
       ("binfmt_flat: revert "binfmt_flat: don't offset
      the data start"") restored offsetting the start of the data section by
      a number of words defined by MAX_SHARED_LIBS. As a result, since
      MAX_SHARED_LIBS is never 0, a gap between the text and data sections
      always exists. For architectures which cannot support a such gap
      between the text and data sections (e.g. riscv nommu), flat binary
      programs cannot be executed.
      
      To allow an architecture to request no data start offset to allow for
      contiguous text and data sections for binaries flagged with
      FLAT_FLAG_RAM, introduce the new config option
      CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET. Using this new option, the
      macro DATA_START_OFFSET_WORDS is conditionally defined in binfmt_flat.c
      to MAX_SHARED_LIBS for architectures tolerating or needing the data
      start offset (CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET disabled case)
      and to 0 when CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET is enabled.
      DATA_START_OFFSET_WORDS is used in load_flat_file() to calculate the
      data section length and start position.
      
      Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
      Signed-off-by: default avatarGreg Ungerer <gerg@linux-m68k.org>
      04d82a6d
  11. Jan 20, 2021
    • Arnd Bergmann's avatar
      c6x: remove architecture · a579fcfa
      Arnd Bergmann authored
      The c6x architecture was added to the kernel in 2011 at a time when
      running Linux on DSPs was widely seen as the logical evolution.
      It appears the trend has gone back to running Linux on Arm based SoCs
      with DSP, using a better supported software ecosystem, and having better
      real-time behavior for the DSP code. An example of this is TI's own
      Keystone2 platform.
      
      The upstream kernel port appears to no longer have any users. Mark
      Salter remained avaialable to review patches, but mentioned that
      he no longer has access to working hardware himself. Without any
      users, it's best to just remove the code completely to reduce the
      work for cross-architecture code changes.
      
      Many thanks to Mark for maintaining the code for the past ten years.
      
      Link: https://lore.kernel.org/lkml/41dc7795afda9f776d8cd0d3075f776cf586e97c.camel@redhat.com/
      
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      a579fcfa
  12. Jan 06, 2021
    • Al Viro's avatar
      Kconfig: regularize selection of CONFIG_BINFMT_ELF · 41026c34
      Al Viro authored
      
      with mips converted to use of fs/config_binfmt_elf.c, there's no
      need to keep selects of that thing all over arch/* - we can simply
      turn into def_bool y if COMPAT && BINFMT_ELF (in fs/Kconfig.binfmt)
      and get rid of all selects.
      
      Several architectures got those selects wrong (e.g. you could
      end up with sparc64 sans BINFMT_ELF, with select violating
      dependencies, etc.)
      
      Randy Dunlap has spotted some of those; IMO this is simpler than
      his fix, but it depends upon the stuff that would need to be
      backported, so we might end up using his variant for -stable.
      
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      41026c34
  13. Jun 13, 2020
    • Masahiro Yamada's avatar
      treewide: replace '---help---' in Kconfig files with 'help' · a7f7f624
      Masahiro Yamada authored
      Since commit 84af7a61
      
       ("checkpatch: kconfig: prefer 'help' over
      '---help---'"), the number of '---help---' has been gradually
      decreasing, but there are still more than 2400 instances.
      
      This commit finishes the conversion. While I touched the lines,
      I also fixed the indentation.
      
      There are a variety of indentation styles found.
      
        a) 4 spaces + '---help---'
        b) 7 spaces + '---help---'
        c) 8 spaces + '---help---'
        d) 1 space + 1 tab + '---help---'
        e) 1 tab + '---help---'    (correct indentation)
        f) 1 tab + 1 space + '---help---'
        g) 1 tab + 2 spaces + '---help---'
      
      In order to convert all of them to 1 tab + 'help', I ran the
      following commend:
      
        $ find . -name 'Kconfig*' | xargs sed -i 's/^[[:space:]]*---help---/\thelp/'
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      a7f7f624
  14. Jun 01, 2020
  15. Apr 20, 2020
  16. Mar 16, 2020
  17. Jun 23, 2019
  18. May 21, 2019
  19. Aug 01, 2018
  20. Jun 15, 2018
  21. Mar 26, 2018
  22. Sep 10, 2017
  23. Oct 24, 2016
  24. Aug 12, 2016
  25. Jul 27, 2016
  26. May 23, 2016
    • Ralf Baechle's avatar
      ELF/MIPS build fix · f43edca7
      Ralf Baechle authored
      CONFIG_MIPS32_N32=y but CONFIG_BINFMT_ELF disabled results in the
      following linker errors:
      
        arch/mips/built-in.o: In function `elf_core_dump':
        binfmt_elfn32.c:(.text+0x23dbc): undefined reference to `elf_core_extra_phdrs'
        binfmt_elfn32.c:(.text+0x246e4): undefined reference to `elf_core_extra_data_size'
        binfmt_elfn32.c:(.text+0x248d0): undefined reference to `elf_core_write_extra_phdrs'
        binfmt_elfn32.c:(.text+0x24ac4): undefined reference to `elf_core_write_extra_data'
      
      CONFIG_MIPS32_O32=y but CONFIG_BINFMT_ELF disabled results in the following
      linker errors:
      
        arch/mips/built-in.o: In function `elf_core_dump':
        binfmt_elfo32.c:(.text+0x28a04): undefined reference to `elf_core_extra_phdrs'
        binfmt_elfo32.c:(.text+0x29330): undefined reference to `elf_core_extra_data_size'
        binfmt_elfo32.c:(.text+0x2951c): undefined reference to `elf_core_write_extra_phdrs'
        binfmt_elfo32.c:(.text+0x29710): undefined reference to `elf_core_write_extra_data'
      
      This is because binfmt_elfn32 and binfmt_elfo32 are using symbols from
      elfcore but for these configurations elfcore will not be built.
      
      Fixed by making elfcore selectable by a separate config symbol which
      unlike the current mechanism can also be used from other directories
      than kernel/, then having each flavor of ELF that relies on elfcore.o,
      select it in Kconfig, including CONFIG_MIPS32_N32 and CONFIG_MIPS32_O32
      which fixes this issue.
      
      Link: http://lkml.kernel.org/r/20160520141705.GA1913@linux-mips.org
      
      
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      Reviewed-by: default avatarJames Hogan <james.hogan@imgtec.com>
      Cc: "Maciej W. Rozycki" <macro@linux-mips.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f43edca7
  27. Apr 14, 2015
    • Kees Cook's avatar
      mm: split ET_DYN ASLR from mmap ASLR · d1fd836d
      Kees Cook authored
      This fixes the "offset2lib" weakness in ASLR for arm, arm64, mips,
      powerpc, and x86.  The problem is that if there is a leak of ASLR from
      the executable (ET_DYN), it means a leak of shared library offset as
      well (mmap), and vice versa.  Further details and a PoC of this attack
      is available here:
      
        http://cybersecurity.upv.es/attacks/offset2lib/offset2lib.html
      
      
      
      With this patch, a PIE linked executable (ET_DYN) has its own ASLR
      region:
      
        $ ./show_mmaps_pie
        54859ccd6000-54859ccd7000 r-xp  ...  /tmp/show_mmaps_pie
        54859ced6000-54859ced7000 r--p  ...  /tmp/show_mmaps_pie
        54859ced7000-54859ced8000 rw-p  ...  /tmp/show_mmaps_pie
        7f75be764000-7f75be91f000 r-xp  ...  /lib/x86_64-linux-gnu/libc.so.6
        7f75be91f000-7f75beb1f000 ---p  ...  /lib/x86_64-linux-gnu/libc.so.6
        7f75beb1f000-7f75beb23000 r--p  ...  /lib/x86_64-linux-gnu/libc.so.6
        7f75beb23000-7f75beb25000 rw-p  ...  /lib/x86_64-linux-gnu/libc.so.6
        7f75beb25000-7f75beb2a000 rw-p  ...
        7f75beb2a000-7f75beb4d000 r-xp  ...  /lib64/ld-linux-x86-64.so.2
        7f75bed45000-7f75bed46000 rw-p  ...
        7f75bed46000-7f75bed47000 r-xp  ...
        7f75bed47000-7f75bed4c000 rw-p  ...
        7f75bed4c000-7f75bed4d000 r--p  ...  /lib64/ld-linux-x86-64.so.2
        7f75bed4d000-7f75bed4e000 rw-p  ...  /lib64/ld-linux-x86-64.so.2
        7f75bed4e000-7f75bed4f000 rw-p  ...
        7fffb3741000-7fffb3762000 rw-p  ...  [stack]
        7fffb377b000-7fffb377d000 r--p  ...  [vvar]
        7fffb377d000-7fffb377f000 r-xp  ...  [vdso]
      
      The change is to add a call the newly created arch_mmap_rnd() into the
      ELF loader for handling ET_DYN ASLR in a separate region from mmap ASLR,
      as was already done on s390.  Removes CONFIG_BINFMT_ELF_RANDOMIZE_PIE,
      which is no longer needed.
      
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Reported-by: default avatarHector Marco-Gisbert <hecmargi@upv.es>
      Cc: Russell King <linux@arm.linux.org.uk>
      Reviewed-by: default avatarIngo Molnar <mingo@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: "David A. Long" <dave.long@linaro.org>
      Cc: Andrey Ryabinin <a.ryabinin@samsung.com>
      Cc: Arun Chandran <achandran@mvista.com>
      Cc: Yann Droneaud <ydroneaud@opteya.com>
      Cc: Min-Hua Chen <orca.chen@gmail.com>
      Cc: Paul Burton <paul.burton@imgtec.com>
      Cc: Alex Smith <alex@alex-smith.me.uk>
      Cc: Markos Chandras <markos.chandras@imgtec.com>
      Cc: Vineeth Vijayan <vvijayan@mvista.com>
      Cc: Jeff Bailey <jeffbailey@google.com>
      Cc: Michael Holzheu <holzheu@linux.vnet.ibm.com>
      Cc: Ben Hutchings <ben@decadent.org.uk>
      Cc: Behan Webster <behanw@converseincode.com>
      Cc: Ismael Ripoll <iripoll@upv.es>
      Cc: Jan-Simon Mller <dl9pf@gmx.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d1fd836d
  28. Feb 17, 2015
  29. Nov 24, 2014
    • Paul Burton's avatar
      binfmt_elf: allow arch code to examine PT_LOPROC ... PT_HIPROC headers · 774c105e
      Paul Burton authored
      
      MIPS is introducing new variants of its O32 ABI which differ in their
      handling of floating point, in order to enable a gradual transition
      towards a world where mips32 binaries can take advantage of new hardware
      features only available when configured for certain FP modes. In order
      to do this ELF binaries are being augmented with a new section that
      indicates, amongst other things, the FP mode requirements of the binary.
      The presence & location of such a section is indicated by a program
      header in the PT_LOPROC ... PT_HIPROC range.
      
      In order to allow the MIPS architecture code to examine the program
      header & section in question, pass all program headers in this range
      to an architecture-specific arch_elf_pt_proc function. This function
      may return an error if the header is deemed invalid or unsuitable for
      the system, in which case that error will be returned from
      load_elf_binary and upwards through the execve syscall.
      
      A means is required for the architecture code to make a decision once
      it is known that all such headers have been seen, but before it is too
      late to return from an execve syscall. For this purpose the
      arch_check_elf function is added, and called once, after all PT_LOPROC
      to PT_HIPROC headers have been passed to arch_elf_pt_proc but before
      the code which invoked execve has been lost. This enables the
      architecture code to make a decision based upon all the headers present
      in an ELF binary and its interpreter, as is required to forbid
      conflicting FP ABI requirements between an ELF & its interpreter.
      
      In order to allow data to be stored throughout the calls to the above
      functions, struct arch_elf_state is introduced.
      
      Finally a variant of the SET_PERSONALITY macro is introduced which
      accepts a pointer to the struct arch_elf_state, allowing it to act
      based upon state observed from the architecture specific program
      headers.
      
      Signed-off-by: default avatarPaul Burton <paul.burton@imgtec.com>
      Cc: linux-mips@linux-mips.org
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: linux-fsdevel@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Patchwork: https://patchwork.linux-mips.org/patch/7679/
      
      
      Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
      774c105e
  30. Apr 30, 2013
  31. Oct 05, 2012
  32. May 15, 2012
    • Mark Salter's avatar
      C6X: add support to build with BINFMT_ELF_FDPIC · fce24476
      Mark Salter authored
      
      C6x userspace supports a shared library mechanism called DSBT for systems with
      no MMU. DSBT is similar to FDPIC in allowing shared text segments and private
      copies of data segments without an MMU. Both methods access data using a base
      register and offset. With FDPIC, the caller of an external function sets up the
      base register for the callee. With DSBT, the called function sets up its own
      base register. Other details differ but both userspaces need the same thing
      from the kernel loader: a map of where each ELF segment was loaded. The FDPIC
      loader already provides this, so DSBT just uses it.
      
      This patch enables BINFMT_ELF_FDPIC by default for C6X and provides the
      necessary architecture hooks for the generic loader.
      
      Signed-off-by: default avatarMark Salter <msalter@redhat.com>
      fce24476
  33. Jan 10, 2012
  34. Oct 27, 2010
  35. Jan 09, 2009