From patchwork Thu May 13 02:27:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 12255109 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.4 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 4AF0FC433ED for ; Thu, 13 May 2021 02:29:40 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 A5B14613FE for ; Thu, 13 May 2021 02:29:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5B14613FE 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=desiato.20200630; 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=rLTRct7jTlGnULvTJ83QwQsVTmcEc4rdvtwEbj73cX4=; b=dRkSHOk7lAmezz unEFp1rD0+kdnmBXJSxtVMCTMC7T3+sjWO4tewUix9SsVtXHPbMMvzXS6/+/bcVph4wtD0ToUfbD6 ctgtFuMX8MofRgDNl/U7RXFpuM+26EuDIyx8NijCLhs6RzMaFCcFKiFl+E63w1wbwEAMBvKrjul79 Nz8wpctJy5X0sDPerZynNfQhQ8G5yYA8eqEHO0uPUAGXzHvpZ6wooJZjFfEUKDS5dHj2BtWP/x5Qn MJkcWMnpgkJ9lpnnBUcNPSDqi7+D/Eh0n1AYxgnHrq/tiFP38B/mIPMSw3dPAh9QMRwpU8cSsVFrn QdzeDdrQMZQMDwLpzJPQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lh14R-004VN6-QH; Thu, 13 May 2021 02:27:28 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lh14L-004VMS-Qb for linux-arm-kernel@desiato.infradead.org; Thu, 13 May 2021 02:27:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Type:Cc:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=HsrRkxbmeW42Q2bERAUqg4965RDz2y3d4rZ4ol559ww=; b=1OjokmcGGf2QVIe8tUOJvX5R8I GFkK/6xfUCo+jeCs0dIiRwVGed/c8ZiKdqRkfw1I5GSbmxWWMa71ppTy1UFJLkbQ+ScfswnW307Lg 3aAf8Ht5rIQahfCFQeaqBzB61hvb9BkKVIERQIC+xwIH6tA6MTgpvUCJ/JIQ0Z0plAkwKj0jAXdYs S4CAPPDP0jr301q0LoC6Y3x0LyDCGkDAnZ5fgfQpVrKorSTyjuRy6KXaciQNRNGsJAV0AAzKg5/Kl 6KqEOrszAwbWmHns3XV6I/ukwGptpujb8XcIvrybIyj0v2ar2kgpFogKxI1qOrAD7OMc+Vn1+xO47 rIvO6SCQ==; Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lh14I-00AyI6-QL for linux-arm-kernel@lists.infradead.org; Thu, 13 May 2021 02:27:20 +0000 Received: by mail-yb1-xb49.google.com with SMTP id d20-20020a25add40000b02904f8960b23e8so20368991ybe.6 for ; Wed, 12 May 2021 19:27:17 -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=HsrRkxbmeW42Q2bERAUqg4965RDz2y3d4rZ4ol559ww=; b=n92jDAggAnDferwKwoYbj61MFEsswjmcg0ongT3znn9VKcChPA2//TsTMMjyugiRLb mFw7yntiUwc7+LgwGz4m3h7l3zfYuwelDnF7m+6P2CnA2lTz3521EmJIbQDy0i39F2ji DAvpgBamMTx/7wOtPPCTTCD9nPRPU5DGEamAaFE1HtQD1Z0LN3DiwF8iqqSmM/SxKdsl 1+LvXAAu5NbWr97ttPY+teBcrtk/Fiovwo2t3rH/rnuoWBhFmEY2byRRmTjZCEX8Te4Z n2Fh5CWHRjkdp5rkQgs72Cbe5R3+/6UcdrcEWeuhnxB19I9Ih3Y1++yCw4W/vsWxWsnQ Pobg== 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=HsrRkxbmeW42Q2bERAUqg4965RDz2y3d4rZ4ol559ww=; b=j4TCXWQwFQ8/KEcu5kLGC+1b7hazHRsrb4mqz85uhAbvv9ZIs4PZnmORj1d9AVDOxE +f0xzZjLvRdLzzmeLbmvrmGzybuWr+HaoH/+/3R9L7aOE7VSX5coOm0U3XcqHtCr8Lv0 0oZFRkdgGTX5/8MHH99QkycJTixB/fnGLyMtsJAfwQM1jDljVHIbr9oQ16lq08DYrw0E wglMrdB/E7Fx5B49uIdko9u5qdf/C/ouP+bhKhkFUQIhmwJKtCtwnUXzOr/C+Bk+tw3w B3/l9PS+1DESPyIw/AREf558ePbMLjE0trg0JgT0H7/9SuO725sX9pJLmkYd2lbfECew G7Hg== X-Gm-Message-State: AOAM530szH4+oxiqdYWJsQFobTTwdk/02TrioecpG05UCwx+WpzpnNo5 Lu1ib/p2O5jrRLGze5d3GkrVwhA= X-Google-Smtp-Source: ABdhPJwu5iIe4sXHMAAaSyxYZOig65iNP9VyjxMi+Dw+0w51aExIgOA+kgz+QucXIAvUmOkCyB+gPy0= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:d8b:fba6:20f0:cbe3]) (user=pcc job=sendgmr) by 2002:a05:6902:513:: with SMTP id x19mr33720082ybs.129.1620872836281; Wed, 12 May 2021 19:27:16 -0700 (PDT) Date: Wed, 12 May 2021 19:27:08 -0700 In-Reply-To: <20210513022709.983982-1-pcc@google.com> Message-Id: <20210513022709.983982-2-pcc@google.com> Mime-Version: 1.0 References: <20210513022709.983982-1-pcc@google.com> X-Mailer: git-send-email 2.31.1.607.g51e8a6a459-goog Subject: [PATCH v4 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 , Andrey Konovalov X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210512_192718_892229_5B0B6C50 X-CRM114-Status: GOOD ( 15.67 ) 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 --- 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 | 6 +++++- 2 files changed, 6 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 2fecbf152e80..020e575e5cd3 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -68,7 +68,11 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame) unsigned long fp = frame->fp; struct stack_info info; - if (fp & 0xf) + /* Terminal record; nothing to unwind */ + if (!fp) + return -ENOENT; + + if (fp & 0x7) return -EINVAL; if (!tsk)