From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38B9B606A31F for ; Sun, 6 Dec 2026 01:26:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SMGU+aPF Received: by kanga.kvack.org (Postfix) id 33FA56B05B1; Sat, 5 Dec 2026 20:26:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C96F6B05B2; Sat, 5 Dec 2026 20:26:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 191726B05B3; Sat, 5 Dec 2026 20:26:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id D06AC6B05B1 for ; Sat, 5 Dec 2026 20:26:22 -0500 (EST) Received: from smtpin19.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 302A012071D for ; Sun, 6 Dec 2026 01:26:22 +0000 (UTC) X-FDA: 85511817804.19.98CEAD5 Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by imf26.hostedemail.com (Postfix) with ESMTP id 75B8814000C for ; Sun, 6 Dec 2026 01:26:20 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=fail ("headers rsa verify failed") header.d=kernel.org header.s=k20260515 header.b=SMGU+aPF; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf26.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796520380; b=S+Ipa1OOszCwApn4GEOug5Nbj3LlUVJL2TN3QNmPMlq5RO4pAxY69VV95R3c9fZ6xUpReA 6HDNzyc59GG2KpYZNlbF5mGoq5IiwPwpdcjAUO1L0tbfoGcRYBQMFJ176Od4oIfWH6ESL/ vnMciRnDMSkbbtiF/cQGvV5BulqWdaM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796520380; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MKZUZuCGZ4hbvmEzu0pSmjbWcZfJ25Qpsak+r0osAeo=; b=ZHBRPkprA+IVEGD4pSoiL9ulQoIbD16eTTbyNj/fqIoB9k+mbtA7eHWV9Mqj1dl+ZY0OAv qm2E/aJdfH5ccdFrCgvtjYttYns7IzfbucOvqzYmV+T2v9Kv1MIJTtIx8gJnc1W/mDaMaX 2+awC33Y9DBT5ZMiEVTjyob840/kCv4= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=fail ("headers rsa verify failed") header.d=kernel.org header.s=k20260515 header.b=SMGU+aPF; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf26.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.234.252.31 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 4E86842E8C; Sun, 6 Dec 2026 01:26:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF26E1F0092B; Sun, 6 Dec 2026 01:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796520379; bh=MKZUZuCGZ4hbvmEzu0pSmjbWcZfJ25Qpsak+r0osAeo=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=SMGU+aPFhtxYwlzOcrqAiHUPGorgkOhrzvs1OywxLbOGI8BAo+AOEyGsuWUkYgBDB 8zUSjywHCFbiQNo/M7b6v/qXPhpPAu1Czc2QAl1q2f+cIirsvytMqgQYLCskby51+3 L0smz5Hlj+S46eGpeivzM9jvRVgHHOD4nShfeMZyjiJ5ZeVt4EEZVyUewzRn0S8RWY 6QuG+Y7uoPF3yQrOppQlHvU2AznDNG6LTcej4R42aj2bUMkqa8sJssFNZQDtXpvPbi SWf4Vr7iZZzrK3zstgXpF8wKx5k+R6BqKUV1abfRekVTPLHbcxTgJye8yNXcPrtKWs s0vL5Lc7JDqkQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v16 2/9] ACPI: APEI: GHES: use exception context to gate SIGBUS on poison consumption Reply-To: sashiko-reviews@lists.linux.dev To: "Jiangtian Feng" , catalin.marinas@arm.com, will@kernel.org, akpm@linux-foundation.org, rafael@kernel.org Cc: mark.rutland@arm.com, james.morse@arm.com, robin.murphy@arm.com, nikumbh.adi@gmail.com, tony.luck@intel.com, guohanjun@huawei.com, mchehab@kernel.org, lenb@kernel.org, xueshuai@linux.alibaba.com, tongtiangen@huawei.com, tianruidong@linux.alibaba.com, tongweilin@linux.alibaba.com, baolin.wang@linux.alibaba.com, ashok.raj@oss.qualcomm.com, jonathan.cameron@oss.qualcomm.com, david@kernel.org, liam@infradead.org, vbabka@kernel.org, rppt@kernel.org, mhocko@suse.com, ljs@kernel.org, surenb@google.com, shivankg@amd.com, wangkefeng.wang@huawei.com, xiangzao@linux.alibaba.com, ying.huang@linux.alibaba.com, linmiaohe@huawei.com, nao.horiguchi@gmail.com, ziy@nvidia.com, tujinjiang@huawei.com, mgorman@techsingularity.net, kaitao.cheng@linux.dev, chengkaitao@kylinos.cn, muchun.song@linux.dev, nico.pache@linux.dev, ryan.roberts@arm.com, dev.jain@arm.com, baohua@kernel.org, lance.yang@linux.dev, usama.arif@linux.dev, kas@kernel.org, kees@kernel.org, andreyknvl@gmail.com, dvyukov@google.com, gli@kvack.org, der@google.com, ryabinin.a.a@gmail.com, vincenzo.frascino@arm.com, tglx@kernel.org, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org, ritesh.list@gmail.com, sshegde@linux.ibm.com, aneesh.kumar@kernel.org, naveen.n.rao@linux.ibm.com, linux-mm@kvack.org, kasan-dev@googlegroups.com, x86@kernel.org In-Reply-To: <20261205012435.1406255-3-jiangtianfeng@linux.alibaba.com> References: <20261205012435.1406255-1-jiangtianfeng@linux.alibaba.com> <20261205012435.1406255-3-jiangtianfeng@linux.alibaba.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 06 Dec 2026 01:26:16 +0000 X-Stat-Signature: qhjrfmf6wk5tyuwfg4y5zsafowbzpoik X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Rspam-User: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 75B8814000C X-HE-Tag: 1796520380-864948 X-HE-Meta: U2FsdGVkX19tpix6nvPscT2o3CR+vCxTxM+F4JZhoKw/7Fo0fD7iUV751s+6K78assn3yZ8vD8gZQT0CW2nxvXCY6bC9/Qw2Y31EVJkjJrbcf+GftX9pR2ucuzytDxpj4vxQp5TPNX405bMWVJpAxJ2wOh83k1j6LlMKpWryO2Ietv1srbsYDUDtKEoE2xt+0c3qtyardNKuR82xYzrCemWiK9WXGFIrQpfKduEPNQXivfy3mLMgrchdRu7mzMmQ711NReM3LOE0w5x/R8HQz0PyCu+1V4E+tErkhzeEjdpab33ZrDN8u8Vvhlt0CxcOK6vKzHxbh1j0koouWf6CO9tU0M4m0qo+iH7Qd6p4gByfVqB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gVzmC2DfwVsxcO0zlMeyLB3npuPEzPdzvuFvFoUHqVRaDna+f3A3FKoC2IBtaE5oMCDo6v0cf2wXeA2m3HgBk/7mkT7ERV6dW23RLlPYQqznULLaQeuPnFchHz3ZAcFWaVcE72xc5O8hTqNtpdCDR3Iw6jzLKDX0bADcEHNXaOR834jZLkcdy/zWljXfNdpjYq9j+W3rQvHfo4PIl3AjbriNsW1siFDBmBVwvSInMLxC7dB6jf2jcKxPnAE9/NRVubJNa6EFbENCE1qs3btf3pKg3ZAkZLuNdlvMu+huNzgoceQsFdeRMsZN0ZAPBSAynAiXK6CVHIgc9jWa90Lq3lWxpOrq2NBy0OVY2axOrQvo+C2vTY/2jgzeyBmPf8cLUhfR+45dAvwQUhf7I6Bwrhuf5zc/Rigg7k= Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [Medium] ACPI: APEI: GHES_CTX_KERNEL defers SEA poisoning to async workqueue - [Medium] ACPI: APEI: GHES: cached kernel SEA returns 0 without queuing work - [Low] ACPI: APEI: commit message mismatches enum ghes_exec_ctx and reachability - [Low] ACPI: APEI: GHES_CTX() double-evaluates, fails on NULL, lacks ptrace.h -- commit 9312338f2bc24ddbc1ea6e4a8f429c087d02ab9f Author: Ruidong Tian ACPI: APEI: GHES: use exception context to gate SIGBUS on poison consumption This commit introduces an execution context enum and plumbs it from apei_claim_sea() through GHES NMI-like spooling into memory failure handling, so kernel-mode synchronous external aborts can avoid setting MF_ACTION_REQUIRED or force-killing the current task with SIGBUS. > Up to now ghes_handle_memory_failure() unconditionally promoted any > synchronous recoverable memory error to MF_ACTION_REQUIRED, which > ends up SIGBUS on current -- regardless of whether the poison was > consumed from user space or from inside the kernel on the task's > behalf. That kills tasks that should instead have seen a plain > syscall error. [ ... ] > Introduce: > > enum context { ... }; > > and plumb the value all the way down to the queued estatus node: > > * Add an 'enum context context' field to struct ghes_estatus_node > and record it in ghes_in_nmi_queue_one_entry(). > * Extend ghes_notify_sea() and the internal > ghes_in_nmi_spool_from_list() with an enum context parameter. [Severity: Low] This isn't a bug, but the commit message refers to enum context three times while the patch actually defines enum ghes_exec_ctx, and it omits the new GHES_CTX() macro. Also, at this commit do_sea() still checks user_mode(regs) before calling apei_claim_sea(regs), so GHES_CTX_KERNEL is not yet reachable. Describing this as preparatory work rather than a currently reachable bug would match the tree state. > diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c > index 5d888c82efeaa..eb4466aa87f25 100644 > --- a/drivers/acpi/apei/ghes.c > +++ b/drivers/acpi/apei/ghes.c > @@ -543,7 +543,7 @@ static bool ghes_handle_memory_failure(struct acpi_he= st_generic_data *gdata, > (gdata->flags & CPER_SEC_ERROR_THRESHOLD_EXCEEDED)) > flags =3D MF_SOFT_OFFLINE; > if (sev =3D=3D GHES_SEV_RECOVERABLE && sec_sev =3D=3D GHES_SEV_RECOVERA= BLE) > - flags =3D sync ? MF_ACTION_REQUIRED : 0; > + flags =3D sync && context !=3D GHES_CTX_KERNEL ? MF_ACTION_REQUIRED : = 0; > =20 > if (flags !=3D -1) > return ghes_do_memory_failure(mem_err->physical_addr, flags); > @@ -552,10 +552,10 @@ static bool ghes_handle_memory_failure(struct acpi_= hest_generic_data *gdata, > } > =20 > static bool ghes_handle_arm_hw_error(struct acpi_hest_generic_data *gdat= a, > - int sev, bool sync) > + int sev, bool sync, enum ghes_exec_ctx context) > { > struct cper_sec_proc_arm *err =3D acpi_hest_get_payload(gdata); > - int flags =3D sync ? MF_ACTION_REQUIRED : 0; > + int flags =3D sync && context !=3D GHES_CTX_KERNEL ? MF_ACTION_REQUIRED= : 0; [Severity: Medium] Does clearing MF_ACTION_REQUIRED for GHES_CTX_KERNEL inadvertently defer page poisoning to the asynchronous workqueue? ghes_do_memory_failure() only queues synchronous TWA_RESUME task_work when flags =3D=3D MF_ACTION_REQUIRED && current->mm, so passing flags =3D 0 falls through to memory_failure_queue(pfn, 0). When a kernel copy helper such as copy_from_user() recovers via its extable fixup and returns -EFAULT, the task can return to userspace before the kworker runs, while the poisoned page is still mapped and unpoisoned. In that window, the task can munmap() or exit and return the poisoned page to the allocator for another task or the kernel to consume, or re-access it and hit the 10-second ghes_estatus_cached() entry just added by ghes_proc_in_irq(). Gating task_work_add() on sync && current->mm while gating the SIGBUS delivery in memory_failure_cb() on MF_ACTION_REQUIRED would keep poisoning synchronous before returning to userspace while still suppressing SIGBUS for GHES_CTX_KERNEL. [ ... ] > @@ -1452,11 +1456,10 @@ static int ghes_in_nmi_queue_one_entry(struct ghe= s *ghes, > /* This error has been reported before, don't process it again. */ > if (ghes_estatus_cached(estatus)) { > /* > - * Return failure on duplicate SEA entries so that the > - * subsequent SEA handler invocation sends a SIGBUS signal to > - * the task to prevent it from re-entering the handler loop. > + * Kernel copies must still reach their fixup; retain duplicate > + * SEA anti-storm handling for user and KVM/NA paths. > */ > - if (is_hest_sync_notify(ghes)) > + if (is_hest_sync_notify(ghes) && context !=3D GHES_CTX_KERNEL) > rc =3D -ECANCELED; > goto no_work; > } > @@ -1473,14 +1476,15 @@ static int ghes_in_nmi_queue_one_entry(struct ghe= s *ghes, > } > =20 > static int __maybe_unused ghes_in_nmi_spool_from_list(struct list_head *= rcu_list, > - enum fixed_addresses fixmap_idx) > + enum fixed_addresses fixmap_idx, > + enum ghes_exec_ctx context) > { > int ret =3D -ENOENT; > struct ghes *ghes; > =20 > rcu_read_lock(); > list_for_each_entry_rcu(ghes, rcu_list, list) { > - if (!ghes_in_nmi_queue_one_entry(ghes, fixmap_idx)) > + if (!ghes_in_nmi_queue_one_entry(ghes, fixmap_idx, context)) > ret =3D 0; > } > rcu_read_unlock(); [Severity: Medium] Can returning 0 from the cached no_work path break duplicate kernel SEA recovery when IRQs are disabled? For a cached GHES_CTX_KERNEL record, ghes_in_nmi_queue_one_entry() frees estatus_node without adding it to ghes_estatus_llist, yet returns 0. ghes_in_nmi_spool_from_list() then treats that 0 as queued work, calls irq_work_queue(&ghes_proc_irq_work) on an empty list, and returns 0 to apei_claim_sea(). If the duplicate SEA hits an IRQ-disabled kernel copy such as __copy_from_user_inatomic() in unwind_user_frame() during a perf PMU IRQ, apei_claim_sea() assumes queued work could not run, logs "APEI work queued but not completed", and returns -EINPROGRESS. With commit "arm64: enable recover from synchronous external abort in kernel context", do_apei_claim_sea() then skips fixup_exception_me() and do_sea() falls through to arm64_notify_die(), turning a recoverable duplicate copy into a fatal exception. Even with IRQs enabled, it still triggers a spurious irq_work_queue() and irq_work_run(). Distinguishing "claimed, already cached" from "claimed, work queued" across ghes_in_nmi_queue_one_entry(), ghes_in_nmi_spool_from_list(), and ghes_notify_sea() would avoid both the empty irq_work and the false -EINPROGRESS. > diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h > index 7acf209061ea7..2cd97f7002140 100644 > --- a/include/acpi/ghes.h > +++ b/include/acpi/ghes.h > @@ -33,10 +33,21 @@ struct ghes { > void __iomem *error_status_vaddr; > }; > =20 > +enum ghes_exec_ctx { > + GHES_CTX_NA =3D -1, > + GHES_CTX_KERNEL =3D 0, > + GHES_CTX_USER =3D 1 > +}; > + > +#define GHES_CTX(regs) ((regs) ? (user_mode(regs) ? GHES_CTX_USER \ > + : GHES_CTX_KERNEL) \ > + : GHES_CTX_NA) [Severity: Low] Should GHES_CTX() be a static inline helper instead of a macro? As written, it evaluates regs twice when non-NULL, fails to compile if a caller passes literal NULL because user_mode(NULL) dereferences void *, and relies on callers transitively including ptrace.h for user_mode(). A static inline helper taking const struct pt_regs *regs (with ptrace.h included, or kept local to arch/arm64/kernel/acpi.c) avoids all three. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205012435.1406= 255-1-jiangtianfeng@linux.alibaba.com?part=3D2