]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
9p: Add missing read barrier in virtio zero-copy path
authorGui-Dong Han <hanguidong02@gmail.com>
Fri, 29 May 2026 07:54:41 +0000 (15:54 +0800)
committerDominique Martinet <asmadeus@codewreck.org>
Sun, 21 Jun 2026 05:22:57 +0000 (05:22 +0000)
Commit 2b6e72ed747f ("9P: Add memory barriers to protect request
fields over cb/rpc threads handoff") added a read barrier after
p9_client_rpc() waits for req->status, pairing with the write barrier in
p9_client_cb(). The virtio zero-copy wait path was missed.

Add the same read barrier after the zero-copy wait before reading the
completed request.

Fixes: 2b6e72ed747f ("9P: Add memory barriers to protect request fields over cb/rpc threads handoff")
Signed-off-by: Gui-Dong Han <hanguidong02@gmail.com>
Message-ID: <20260529075441.233369-1-hanguidong02@gmail.com>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
net/9p/trans_virtio.c

index 4cdab7094b273ad9bd90501684f34f5c6187bdcc..b0d0094ec8e2c8dd9f7ce19af77f9379a421e1d4 100644 (file)
@@ -532,6 +532,11 @@ req_retry_pinned:
        p9_debug(P9_DEBUG_TRANS, "virtio request kicked\n");
        err = io_wait_event_killable(req->wq,
                                     READ_ONCE(req->status) >= REQ_STATUS_RCVD);
+       /*
+        * Make sure our req is coherent with regard to updates in other
+        * threads - echoes to wmb() in the callback
+        */
+       smp_rmb();
        // RERROR needs reply (== error string) in static data
        if (READ_ONCE(req->status) == REQ_STATUS_RCVD &&
            unlikely(req->rc.sdata[4] == P9_RERROR))