From: Paolo Abeni <pabeni@redhat.com>
To: "Nikhil P. Rao" <nikhil.rao@amd.com>, netdev@vger.kernel.org
Cc: kuba@kernel.org, brett.creeley@amd.com, eric.joyner@amd.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com
Subject: Re: [PATCH net v2 2/2] pds_core: fix use-after-free on workqueue during remove
Date: Thu, 2 Jul 2026 10:13:04 +0200 [thread overview]
Message-ID: <11c0ee2b-96ff-4e27-8688-485dc4605f58@redhat.com> (raw)
In-Reply-To: <20260629200358.2626129-3-nikhil.rao@amd.com>
On 6/29/26 10:03 PM, Nikhil P. Rao wrote:
> In pdsc_remove(), the workqueue is destroyed before pdsc_teardown()
> is called. This ordering allows two paths to queue work on the
> destroyed workqueue:
>
> 1. If pdsc_teardown() -> pdsc_devcmd_reset() times out, the error
> path in pdsc_devcmd_locked() queues health_work.
>
> 2. A NotifyQ event can trigger the ISR and queue work before free_irq()
> is called in pdsc_teardown().
I think this should be 2 separate patches.
> @@ -121,10 +122,16 @@ void pdsc_process_adminq(struct pdsc_qcq *qcq)
> qcq->accum_work += aq_work;
>
> credits:
> - /* Return the interrupt credits, one for each completion */
> - pds_core_intr_credits(&pdsc->intr_ctrl[qcq->intx],
> - nq_work + aq_work,
> - PDS_CORE_INTR_CRED_REARM);
> + /* Return the interrupt credits, one for each completion.
> + * Use READ_ONCE to get a single consistent copy of intx since it can
> + * be set to PDS_CORE_INTR_INDEX_NOT_ASSIGNED concurrently during
> + * teardown, and skip the credits if so.
> + */
> + intx = READ_ONCE(qcq->intx);
> + if (intx != PDS_CORE_INTR_INDEX_NOT_ASSIGNED)
> + pds_core_intr_credits(&pdsc->intr_ctrl[intx],
> + nq_work + aq_work,
> + PDS_CORE_INTR_CRED_REARM);
AFAICS this does not look safe.
A concurrent pdsc_qcq_free()/pdsc_qcq_intr_free() may free
`pdsc->intr_ctrl` before setting PDS_CORE_INTR_INDEX_NOT_ASSIGNED.
I think the teardown should:
- disable the IRQ
- cancel the work
- free the structs
in the above sequence.
/P
prev parent reply other threads:[~2026-07-02 8:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 20:03 [PATCH net v2 0/2] pds_core: fix use-after-free on workqueue during remove Nikhil P. Rao
2026-06-29 20:03 ` [PATCH net v2 1/2] pds_core: fix deadlock between reset thread and remove Nikhil P. Rao
2026-06-29 21:30 ` Harshitha Ramamurthy
2026-06-29 20:03 ` [PATCH net v2 2/2] pds_core: fix use-after-free on workqueue during remove Nikhil P. Rao
2026-06-29 21:32 ` Harshitha Ramamurthy
2026-06-29 23:42 ` Rao, Nikhil
2026-07-02 8:13 ` Paolo Abeni [this message]
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=11c0ee2b-96ff-4e27-8688-485dc4605f58@redhat.com \
--to=pabeni@redhat.com \
--cc=andrew+netdev@lunn.ch \
--cc=brett.creeley@amd.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.joyner@amd.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nikhil.rao@amd.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox