]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
pds_core: order completion reads after the ownership check
authorNikhil P. Rao <nikhil.rao@amd.com>
Tue, 14 Jul 2026 20:41:45 +0000 (20:41 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 21 Jul 2026 19:45:17 +0000 (12:45 -0700)
pdsc_process_adminq() and pdsc_process_notifyq() decide a completion is
valid from its ownership field - the color bit for the adminq, the event
id for the notifyq - then read the rest of the descriptor, with no
barrier in between.

On a weakly ordered architecture the CPU may read the payload first. Add
dma_rmb() between the ownership read and the payload reads.

Fixes: 7e82a8745b95 ("pds_core: Prevent race issues involving the adminq")
Reported-by: sashiko-bot <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260629200358.2626129-1-nikhil.rao%40amd.com?part=2
Signed-off-by: Nikhil P. Rao <nikhil.rao@amd.com>
Reviewed-by: Eric Joyner <eric.joyner@amd.com>
Link: https://patch.msgid.link/20260714204145.1782390-1-nikhil.rao@amd.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/amd/pds_core/adminq.c

index 097bb092bdb8cd76b5a0185d98373eff72d1c3f9..eadb4b604fbe3c23bf01ec8915094810d6bb0a94 100644 (file)
@@ -18,7 +18,13 @@ static int pdsc_process_notifyq(struct pdsc_qcq *qcq)
        comp = cq_info->comp;
        eid = le64_to_cpu(comp->event.eid);
        while (eid > pdsc->last_eid) {
-               u16 ecode = le16_to_cpu(comp->event.ecode);
+               u16 ecode;
+
+               /* Order the payload read after the event id, the field the
+                * driver uses to detect a new completion.
+                */
+               dma_rmb();
+               ecode = le16_to_cpu(comp->event.ecode);
 
                switch (ecode) {
                case PDS_EVENT_LINK_CHANGE:
@@ -101,6 +107,10 @@ void pdsc_process_adminq(struct pdsc_qcq *qcq)
        spin_lock_irqsave(&pdsc->adminq_lock, irqflags);
        comp = cq->info[cq->tail_idx].comp;
        while (pdsc_color_match(comp->color, cq->done_color)) {
+               /* Order the payload reads after the color bit, the field the
+                * driver uses to detect a new completion.
+                */
+               dma_rmb();
                q_info = &q->info[q->tail_idx];
                q->tail_idx = (q->tail_idx + 1) & (q->num_descs - 1);