Skip to content

Commit

Permalink
elf: Fix the arm64 MTE ELF segment name and value
Browse files Browse the repository at this point in the history
Unfortunately, the name/value choice for the MTE ELF segment type
(PT_ARM_MEMTAG_MTE) was pretty poor: LOPROC+1 is already in use by
PT_AARCH64_UNWIND, as defined in the AArch64 ELF ABI
(https://github.com/ARM-software/abi-aa/blob/main/aaelf64/aaelf64.rst).

Update the ELF segment type value to LOPROC+2 and also change the define
to PT_AARCH64_MEMTAG_MTE to match the AArch64 ELF ABI namespace. The
AArch64 ELF ABI document is updating accordingly (segment type not
previously mentioned in the document).

Signed-off-by: Catalin Marinas <[email protected]>
Fixes: 761b9b3 ("elf: Introduce the ARM MTE ELF segment type")
Cc: Will Deacon <[email protected]>
Cc: Jonathan Corbet <[email protected]>
Cc: Eric Biederman <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Luis Machado <[email protected]>
Cc: Richard Earnshaw <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Will Deacon <[email protected]>
  • Loading branch information
ctmarinas authored and willdeacon committed Apr 28, 2022
1 parent 23bc8f6 commit c35fe2a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Documentation/arm64/memory-tagging-extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ Core dump support
-----------------

The allocation tags for user memory mapped with ``PROT_MTE`` are dumped
in the core file as additional ``PT_ARM_MEMTAG_MTE`` segments. The
in the core file as additional ``PT_AARCH64_MEMTAG_MTE`` segments. The
program header for such segment is defined as:

:``p_type``: ``PT_ARM_MEMTAG_MTE``
:``p_type``: ``PT_AARCH64_MEMTAG_MTE``
:``p_flags``: 0
:``p_offset``: segment file offset
:``p_vaddr``: segment virtual address, same as the corresponding
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/kernel/elfcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int elf_core_write_extra_phdrs(struct coredump_params *cprm, loff_t offset)
for_each_mte_vma(current, vma) {
struct elf_phdr phdr;

phdr.p_type = PT_ARM_MEMTAG_MTE;
phdr.p_type = PT_AARCH64_MEMTAG_MTE;
phdr.p_offset = offset;
phdr.p_vaddr = vma->vm_start;
phdr.p_paddr = 0;
Expand Down
2 changes: 1 addition & 1 deletion include/uapi/linux/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ typedef __s64 Elf64_Sxword;


/* ARM MTE memory tag segment type */
#define PT_ARM_MEMTAG_MTE (PT_LOPROC + 0x1)
#define PT_AARCH64_MEMTAG_MTE (PT_LOPROC + 0x2)

/*
* Extended Numbering
Expand Down

0 comments on commit c35fe2a

Please sign in to comment.