From patchwork Fri Jan 15 17:41:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12023473 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=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 66943C433E6 for ; Fri, 15 Jan 2021 17:43:26 +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 1FE5323A59 for ; Fri, 15 Jan 2021 17:43:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1FE5323A59 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:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Kx1ivjhTSuLNqeb0SJ3VXeJt0CPh9ve1kRsNLUJPnyU=; b=1wSN/cys/uFGKhS6/8XACkqjh 2aEjIF40GMKJ2ptOTtO8WfwKnqUTMLdc6y/srN/NrmbTu9UKDAttRz4hVOV1DDG0ZOJyEnAMH6MBe 4szqQQoxe1yjH3/Kl76dqu1/EmszhI3YBdXmCb1RuQonbu0AA0jfl7HlWiL4hZ+mQ2NKbbHxpKltg Z5TR3xPo/Wl55+4Eoj6cdWdnv0P/VcDnFtPuESRrGU9tey29pt2NdhyhUIw47UqDO1Rk0COR6rhKd vC1i8Eb4DcdjD0yD5akN1B+RcLDTmvA8BCNiCH2JJZo2H6J4mseZC2zWUhV3OISfBlC84W8bQ80CH 6nwo9WoTg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0T70-00024j-Gg; Fri, 15 Jan 2021 17:42:14 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0T6s-00022H-Bk for linux-arm-kernel@lists.infradead.org; Fri, 15 Jan 2021 17:42:08 +0000 Received: by mail-wr1-x449.google.com with SMTP id v5so4463672wrr.0 for ; Fri, 15 Jan 2021 09:42:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=2Jh+PMvtwPBdOf35KI8y5U59fASZU17QcTjkcKex3tI=; b=Hd2IN4XMaOhARll1q80OAre7pjVfYDxXAVwkYziln0JBQl6QbZlfrmyN+WlNgylyWU pIaRrBzcotlT2eZMrDvmrnwfyeoANkWceg612cwXsWqYdVaiErMhEKNDdohjPzMPYd/H 55ovgJKab/CQUxTOgOefpS+wa9DeexWd/gKfu1rB2+Upw5JdPIdRXP1uyvJUjtq21IxU tseFZahjTU9om4RhlW5xYn0HIsNnWgBJ04W6+DTt0sdqmXFQvWtH1AiiUPDkQ2hkPbF5 T+aqk8C3k5N9mZhTqK2lNPrt256CFiYczEGa0r+9tU9/1NEzYb8n3fshYQ+XiSG6hS+P BrPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=2Jh+PMvtwPBdOf35KI8y5U59fASZU17QcTjkcKex3tI=; b=sWqq3rr1rs7yraGZvBq4fNzPd8PDJ3LDpRWL+iQcqgwD/ZFLg/Hwgu66EeMgrjeC2i zRNfbsz+5urtGHtibCz2Y1uWi51CqoEzj/qRa87F0Ev88e9P3jOiS67/Uv3mT0M+bda7 585C5LFAaz93/HaLcBW58xORa2FoYiKgKgP4t9nf8ffLCbVRY7DplNjrqkDBlbwPY/UR WQkDTabXpZ6LOy+iRp4OOx4aENoJKWDE4GWLXFl9vFS6GG3uf5C70XZgxLTU+C0Ijjvi MJ8bc+WVoEZIbU5WwswQsTqA1+YdKA0CVVwKEqTY8FgyL3/3e91Y7jUjms8P0foqREFc fevg== X-Gm-Message-State: AOAM531ucbBqckkNAjphQucRDQtCgCfRGWaMJGfQiL8Cv3zS1JEgOomu /Y4gh13WPgl50WsWNyqaKNQi4x85UZohgAow X-Google-Smtp-Source: ABdhPJwtveqVzh/mz1rxuVT8+JjfpWP10vB1hMpqRtgEBmDO+OrhmMhVsyLbeqMFYIRBQSX7tuyjEk70XhttOV8N X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a5d:58d7:: with SMTP id o23mr14634604wrf.288.1610732522952; Fri, 15 Jan 2021 09:42:02 -0800 (PST) Date: Fri, 15 Jan 2021 18:41:53 +0100 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH v3 2/2] kasan, arm64: fix pointer tags in KASAN reports From: Andrey Konovalov To: Andrew Morton , Catalin Marinas , Vincenzo Frascino , Dmitry Vyukov , Alexander Potapenko , Marco Elver X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210115_124206_502536_5067DE8E X-CRM114-Status: GOOD ( 13.19 ) 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: Branislav Rankov , Andrey Konovalov , Kevin Brodsky , Will Deacon , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Andrey Ryabinin , Peter Collingbourne , Evgenii Stepanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org As of the "arm64: expose FAR_EL1 tag bits in siginfo" patch, the address that is passed to report_tag_fault has pointer tags in the format of 0x0X, while KASAN uses 0xFX format (note the difference in the top 4 bits). Fix up the pointer tag for kernel pointers in do_tag_check_fault by setting them to the same value as bit 55. Explicitly use __untagged_addr() instead of untagged_addr(), as the latter doesn't affect TTBR1 addresses. Link: https://linux-review.googlesource.com/id/I9ced973866036d8679e8f4ae325de547eb969649 Fixes: dceec3ff7807 ("arm64: expose FAR_EL1 tag bits in siginfo") Fixes: 4291e9ee6189 ("kasan, arm64: print report from tag fault handler") Signed-off-by: Andrey Konovalov Reviewed-by: Catalin Marinas Reviewed-by: Vincenzo Frascino --- arch/arm64/mm/fault.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 3c40da479899..35d75c60e2b8 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -709,10 +709,11 @@ static int do_tag_check_fault(unsigned long far, unsigned int esr, struct pt_regs *regs) { /* - * The architecture specifies that bits 63:60 of FAR_EL1 are UNKNOWN for tag - * check faults. Mask them out now so that userspace doesn't see them. + * The architecture specifies that bits 63:60 of FAR_EL1 are UNKNOWN + * for tag check faults. Set them to corresponding bits in the untagged + * address. */ - far &= (1UL << 60) - 1; + far = (__untagged_addr(far) & ~MTE_TAG_MASK) | (far & MTE_TAG_MASK); do_bad_area(far, esr, regs); return 0; }