From patchwork Sat Oct 17 00:12:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 11842475 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CB0CC2D0A3 for ; Sat, 17 Oct 2020 00:15:00 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EB22D22203 for ; Sat, 17 Oct 2020 00:14:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="J9ETU+OY"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="WuhlseqJ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB22D22203 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:Mime-Version:Message-Id:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=BJT8VDUV2l5P7ZMZl32joZj+XMTXtGO9oFvr4lSsxoU=; b=J9ETU+OYR9wcukSnlJ7vQTILYc HcYqFLAR0NyLzXlN88AANlqUqno5ROlRZXwwGpwiay/IyhYwPLdiJ02qwrwpkKRuXxgR+3AwGjo9l 68bvpcu2JKA05MNE4L2YP+MkRJyYt23J8nGL/rB8oc2nQVmIFzM773bdUwgMBOWL+B42oI8LnjM0C rxSkYwA6p5vyq0jJepViy9Bg5CnFz2hGM6McNmFlU1mL7Gc14lR+WKpTgY29q79ZL40Dbf0jIcnL9 H+Khoyy5ewRXGv+8ESPtbjkvVmBd1soLRhkQbwx8WKBk5TKEz9aamH6Q3T/w/sn30KbcKSYCHgV8D JfHpCj2w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kTZq6-0001wK-8M; Sat, 17 Oct 2020 00:12:50 +0000 Received: from mail-qv1-xf49.google.com ([2607:f8b0:4864:20::f49]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kTZq3-0001ve-0R for linux-arm-kernel@lists.infradead.org; Sat, 17 Oct 2020 00:12:48 +0000 Received: by mail-qv1-xf49.google.com with SMTP id l8so2517468qvz.2 for ; Fri, 16 Oct 2020 17:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=0SzVqODEfPVXxLTAWYh1OlMRZX67EtQRCd+LR3qS49c=; b=WuhlseqJkkPmSyZw616Hrf+g3JLaplGgcP+WbLNqPy6pbqoUqVy2fZfRmPjkKnlNEF a5QjECu3iU010I4z4m5sv9yOYLjtgYQMD/ntbgYb0y7oaqRCzmy2Jhr0dSTYhJP9QDev EABizo8Mme8p3TdOVqWL5im2eC+Shw6NDyno9Z+iAkK0YzHTLLQ20+l7sz/2txyxDbtN kv8S9RWCC9Rte4uKn/cBRjsG1J8fN5X/JRpTFdBNv79AQ/ntKnI9Gz3mlw1vqxnB9Ixz WWMeIe5grQwW+JAz61iF76EpV/juD7Z3uLyAlFgBDg4FPo6mb2jDawciNLJtNzKVYiE1 UbDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=0SzVqODEfPVXxLTAWYh1OlMRZX67EtQRCd+LR3qS49c=; b=bhhBGvP67H+aWavMUIuTy8V9wDmrHYhAfexVHvPb9WUjhVsrohKS5FoLI1+n6mlIHU rtvLxAMGoiuv74hTkc6uhUSob9y23YyoXeTEM9d6BYeQ4inc3En/uNCWSqyH1e9rFJ8G LFErKPEOf+VK0RteNA3x3YLx+H0BEOV2UP7W8xKJbTT5wyPykaE0YmifnpJyjXval6VA nBG3ZhdRtX/9b7QY9UIJhFQKB7/dvXahUAFhSHoHYriElmHdD8Et9p9LJh5drV//JTJ+ rlDhWLDLp1TWuTljJ/R/psYsshEVO+fp4byOexzU6AJRnZx8WwcWe6MwtTqHdwBQXtff eADQ== X-Gm-Message-State: AOAM533br4PC08fVQJvU8Hzy7l++0kIZeNj+Iba49eJiRwkIbsuck6Ae ITcgMW2UHdf4vG+cwJyGVdtiL8U= X-Google-Smtp-Source: ABdhPJwrcG+HjhDPcsvVqMBOCzJnFkmyrsDDTznxLj+oymEZ6nBA7SBVRkAeE4Jure8saQqIjl/72hc= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:0:7220:84ff:fe09:385a]) (user=pcc job=sendgmr) by 2002:a05:6214:943:: with SMTP id dn3mr6291415qvb.45.1602893563003; Fri, 16 Oct 2020 17:12:43 -0700 (PDT) Date: Fri, 16 Oct 2020 17:12:25 -0700 Message-Id: Mime-Version: 1.0 X-Mailer: git-send-email 2.29.0.rc1.297.gfa9743e501-goog Subject: [PATCH v12 0/8] arm64: expose FAR_EL1 tag bits in siginfo From: Peter Collingbourne To: Catalin Marinas , Evgenii Stepanov , Kostya Serebryany , Vincenzo Frascino , Dave Martin , Will Deacon , Oleg Nesterov , "Eric W. Biederman" , "James E.J. Bottomley" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201016_201247_074548_2D234EAC X-CRM114-Status: GOOD ( 15.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrey Konovalov , Helge Deller , Kevin Brodsky , linux-api@vger.kernel.org, David Spickett , Peter Collingbourne , Linux ARM , Richard Henderson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The kernel currently clears the tag bits (i.e. bits 56-63) in the fault address exposed via siginfo.si_addr and sigcontext.fault_address. However, the tag bits may be needed by tools in order to accurately diagnose memory errors, such as HWASan [1] or future tools based on the Memory Tagging Extension (MTE). We should not stop clearing these bits in the existing fault address fields, because there may be existing userspace applications that are expecting the tag bits to be cleared. Instead, create a new pair of union fields in siginfo._sigfault, and store the tag bits of FAR_EL1 there, together with a mask specifying which bits are valid. However, one does not simply add fields to siginfo, at least not without a mechanism for userspace to detect that they are present and valid. Therefore, the first seven patches in this series introduce a mechanism for userspace to detect the presence of our new siginfo fields, and the last patch uses it to advertise the presence of said fields. The series can be viewed on Gerrit here: https://linux-review.googlesource.com/q/Ia8876bad8c798e0a32df7c2ce1256c4771c81446 [1] http://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html Helge Deller (1): parisc: Drop parisc special case for __sighandler_t Peter Collingbourne (7): parisc: start using signal-defs.h arch: move SA_* definitions to generic headers signal: clear non-uapi flag bits when passing/returning sa_flags signal: define the SA_UNSUPPORTED bit in sa_flags signal: deduplicate code dealing with common _sigfault fields signal: define the field siginfo.si_xflags arm64: expose FAR_EL1 tag bits in siginfo Documentation/arm64/tagged-pointers.rst | 21 +++- arch/alpha/include/uapi/asm/signal.h | 14 --- arch/arm/include/asm/signal.h | 2 + arch/arm/include/uapi/asm/signal.h | 28 +---- arch/arm64/include/asm/exception.h | 2 +- arch/arm64/include/asm/signal.h | 19 +++ arch/arm64/include/asm/system_misc.h | 2 +- arch/arm64/include/asm/traps.h | 6 +- arch/arm64/kernel/debug-monitors.c | 5 +- arch/arm64/kernel/entry-common.c | 2 - arch/arm64/kernel/ptrace.c | 7 +- arch/arm64/kernel/sys_compat.c | 5 +- arch/arm64/kernel/traps.c | 29 ++--- arch/arm64/mm/fault.c | 68 ++++++----- arch/h8300/include/uapi/asm/signal.h | 24 ---- arch/ia64/include/uapi/asm/signal.h | 24 ---- arch/m68k/include/uapi/asm/signal.h | 24 ---- arch/mips/include/uapi/asm/signal.h | 12 -- arch/parisc/include/asm/signal.h | 2 + arch/parisc/include/uapi/asm/signal.h | 34 +----- arch/powerpc/include/uapi/asm/signal.h | 24 ---- arch/powerpc/platforms/powernv/vas-fault.c | 1 + arch/s390/include/uapi/asm/signal.h | 24 ---- arch/sparc/include/uapi/asm/signal.h | 4 +- arch/x86/include/uapi/asm/signal.h | 24 ---- arch/x86/kernel/signal_compat.c | 19 +-- arch/xtensa/include/uapi/asm/signal.h | 24 ---- include/linux/compat.h | 4 + include/linux/signal.h | 29 +++++ include/linux/signal_types.h | 12 ++ include/uapi/asm-generic/siginfo.h | 14 +++ include/uapi/asm-generic/signal-defs.h | 58 +++++++++ include/uapi/asm-generic/signal.h | 29 ----- include/uapi/linux/ptrace.h | 12 ++ kernel/ptrace.c | 32 ++++- kernel/signal.c | 134 +++++++++++---------- 36 files changed, 345 insertions(+), 429 deletions(-) create mode 100644 arch/arm64/include/asm/signal.h