From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD057606A322 for ; Wed, 2 Dec 2026 19:31:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=XfS5DXxh; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=ZrKxxWpK DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:Message-ID:Mime-Version:Date:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Unsubscribe-Post:List-Owner; bh=tR2CAhuBSOobvVSZedH6LDtOptsCFj9icKt8MuvxTd4=; b=XfS5DXxhp4e/ZFfXSCBo33tsbe PMlgrMNbUurCcZ/AP4V7KEiGUrD3+6RVjjqpdsNgedrr3BR/bACcl0iKN6l+JSV6LhJaopops0Zqi CqsIy5iiotU1yAJx8Aku4M0JX6z9nt6U1kt7YaewsSPi5v5ubBVsypLIQ4Z9vjDd0Dla8/QpyfMs/ t+IvV8Cx5MFbfgqUm94s5BPuC42DfPKfd/Ei7KZxvoiAs+g68EKHJDmQyJ2XJwHcie21UiGiFwOna fmF8B5QgwbRxbwOAAfPJJgPSLHNz+JYCHsFqCxT+uNcnkK/SHO2lG4+Ha8Y6NEWxrSASMen2Lk+Ma yO6af/NA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYq32-0000000CdTL-2Yd6; Wed, 02 Dec 2026 19:31:24 +0000 Received: from mail-dl1-x1247.google.com ([2607:f8b0:4864:20::1247]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYq2z-0000000CdRH-3B4A for linux-arm-kernel@lists.infradead.org; Wed, 02 Dec 2026 19:31:23 +0000 Received: by mail-dl1-x1247.google.com with SMTP id a92af1059eb24-154e9d2d94fso4952477c88.0 for ; Wed, 02 Dec 2026 11:31:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796239880; x=1796844680; darn=lists.infradead.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=tR2CAhuBSOobvVSZedH6LDtOptsCFj9icKt8MuvxTd4=; b=ZrKxxWpKuWDsieq7EhmJO4TIdSQDB7BcUaLPFHdolB5YDVsOOfALJ/paABj45V8TZX fHKItcU5o7f+gBlDs77JRS8mLB11QV0eLwLdTpgyyD5kVQAGVyHadG8WGefOaGeMo6D+ vfkdX+crJUNge897k2uBRiFpG9AAa9mk4FxZ7AFFESmqP8UkVDFsLJAhUPat+qm1Af6G DlPZi/kzyeQDWL7rWavZzV/r4vLf8yIyvz0o0lwLFxcBt/FaiVQbeHuVBk+hzGfk9s3P 4SkPBCHGG784sPQEVvBg5W0VluFMBOTT1//TgfoZeTFeGKYFe/UsfGJn83GofnlsZSNW Oecw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796239880; x=1796844680; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=tR2CAhuBSOobvVSZedH6LDtOptsCFj9icKt8MuvxTd4=; b=nD0cUL8C263r6xxmatPlN28s+gnjSmdVSMug3T4cwFXaXaQdGdaVs1rPKf52GnvoOO hED8OaVZg9PjxKL094lbtVM0RFBkn5j3208ywJ+hpYfzBuIYQq+fURgmW+97ESP4C8mP zR4oJKoaSUBk7pvDu4Fya3fwNWs4jN98v8oiyu//3cvLuXE57EaehXQOgfVeGaQ9p+GY qXLnXpTBfb31p0unk1iw+Yu3yxilF0DCzxKHHIo9zve7bbhU3ct39TcJ1DjJSPoAhR5u E8weKM+ENmMZcNgJzjQ1eezE2m5jmiP1dchJikd+ehbwBInkq45oaUmgDxWTt2HYgRCD UqKg== X-Forwarded-Encrypted: i=1; AL+hErHTNY4Xub0uo20J3JYpC9MxegrFzKaRbpKbuTz2Wy4GcaL106E+mLxQQPL7pya+q3MEo3gIgVcwsHYgRB+ZIwTr@lists.infradead.org X-Gm-Message-State: APuU4Z+jzdVF84D7iCYX+00mamQJO3SsPpmXGws71JxruFyTt0u+niVQ K3TGEYcKJGHbW2//ZoSLjr89aJxqTpurigDEgDnKFcyFLJ4SL0SflGfJGbTqHs4dXQbYgpjNlkG slXfgKg== X-Received: from dlae21.prod.google.com ([2002:a05:701b:2315:b0:1b5:aa96:54c7]) (user=weihsu job=prod-delivery.src-stubby-dispatcher) by 2002:a05:701b:42d1:20b0:1af:d88f:fc51 with SMTP id a92af1059eb24-1b5568edb1dmr44717549c88.30.1796239879761; Wed, 02 Dec 2026 11:31:19 -0800 (PST) Date: Wed, 2 Dec 2026 19:31:15 +0000 X-Archived-By: Mime-Version: 1.0 X-Mailer: git-send-email 2.56.1.915.g69d5ec7298-goog Message-ID: <20261202193116.982004-1-weihsu@google.com> Subject: [PATCH v2] ARM: stacktrace: Fix Clang frame pointer upper bound and alignment check From: Wei-chung Hsu To: Russell King Cc: Nick Desaulniers , Nathan Chancellor , Bill Wendling , Justin Stitt , Ard Biesheuvel , Prasanna Kumar T S M , linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, Wei-chung Hsu , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261202_113121_800158_B7B20B12 X-CRM114-Status: GOOD ( 15.95 ) X-Spam-Score: -9.5 (---------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-26.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 When built with Clang (CONFIG_CC_IS_CLANG) and frame pointers (CONFIG_FRAME_POINTER), unwind_frame() reads two 32-bit words starting at fp: *(unsigned long *)(fp) and *(unsigned long *)(fp + 4), i.e. 8 bytes [fp, fp + 7]. However, frame_pointer_check() copied the GCC upper-bound check (fp > high - 4), which assumes accesses stay below fp (fp - 12 .. fp - 4). It also does not verify 4-byte alignment of fp. With CONFIG_VMAP_STACK=y, if an interrupt or lockdep trace_hardirqs_on() unwinds through hand-written assembly that uses r11 (fp) as a scratch pointer (such as __aes_arm_encrypt / __aes_arm_decrypt), an unaligned or top-of-stack fp value in (high - 8, high - 4] (e.g. 0xf554bffb or 0xf6733ff9, 5-7 bytes below high) passes frame_pointer_check(), and the subsequent read of *(unsigned long *)(fp + 4) faults into the unmapped VMAP_STACK guard page: Unable to handle kernel paging request at virtual address f554c000 Internal error: Oops: 207 [#1] SMP ARM PC is at walk_stackframe+0x11c/0x17c walk_stackframe from return_address+0x6c/0xa8 return_address from trace_hardirqs_on+0x158/0x1e8 trace_hardirqs_on from __aes_arm_encrypt+0x4b8/0x500 Reject unaligned frame pointers via !IS_ALIGNED(fp, 4) before the call_with_stack() pc check (call_with_stack() always keeps fp 4-byte aligned on both Clang and GCC), and tighten the Clang upper bound to fp > high - 8 so both *(fp) and *(fp + 4) stay strictly within [low, high). Fixes: b4d5ec9b39f8 ("ARM: 8992/1: Fix unwind_frame for clang-built kernels") Cc: stable@vger.kernel.org Signed-off-by: Wei-chung Hsu --- Changes in v2: - Move the !IS_ALIGNED(fp, 4) check before the call_with_stack() pc check with its own comment (per Nick Desaulniers). Dropped Prasanna's v1 Reviewed-by due to the control-flow reorder. - Add Cc: stable@vger.kernel.org (per Nick Desaulniers). - Verified call_with_stack() in arch/arm/lib/call_with_stack.S maintains 4-byte fp alignment on both Clang and GCC. - Will submit to Russell King's ARM patch tracker after list review. Link to v1: https://lore.kernel.org/all/20261130232454.176395-1-weihsu@google.com/ arch/arm/kernel/stacktrace.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c index 620aa82e3..dae8ac614 100644 --- a/arch/arm/kernel/stacktrace.c +++ b/arch/arm/kernel/stacktrace.c @@ -50,6 +50,10 @@ static int frame_pointer_check(struct stackframe *frame) unsigned long fp = frame->fp; unsigned long pc = frame->pc; + /* check current frame pointer is 4-byte aligned */ + if (!IS_ALIGNED(fp, 4)) + return -EINVAL; + /* * call_with_stack() is the only place we allow SP to jump from one * stack to another, with FP and SP pointing to different stacks, @@ -65,7 +69,7 @@ static int frame_pointer_check(struct stackframe *frame) /* check current frame pointer is within bounds */ #ifdef CONFIG_CC_IS_CLANG - if (fp < low + 4 || fp > high - 4) + if (fp < low + 4 || fp > high - 8) return -EINVAL; #else if (fp < low + 12 || fp > high - 4) -- 2.56.1.915.g69d5ec7298-goog