[v11,0/2] arm64: Enable BTI for the executable as well as the interpreter

Message ID 20220308132240.1697784-1-broonie@kernel.org
Series arm64: Enable BTI for the executable as well as the interpreter |


Mark Brown March 8, 2022, 1:22 p.m. UTC
  Deployments of BTI on arm64 have run into issues interacting with
systemd's MemoryDenyWriteExecute feature.  Currently for dynamically
linked executables the kernel will only handle architecture specific
properties like BTI for the interpreter, the expectation is that the
interpreter will then handle any properties on the main executable.
For BTI this means remapping the executable segments PROT_EXEC |

This interacts poorly with MemoryDenyWriteExecute since that is
implemented using a seccomp filter which prevents setting PROT_EXEC on
already mapped memory and lacks the context to be able to detect that
memory is already mapped with PROT_EXEC.  This series resolves this by
providing a sysctl which when enabled will cause the kernel to handle
the BTI property for both the interpreter and the main executable.

 - Ignore extra PT_INTERPs.
 - Add a sysctl abi.bti_main controlling the new behaviour.
 - Rebase onto v5.17-rc3.
 - Rebase onto v5.17-rc1.
 - Rebase onto v5.16-rc1.
 - Rebase onto v5.15-rc1.
 - Rebase onto v5.14-rc2.
 - Tweak changelog on patch 1.
 - Use the helper for interpreter/executable flag in elf.h as well.
 - Rebase onto v5.14-rc1.
 - Fix passing of properties for parsing by the main executable.
 - Drop has_interp from arch_parse_elf_property().
 - Coding style tweaks.
 - Add a patch dropping has_interp from arch_adjust_elf_prot()
 - Fix bisection issue with static executables on arm64 in the first

Mark Brown (2):
  elf: Allow architectures to parse properties on the main executable
  arm64: Enable BTI for main executable as well as the interpreter

 arch/arm64/include/asm/elf.h | 14 ++++++++--
 arch/arm64/kernel/process.c  | 52 +++++++++++++++++++++++++++---------
 fs/binfmt_elf.c              | 34 ++++++++++++++++-------
 include/linux/elf.h          |  4 ++-
 4 files changed, 78 insertions(+), 26 deletions(-)

base-commit: dfd42facf1e4ada021b939b4e19c935dcdd55566