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 A3340606A31A for ; Tue, 1 Dec 2026 03:31:19 +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=sdXo6FnB; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.a=rsa-sha256 header.s=default header.b=B5jrW5MD 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-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=vAjaDsPQVkIbSgbEx+S5q1i9emJtqZ26OmUuOb6NCoo=; b=sdXo6FnBq9H+yw H6CyhkyYTweF9D++plmaZQ4ttZMumRxU0JpgJdlD+02kGneSWic6iHzSypS0EsFq8a4S8ZNT/v7nb FM6eNotj0zv6Z/2W95k2sg7Bt5xPZYmT9ZfIAmd/95cyTUdSxv3VrMHbfDilGhSUanFpK9ZVKzGA4 ReQ/7vmmCyBdadd5C1OUC3qzR+pwNS+huPu8qgHmK4i6T6sUV8w2kjOFaMiceyGYyTp7EGT3/LsbY Hnw32ePWKT1x6NYGk1CR9gYCBAUmbOJETl9JarEiZ/rAMzu2D49f8miERPqa7iisIM0tniNe+XbuD YkXkShZGE+0QpXSfyJuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYEaG-00000006SQl-19vy; Tue, 01 Dec 2026 03:31:12 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYEaC-00000006SQ9-0vHx for linux-arm-kernel@lists.infradead.org; Tue, 01 Dec 2026 03:31:11 +0000 Received: from [10.94.176.220] (unknown [52.172.102.219]) by linux.microsoft.com (Postfix) with ESMTPSA id 10CCA20B7168; Mon, 30 Nov 2026 19:30:56 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 10CCA20B7168 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1796095859; bh=vAjaDsPQVkIbSgbEx+S5q1i9emJtqZ26OmUuOb6NCoo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=B5jrW5MDUXAVWtXiqp1hJaS4854qSqqWhvNI2EFo4jxiaJYtDwT6we6GR4TDz47+f s6d/Y4FUgpUhMcc4Zibb0769VptSN/Iejd56U7B03hEHZvgoZk/oRitt1r5ev7Pxlu VnRln3Q38a+ucwO3QM1MM7GyMvUD2ZuGQkqXgGBQ= Message-ID: Date: Tue, 1 Dec 2026 09:01:02 +0530 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] ARM: stacktrace: Fix Clang frame pointer upper bound and alignment check To: Wei-chung Hsu , Russell King Cc: Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org References: <20261130232454.176395-1-weihsu@google.com> Content-Language: en-US From: Prasanna Kumar T S M In-Reply-To: <20261130232454.176395-1-weihsu@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-17.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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_SANE_1 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261130_193109_988186_011CBB2D X-CRM114-Status: GOOD ( 19.62 ) X-Spam-Score: -4.4 (----) 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" On 01-12-2026 04:54, Wei-chung Hsu wrote: > 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) 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") > Signed-off-by: Wei-chung Hsu > --- > arch/arm/kernel/stacktrace.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/arm/kernel/stacktrace.c b/arch/arm/kernel/stacktrace.c > index 620aa82e3bdd..3cbab5286f10 100644 > --- a/arch/arm/kernel/stacktrace.c > +++ b/arch/arm/kernel/stacktrace.c > @@ -64,8 +64,10 @@ static int frame_pointer_check(struct stackframe *frame) > high = ALIGN(low, THREAD_SIZE); > > /* check current frame pointer is within bounds */ > + if (!IS_ALIGNED(fp, 4)) > + return -EINVAL; > #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) Looks good to me. Reviewed-by: Prasanna Kumar T S M