Received: by 2002:a05:6a10:5594:0:0:0:0 with SMTP id ee20csp518473pxb; Mon, 25 Apr 2022 15:24:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvPS8KdrNm4O8qVz5ynb70eBHLZLrg2Q2ztKrqSOo743TeoJNi32vpdQDpojMEsSrAlhRY X-Received: by 2002:a17:903:246:b0:153:84fe:a9b0 with SMTP id j6-20020a170903024600b0015384fea9b0mr20250509plh.163.1650925470114; Mon, 25 Apr 2022 15:24:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650925470; cv=none; d=google.com; s=arc-20160816; b=iiySz1ulxUflwWtaotBDsZJkxXC7+i1zSb5LL2TKBugXOXjSofa/hK06l+auDBK/Va zhxUbEUC2H3dw06FszrDbTZiJ+ORG050WeZwo6wiT2MTiqbeMaysflkWwhDOjOMYElFj 2fhHgH4aPEhgFjC39/65N51LqkyBlJ9oexLIQkDqTRCyCLOXToGszMv5qv6fWiaXkWln RnDZi+Whn9N4Q7f+LTt46uuKKbekdh9NwObB+byjkMiGTyBDvejBOI52zM4n0y16bhhl iF9mO0X9JrYq2tH6GKMOuCcnHbQH2zT4NuC+NEMxxd40B4frrdh8zhmhEUtNDaSazU2q MWdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=cJH8j8c/wGufeLh67k0Kaz4h9Mqwhi37wxFrw2YjrQ8=; b=bLKlpD9iEbzjgZfRGjaRhW5KtgoV4cfuW4/j/kPt06peF43XNzNO8NFyI6+FvLM1H3 JZzIVdsJ8qLepUSmaKvVocD8vbJ2D9I67e+NT+sYim1GTdoGaq0CnjtnlfNUR2KbisMK kTEoY+kpmwsQLEF3G87oz+EhsZ21LBRth8AL3N8UxHq3ESt2+6eaEKvxZZbfnBISpvrd jaIWvK0nGPDP/Ir8WdQuoYQi4YxvxS0xl21gRunwbR/WwC5IKsdbyJbSh+h/G5v/nl0c 3PGg4i3NQld0V4bmkF6DuWe+6jzCXx+cVCzCL5rwDy7rJ3fv5fBImxxmksGd63tIbx84 83Xw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i23-20020a63e917000000b00381facb2ec6si18275092pgh.728.2022.04.25.15.24.14; Mon, 25 Apr 2022 15:24:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234351AbiDYPVr (ORCPT + 99 others); Mon, 25 Apr 2022 11:21:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230471AbiDYPVq (ORCPT ); Mon, 25 Apr 2022 11:21:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC3D6B6E4B for ; Mon, 25 Apr 2022 08:18:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5225B60E06 for ; Mon, 25 Apr 2022 15:18:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B7E6C385A7; Mon, 25 Apr 2022 15:18:35 +0000 (UTC) From: Catalin Marinas To: Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jonathan Corbet , Eric Biederman , Kees Cook , Luis Machado , Richard Earnshaw Subject: [PATCH] elf: Fix the arm64 MTE ELF segment name and value Date: Mon, 25 Apr 2022 16:18:33 +0100 Message-Id: <20220425151833.2603830-1-catalin.marinas@arm.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Fixes: 761b9b366cec ("elf: Introduce the ARM MTE ELF segment type") Cc: Will Deacon Cc: Jonathan Corbet Cc: Eric Biederman Cc: Kees Cook Cc: Luis Machado Cc: Richard Earnshaw --- Luckily, the commit being fixed here only went in for 5.18-rc1, so there is no ABI change in a mainline release. FYI, the corresponding pull request for the AArch64 ELF ABI: https://github.com/ARM-software/abi-aa/pull/148 I don't expect any further change to the segment name/value. Documentation/arm64/memory-tagging-extension.rst | 4 ++-- arch/arm64/kernel/elfcore.c | 2 +- include/uapi/linux/elf.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/arm64/memory-tagging-extension.rst b/Documentation/arm64/memory-tagging-extension.rst index dd27f78d7608..dbae47bba25e 100644 --- a/Documentation/arm64/memory-tagging-extension.rst +++ b/Documentation/arm64/memory-tagging-extension.rst @@ -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 diff --git a/arch/arm64/kernel/elfcore.c b/arch/arm64/kernel/elfcore.c index 2b3f3d0544b9..98d67444a5b6 100644 --- a/arch/arm64/kernel/elfcore.c +++ b/arch/arm64/kernel/elfcore.c @@ -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; diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h index 787c657bfae8..7ce993e6786c 100644 --- a/include/uapi/linux/elf.h +++ b/include/uapi/linux/elf.h @@ -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