From patchwork Thu May 13 16:54: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: 12255983 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 8B707C433ED for ; Thu, 13 May 2021 16:56:47 +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 1A15460FDC for ; Thu, 13 May 2021 16:56:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A15460FDC 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=LSzm05GVxV+J6TsZ6C4f76wOSdRCyefFKUmXwtF+/6c=; b=kuZnA+ejXH9goN xFdGKYE7HAyFXqVaZI6VoVvebrOjDlgi9J8ilegknZwuP4xhtsBQP3Qpg4sxl6y8vCW9SJjHR3/5Q Aw2pEZUDjCGIr+kwIqCh8G4vJfvamlg+lbSKXu89QuE8dCsusNnvbf/SqMe7CO7VAXWhIIHWiFCH0 mwx/li3K5lW42G7mLuk0ClD+81vfi21zAQjXTMBY1e7EB2V8BS/yroge8hOEFolP6Byi8Tz5qP21c kEPBfJc1JHA1H/9c4ayP8uDky7YBUC3TrDfq4k83cUxkSDkJWJZRBaoOu6l6RPOKrOIxNl/IwoqnP RuF8c2RervoPKN7aH5Pg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lhEbm-0060cn-VV; Thu, 13 May 2021 16:54:47 +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 1lhEbk-0060cW-DV for linux-arm-kernel@desiato.infradead.org; Thu, 13 May 2021 16:54:44 +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=AOIFDOMn703+rY8/cBNA2oHMOB1w6+rGrHOvuNVB/zw=; b=zlyzAx3z0zLMVEI9EWjy7rSYh7 CCORYpuglava/rdcCFrS52ZceScHTFjwcodakR1aEWiAAD6d7kbTKbcIysA0ZGs0+rlhv2lUMsBWr rQfQ8tVUdBMlxJOHCpMM7FEH+aq22RJls3+rZdKxojA+LDSWjRDbkVZAUv0GGrwYWJO4355O5kIKw wjARL9RwN9tGG2M0lOfw1mGHZ7yECo2Pf199ttP0ZG6N9omsvo4IhVPnVXVKsD7CVvqZibFTstCBg 4hZq7bGPEPIRogOdSMb2GVUJf7V78b9FMeFlkejJJyB7FzXwMBSfx+TRkZcVN6E20VrMnHQrRDjLx rijmZ5Rg==; Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhEbh-00BOir-Ha for linux-arm-kernel@lists.infradead.org; Thu, 13 May 2021 16:54:43 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id w80-20020a25df530000b02904f953b5241bso7751563ybg.18 for ; Thu, 13 May 2021 09:54:39 -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=AOIFDOMn703+rY8/cBNA2oHMOB1w6+rGrHOvuNVB/zw=; b=pg0y7eNfKMkAxLYsrJ8jsRgBOQY2Mi3mS+c0VKOBJw51MedFWP5pefU53Q1idfMcqZ 8yTjbcRqmVkd6vE7taack60qFUgeCAQk0b3+pPK9bMMOYly/pAWzUWCUZSC+T7oNQ+kD yRv8Xm/cx+g2noyUH1fhHmGYKWHHJt60rJ/LllFxgX9dcQqDdoOwsvq0ZBB3WetjKGW6 GfHaKnA8gN4/4ISAFmX9zxnz3Uj/Z8Rzv2AiaEYLSPJbUn332QFEvpUN76VqGRkv0083 wStsOv8BmaObOskonT+IdLnTf/rzz+rEw8JVB/s03dg4k4Jp7DlFEm/Z8UY++BT6jB6B Yqig== 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=AOIFDOMn703+rY8/cBNA2oHMOB1w6+rGrHOvuNVB/zw=; b=FXSconfYW0hxFNwCpyW/YsWC86jDjBLXnQmWGTX1UROyXwAJTShCNJHtoSp8m3TL/D GboCvuKvspwhXaYq9L9y/Hxy/T8evwBYEHZ8J28gbhCGrtowUzAAzJl6QgHXt8kWiE7b NaStNpG0CHXI1XhV3E3kiZRR0wjQOxb3mdHFM3Q3QRq6vlDbuQtkD/pi6X6+ZaZAXzxl aWTzMq2cwGbamngCjHXXOShb58jIl2a0amz5/ysZF4mXopFm5lkyxgfGGqcbdHcwkzNY L1jcw7pNYNzHVre0S4Gx2ZiZqspsGbrVrnJvcLPn98gpsRVT8aJaC14euO1IioLFZB3a 6d4g== X-Gm-Message-State: AOAM532xPZFXTsX/KCKPfV8f/cMQz5t8NkYPqnwV1SbEu9mNZ/7gX0gM aG9JKGz8qzciGyUv2aJVhLkJpSY= X-Google-Smtp-Source: ABdhPJyd5S2my0WDXZ19cVyY2ogLplI0bgq017k8U/Di9AUqD9u9SKPkNL3EtJcagTPXcsGfmuomeAA= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2ce:200:2329:e7ca:8ef7:523e]) (user=pcc job=sendgmr) by 2002:a25:bbd1:: with SMTP id c17mr21450762ybk.507.1620924878564; Thu, 13 May 2021 09:54:38 -0700 (PDT) Date: Thu, 13 May 2021 09:54:26 -0700 In-Reply-To: <20210513165427.1133795-1-pcc@google.com> Message-Id: <20210513165427.1133795-2-pcc@google.com> Mime-Version: 1.0 References: <20210513165427.1133795-1-pcc@google.com> X-Mailer: git-send-email 2.31.1.607.g51e8a6a459-goog Subject: [PATCH v5 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-20210513_095441_618880_48E753BF X-CRM114-Status: GOOD ( 15.60 ) 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 Reviewed-by: Mark Brown --- 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 2fecbf152e80..bc672bfd7ac7 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -68,7 +68,7 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame) unsigned long fp = frame->fp; struct stack_info info; - if (fp & 0xf) + if (fp & 0x7) return -EINVAL; if (!tsk)