From patchwork Wed May 26 17:49:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12282585 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.1 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, 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 1E6E5C47088 for ; Wed, 26 May 2021 18:54:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 D3853613BC for ; Wed, 26 May 2021 18:54:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3853613BC 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=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc: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=4SA7OAdjesrA2vXWTsEtMalnCUXHTK809r/jkOni2oM=; b=iaNuXPnPrZ+h76MZiGcpEv/uro 3zuR5tQg8pj69XGhBOxgo+GtJYMtJ4/GAk5HW7/F77ZGHITXT63feUPO/Jexo45qKUh5YR7SEBvmw VCq+su81jEyUYc1U5tuavRkCaK6wrIHB66SSxLnZ6U8AQVWu4+QrQXBrWG8w5obGV4fPUFhTdVnBr USyKYkEvDxpxBQzYtsukEJSGToVt3aMBhb80ntfpXS1HtgfxTR5OjxJDFezqOd84ESKk1gLxq3bFR ElVR8YLs6tWAC55h5zjQcAx63g9UrSYMGvwKksqtYSjsseCdywo0VyPpkyhiDeQ85TLC2n8qXfFJA SDFvf92A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1llycE-00Ghrx-P1; Wed, 26 May 2021 18:50:53 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1llxf8-00GFv4-05 for linux-arm-kernel@lists.infradead.org; Wed, 26 May 2021 17:49:48 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id j7-20020a258b870000b029052360b1e3e2so2550766ybl.8 for ; Wed, 26 May 2021 10:49:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=GqmVVXezyMmHPgCnOKEarqOWfLrnu9GStscZ2c33AM4=; b=h8YeQi0+TXAtIgFS5KMdfkHQZ+8vBKkQDrmUewNfsQjC+qSZPKRYehwyWtHl2cF99e ocYtFUX7yph7M/KafScINOFQpepuWFH/0h/AOh82Y35O76V0EuFt8NEhzsbvJLsFk8Rw CebLxWzfEp8fA3n1lzIFqtXkL75JtDITFbKDgOjBVuY420bv9welt5XaZ31io7yjxDIA Igp/3N8u4LUYjOoZaWC2MnoAr9o27PhOl/gc3uq5UblmFWpgtujPx1ORdQNKagp7qph2 U076BIDHjs2SdcaBVBimuUWDdHBkQtepWns2u3zSkZBoR3wU6XJ1kiGKeCPeN0inxkUV 6nLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=GqmVVXezyMmHPgCnOKEarqOWfLrnu9GStscZ2c33AM4=; b=WpWsCZTxM5bwVMK0bQduHeVMkGdRQBlt8O937acbrtNeQpeli6jGQLexhs/+gnqEKc H6qW98VZUBQ70ML0G1Ke763R9mSc7MGAva2Pugb4i5BNgwyOSBGYJv9ITv9sJ/Y+b+Vn aaH1dDrzxMSIYEXvQ56qE2xM2/1HkYSQn4LDwhTtWWIkGPH+imFvT9SCCx0RYYRT8CJM vBcQGTtancMYqbOCBqtYWW+bZ3SXIXypS7uEar0hugrt57UUDJfV2XIjXE1+rgRmx8P/ rP7OvDQZYCf8OH4tgQn6163qdQIgONbdRae0EFN4JNMDyRE9XeulnAaN6rzBbQXdhNuO EqmQ== X-Gm-Message-State: AOAM533NIPBi49vQiKeMLim/nmyE4QkHWI0tny+ZHJP3mZJaGvU8ZAz0 bRGxm0Gi1iKlFohCOSUoMc/xvq8= X-Google-Smtp-Source: ABdhPJxef3Weo5XHTOZpuQzcBc1xK121ALoMxcYWcL0ObL3u+Fzve7HB8wYJteHXd8HOnW+1nww/cbg= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:a9df:d12:c875:45b7]) (user=pcc job=sendgmr) by 2002:a25:11c6:: with SMTP id 189mr52382886ybr.154.1622051383686; Wed, 26 May 2021 10:49:43 -0700 (PDT) Date: Wed, 26 May 2021 10:49:26 -0700 In-Reply-To: <20210526174927.2477847-1-pcc@google.com> Message-Id: <20210526174927.2477847-2-pcc@google.com> Mime-Version: 1.0 References: <20210526174927.2477847-1-pcc@google.com> X-Mailer: git-send-email 2.31.1.818.g46aad6cb9e-goog Subject: [PATCH v6 2/3] arm64: stacktrace: Relax frame record alignment requirement to 8 bytes From: Peter Collingbourne To: Mark Brown , Mark Rutland , Will Deacon , Catalin Marinas , Andrey Konovalov , Evgenii Stepanov , Ard Biesheuvel Cc: Peter Collingbourne , Linux ARM X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210526_104946_108337_E45E3E9D X-CRM114-Status: GOOD ( 16.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The AAPCS places no requirements on the alignment of the frame record. In theory it could be placed anywhere, although it seems sensible to require it to be aligned to 8 bytes. With an upcoming enhancement to tag-based KASAN Clang will begin creating frame records located at an address that is only aligned to 8 bytes. Accommodate such frame records in the stack unwinding code. As pointed out by Mark Rutland, the userspace stack unwinding code has the same problem, so fix it there as well. Signed-off-by: Peter Collingbourne Link: https://linux-review.googlesource.com/id/Ia22c375230e67ca055e9e4bb639383567f7ad268 Acked-by: Andrey Konovalov Reviewed-by: Mark Rutland Tested-by: Mark Rutland --- v6: - rebase onto for-next/stacktrace v5: - fix rebase v4: - rebase to 5.13rc1 v2: - fix it in the userspace unwinding code as well arch/arm64/kernel/perf_callchain.c | 2 +- arch/arm64/kernel/stacktrace.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/perf_callchain.c b/arch/arm64/kernel/perf_callchain.c index 88ff471b0bce..4a72c2727309 100644 --- a/arch/arm64/kernel/perf_callchain.c +++ b/arch/arm64/kernel/perf_callchain.c @@ -116,7 +116,7 @@ void perf_callchain_user(struct perf_callchain_entry_ctx *entry, tail = (struct frame_tail __user *)regs->regs[29]; while (entry->nr < entry->max_stack && - tail && !((unsigned long)tail & 0xf)) + tail && !((unsigned long)tail & 0x7)) tail = user_backtrace(tail, entry); } else { #ifdef CONFIG_COMPAT diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index 5c70f247645b..b189de5ca6cb 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -75,7 +75,7 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame) if (fp == (unsigned long)task_pt_regs(tsk)->stackframe) return -ENOENT; - if (fp & 0xf) + if (fp & 0x7) return -EINVAL; if (!on_accessible_stack(tsk, fp, 16, &info))