From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 59DD1FF886F for ; Thu, 30 Apr 2026 10:04:51 +0000 (UTC) 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-Owner; bh=Of6v3tddymZAopVSSZLx/BjESEwtJ6OYNXD95nkNQ9I=; b=0CSbIvhwpiSeQp+yA5lbt1FMB3 8B33awUSIeNN4uF8Dl6qhccOjaBT+NYdkQu2npp4/YISawKTiu2CWgVxXoGr+PO2HNYNsVAaYet24 i6L+LeqjCs64RYRFSZbEJwS7bcmvtR7h4GijSWSTIBcHcqX3sl5cWS+rL/7GF1D4EZ8Ps2nRp8Ylx tPyCPR6XfKVaclb8gSTmJ70GHsWc6f9HLC6pnno1BQtVJonf7Mvx8a3exj4ZC2eSusRPB+sSigZ7p VyZnzbI75DL51ut5b3eOIwJrHwA9gysfFxOeodIiyOxht9gG8yjQZXSpxuhHSqKJPKnzpvgEbWh6A Kgy6YCUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1wIOGD-00000005A0h-21Nk; Thu, 30 Apr 2026 10:04:45 +0000 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1wIOG3-000000059wY-0ZAY for linux-arm-kernel@lists.infradead.org; Thu, 30 Apr 2026 10:04:42 +0000 Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63TIf3P81559961; Thu, 30 Apr 2026 10:04:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=Of6v3t ddymZAopVSSZLx/BjESEwtJ6OYNXD95nkNQ9I=; b=ou4JTHKrALqEFtr/K9miwl lwLm3i56asVr1ieQXl0n5FH0eeXuXRHkrhf+BpJdy7ImRuYlgntKoM66am9do+u2 kKcpI935UwEx9zTU1F9CJNseBfVesQ7WOeGK+kxqKKFH6b4rXwjK2bVAQhucseCX WMYYHISVBeq59iJk8mpHRKXaUb0NBCNhDb0aK1GfZMMZdgH99vT0sgy+aiYfzIvy zEQvZap/X49LHDtlDvVWJLgvvPwTuVXBRXQ1P/9UrUzgGM6KxOk3xrVdJJQqCT6S JbHiGzAVJr0SDgsJ6zoSXQCysTw8O5WL0XLGuPtldkV5VhttcYXSfg29pACgAQdA == Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4drn8vnb10-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Apr 2026 10:04:04 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 63U9ro7N032701; Thu, 30 Apr 2026 10:04:03 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4ds8aw2g4t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Apr 2026 10:04:03 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 63UA414P60031378 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Apr 2026 10:04:01 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 497E420049; Thu, 30 Apr 2026 10:04:01 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B617620040; Thu, 30 Apr 2026 10:04:00 +0000 (GMT) Received: from [9.52.200.195] (unknown [9.52.200.195]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 30 Apr 2026 10:04:00 +0000 (GMT) Message-ID: <6fb474e6-7e54-408b-a3d9-9e13c674740c@linux.ibm.com> Date: Thu, 30 Apr 2026 12:04:00 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 7/8] sframe: Introduce in-kernel SFRAME_VALIDATION To: Dylan Hatch , Roman Gushchin , Weinan Liu , Will Deacon , Josh Poimboeuf , Indu Bhagat , Peter Zijlstra , Steven Rostedt , Catalin Marinas , Jiri Kosina Cc: Mark Rutland , Prasanna Kumar T S M , Puranjay Mohan , Song Liu , joe.lawrence@redhat.com, linux-toolchains@vger.kernel.org, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Randy Dunlap , Heiko Carstens References: <20260428183643.3796063-1-dylanbhatch@google.com> <20260428183643.3796063-8-dylanbhatch@google.com> Content-Language: en-US From: Jens Remus Organization: IBM Deutschland Research & Development GmbH In-Reply-To: <20260428183643.3796063-8-dylanbhatch@google.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=CIIamxrD c=1 sm=1 tr=0 ts=69f32914 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=QMc7QGPnP32PvtbJ_1wA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: zHdENj8pe7xhfjKzYXLQilF2gKUQgWlz X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDMwMDA5OCBTYWx0ZWRfX+ZhHMSaiAJEV +IMEZ9ZaeHhmTO1z96r4nMyBUjbCGqpkK+elMrlooeOITudnP+3qyu4rfwWTQmJHg6cqmKx5LXz tLTrswQUCofSfBHO/b/xVxmrvuxl1rUce9O+4Zt/+x8NPZwyyP3pObnYmD8Jyrq4WWkQ+MM0D+b OOP+vCN4TtrI8Yc7I3aWuXnc9SJwFfYvm2Zp/ov1EpNlb1YLhnyvK8vngtAc4LmbIdjLFNYJLRI BGvR9xboPeRXIURQtGs8arHUx5ZryX1A8nTCVWBjaK4z/EfyuMp5J7nXaT1l0ZjD05CqKgoxQF3 avgVXvSypr72i/nh/F8m4XCsfivhAP4JCpLLTJWnVT50kBOW83zv0U93X3tLktpT0S5XAWc3Bt9 Mgmxl8AK7hSMY/Mbg1Qae+BQPqDoh9ySTwMO4uC/JYk2sqqACb6xkmhlLGULBS2JsY2iMncak8E 9aeHepxYFdxzLeV3nsw== X-Proofpoint-GUID: eMVam4ZfEteGXrjhGDO56EdCBNpTPVoi X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-30_03,2026-04-28_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 malwarescore=0 suspectscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 bulkscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604300098 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260430_030435_296587_13E56278 X-CRM114-Status: GOOD ( 26.12 ) 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 On 4/28/2026 8:36 PM, Dylan Hatch wrote: > Generalize the __safe* helpers to support a non-user-access code path. > > This requires arch-specific function address validation. This is because > arm64 vmlinux keeps .exit.text (normally discarded), and .rodata.text > sections both of which lie outside the bounds of the normal .text. > .rodata.text contains code that is never executed by the kernel mapping, > but for which the toolchain nonetheless generates sframe data, and needs > to be considered valid for a PC lookup. > > Additionally .init.text lies outside .text for all arches and must be > accounted for as well. > diff --git a/arch/arm64/include/asm/unwind_sframe.h b/arch/arm64/include/asm/unwind_sframe.h > @@ -2,7 +2,54 @@ > #ifndef _ASM_ARM64_UNWIND_SFRAME_H > #define _ASM_ARM64_UNWIND_SFRAME_H > > +#include > +#include > +#include > + > #define SFRAME_REG_SP 31 > #define SFRAME_REG_FP 29 > > +static inline bool sframe_func_start_addr_valid(struct sframe_section *sec, > + unsigned long func_addr) > +{ > + /* Common case for unwinding */ > + if (sec->text_start <= func_addr && func_addr < sec->text_end) > + return true; > + > + if (sec->sec_type != SFRAME_KERNEL) > + return false; > + > + /* > + * Account for vmlinux and module code outside the normal .text section. > + * The toolchain still generates sframe data for these functions, so > + * sframe lookups on them should be allowed. > + */ > + if (sec == &kernel_sfsec) { > + if (is_kernel_inittext(func_addr)) > + return true; > + > + /* .exit.text is retained in vmlinux on arm64. */ > + if (func_addr >= (unsigned long)__exittext_begin && > + func_addr < (unsigned long)__exittext_end) > + return true; > + > + Nit: Superfluous empty line (2 instead of 1). > + /* > + * .rodata.text is never executed from the kernel mapping, but > + * still has sframe data > + */ > + if (func_addr >= (unsigned long)_srodatatext && > + func_addr < (unsigned long)_erodatatext) > + return true; > + } else { > + struct module *mod = container_of(sec, struct module, > + arch.sframe_sec); This currently does not work properly when sframe_validate_section() is called from sframe_module_init(), which operates on a temporary struct sframe_section section, that is not (yet) the one in struct module. See my feedback to the respective patch for how to resolve. > + if (within_module_mem_type(func_addr, mod, MOD_INIT_TEXT)) > + return true; > + } > + > + return false; > +} > +#define sframe_func_start_addr_valid sframe_func_start_addr_valid > + > #endif /* _ASM_ARM64_UNWIND_SFRAME_H */ Regards, Jens -- Jens Remus Linux on Z Development (D3303) jremus@de.ibm.com / jremus@linux.ibm.com IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Ehningen; Registergericht: Amtsgericht Stuttgart, HRB 243294 IBM Data Privacy Statement: https://www.ibm.com/privacy/