All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ahmed Tiba" <ahmed.tiba@arm.com>
Cc: linux-cxl@vger.kernel.org, linux-pci@vger.kernel.org,
	devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v8 04/22] ACPI: APEI: GHES: drain deferred work before freeing a source
Date: Thu, 03 Dec 2026 14:00:40 +0000	[thread overview]
Message-ID: <sashiko-outbox-247911@kernel.org> (raw)
In-Reply-To: <20261203-topics-ahmtib01-ras_ffh_arm_internal_review-v8-4-157aac88560b@arm.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] ACPI: APEI: irq_work_sync() in ghes_remove() leaves
  concurrent UAF window
- [Low] ACPI: APEI: missing Fixes trailer for commit 21480547c8b8 in
  ghes_remove()
--

commit 3ddf2ff751b2a3ebd22a2b95b293aa447a0715c3
Author: Ahmed Tiba <ahmed.tiba@arm.com>

> ACPI: APEI: GHES: drain deferred work before freeing a source
>
> Queued error status nodes retain a pointer to their struct ghes so that
> ghes_proc_in_irq() can process the record later. Device removal stops new
> notifications, but it can free that source while previously queued IRQ
> work still holds the pointer.
>
> Drain the global IRQ work after unregistering the notification source and
> before releasing the GHES resources.
>
> Reported-by: sashiko-bot@kernel.org
> Link: https://sashiko.dev/#/message/20260617140908.9FEA81F000E9%40smtp.kernel.org
> Signed-off-by: Ahmed Tiba <ahmed.tiba@arm.com>

[Severity: Low]
This looks like a bug fix for the deferred processing path introduced in
21480547c8b8 ("ghes: add the needed hooks for EDAC error report").  Should
this include:

  Fixes: 21480547c8b8 ("ghes: add the needed hooks for EDAC error report")

> diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
> index 03eee0b2500e9..dd3a698990e21 100644
> --- a/drivers/acpi/apei/ghes.c
> +++ b/drivers/acpi/apei/ghes.c
> @@ -1926,6 +1926,7 @@ static void ghes_remove(struct platform_device *ghes_dev)
>  		break;
>  	}
>  
> +	irq_work_sync(&ghes_proc_irq_work);
>  	ghes_fini(ghes);
>  
>  	mutex_lock(&ghes_devs_mutex);

[Severity: Medium]
Can irq_work_sync(&ghes_proc_irq_work) return while another CPU is still
dereferencing struct ghes inside ghes_proc_in_irq()?

irq_work_single() clears IRQ_WORK_PENDING before invoking work->func(work)
and clears the single IRQ_WORK_BUSY bit afterward with atomic_cmpxchg().
Because ghes_proc_irq_work is shared across all CPUs and NMI/SEA/SDEI
sources, a second CPU can run it concurrently and clear IRQ_WORK_BUSY first.

On !CONFIG_PREEMPT_RT kernels where arch_irq_work_has_interrupt() is true
(x86 with APIC and arm64), irq_work_sync() only spins on IRQ_WORK_BUSY
without an RCU grace period.  Because sdei_unregister_ghes() also skips
synchronize_rcu(), ghes_remove() can free struct ghes during ghes_do_proc():

CPU0                     CPU1                       CPU2
                         irq_work_single()
                           clear IRQ_WORK_PENDING
                           ghes_proc_in_irq()
                             pop ghes_A node
                                                    irq_work_queue()
                                                    irq_work_single()
                                                      clear IRQ_WORK_PENDING
                                                      ghes_proc_in_irq()
                                                      clear IRQ_WORK_BUSY
ghes_remove(ghes_A)
  irq_work_sync()
    /* BUSY == 0 */
  ghes_fini(ghes_A)
  kfree(ghes_A)
                             ghes_do_proc(ghes_A)
                               <-- use-after-free

Calling synchronize_rcu() after irq_work_sync(&ghes_proc_irq_work) would
wait for any in-flight ghes_proc_in_irq() to complete, since irq_work runs
with IRQs disabled on !CONFIG_PREEMPT_RT and in an RCU read-side critical
section on CONFIG_PREEMPT_RT.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-topics-ahmtib01-ras_ffh_arm_internal_review-v8-0-157aac88560b@arm.com?part=4

  reply	other threads:[~2026-12-03 14:00 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 13:40 [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 01/22] ACPI: APEI: GHES: wait for RCU readers before unmapping Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 02/22] EDAC: ghes: avoid traversing the GHES device list Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 03/22] ACPI: APEI: GHES: track error status pool allocation size Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 04/22] ACPI: APEI: GHES: drain deferred work before freeing a source Ahmed Tiba
2026-12-03 14:00   ` sashiko-bot [this message]
2026-12-03 13:40 ` [PATCH v8 05/22] ACPI: APEI: GHES: apply read-acknowledge masks directly Ahmed Tiba
2026-12-03 13:58   ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 06/22] ACPI: APEI: GHES: revalidate the error status length after copying Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 07/22] ACPI: APEI: GHES: free an estatus cache entry when no slot is found Ahmed Tiba
2026-12-03 13:53   ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 08/22] efi/cper: include architecture ACPI declarations directly Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 09/22] ACPI: APEI: GHES: allow the error status pool to be extended Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 10/22] ACPI: APEI: GHES: keep task work valid through error reporting Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 11/22] ACPI: APEI: GHES: reset FRU metadata for each CPER section Ahmed Tiba
2026-12-03 13:54   ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 12/22] efi/cper: validate the remaining length before reading a section Ahmed Tiba
2026-12-03 13:52   ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 13/22] ACPI: APEI: GHES: share macros via a private header Ahmed Tiba
2026-12-03 14:00   ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 14/22] ACPI: APEI: GHES: move CPER read helpers Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 15/22] ACPI: APEI: GHES: move GHESv2 ack and alloc helpers Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 16/22] ACPI: APEI: GHES: move estatus cache helpers Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 17/22] ACPI: APEI: GHES: move vendor record helpers Ahmed Tiba
2026-12-03 14:04   ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 18/22] ACPI: APEI: GHES: move CXL CPER helpers Ahmed Tiba
2026-12-03 14:09   ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 19/22] ACPI: APEI: introduce GHES CPER helper configuration Ahmed Tiba
2026-12-03 14:19   ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 20/22] ACPI: APEI: share GHES CPER helpers Ahmed Tiba
2026-12-03 14:23   ` sashiko-bot
2026-12-03 13:40 ` [PATCH v8 21/22] dt-bindings: firmware: add arm,ras-cper Ahmed Tiba
2026-12-03 13:40 ` [PATCH v8 22/22] RAS: add firmware-first CPER provider Ahmed Tiba
2026-12-03 14:28   ` sashiko-bot
2026-12-05  9:54   ` kernel test robot
2026-12-05  9:54   ` kernel test robot
2026-12-03 14:28 ` [PATCH v8 00/22] ACPI: APEI: share GHES CPER helpers and add DT FFH provider sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-247911@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ahmed.tiba@arm.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.