From nobody Thu Sep 18 03:58:51 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07C4CC4332F for ; Sat, 10 Dec 2022 00:11:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229876AbiLJALD (ORCPT ); Fri, 9 Dec 2022 19:11:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229470AbiLJALA (ORCPT ); Fri, 9 Dec 2022 19:11:00 -0500 Received: from nautica.notk.org (nautica.notk.org [91.121.71.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7D3430F7F for ; Fri, 9 Dec 2022 16:10:58 -0800 (PST) Received: by nautica.notk.org (Postfix, from userid 108) id AD31DC01B; Sat, 10 Dec 2022 01:11:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1670631067; bh=HyFR8xSzRUqVUlavgT48EJ0ZVGK/uZU9vO4AzilxacY=; h=From:To:Cc:Subject:Date:From; b=ripLB6FSl1Bmq/LE0nufGTv/HavizAqpw2unUao7R6KQeDmBLo8GB0b+YIqjNKC8d IutrWk/aOL2SpRYc/jOimr2kFQc81MPr34AIuIGh6BvMfotO9THbNxF6BO7M523mtT r/5NpZF05pVFzmEL9lYlDP79bzUkPmx/3941oZ0q3mQm2Qt3Z9nP0XKZj0YsK3gyi9 dzRzt3oWA9WL41q8O3r0btW28xJdAR4JMLX2aPDp9s4mU29gn1aeeADbTtMEHW8qkC oZzhsEmZGJKhFbsK2VRarstSlxU+gxhxfgUs+aNlVLQaciwtBIuINexy6N07DMV4uM 6CSDhOOTSOPeQ== Received: from odin.codewreck.org (localhost [127.0.0.1]) by nautica.notk.org (Postfix) with ESMTPS id 7E094C01B; Sat, 10 Dec 2022 01:11:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1670631067; bh=HyFR8xSzRUqVUlavgT48EJ0ZVGK/uZU9vO4AzilxacY=; h=From:To:Cc:Subject:Date:From; b=ripLB6FSl1Bmq/LE0nufGTv/HavizAqpw2unUao7R6KQeDmBLo8GB0b+YIqjNKC8d IutrWk/aOL2SpRYc/jOimr2kFQc81MPr34AIuIGh6BvMfotO9THbNxF6BO7M523mtT r/5NpZF05pVFzmEL9lYlDP79bzUkPmx/3941oZ0q3mQm2Qt3Z9nP0XKZj0YsK3gyi9 dzRzt3oWA9WL41q8O3r0btW28xJdAR4JMLX2aPDp9s4mU29gn1aeeADbTtMEHW8qkC oZzhsEmZGJKhFbsK2VRarstSlxU+gxhxfgUs+aNlVLQaciwtBIuINexy6N07DMV4uM 6CSDhOOTSOPeQ== Received: from localhost (odin.codewreck.org [local]) by odin.codewreck.org (OpenSMTPD) with ESMTPA id 19dbb211; Sat, 10 Dec 2022 00:10:51 +0000 (UTC) From: Dominique Martinet To: Christian Schoenebeck Cc: v9fs-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, Marco Elver , Dominique Martinet Subject: [PATCH] 9p/virtio: add a read barrier in p9_virtio_zc_request Date: Sat, 10 Dec 2022 09:10:44 +0900 Message-Id: <20221210001044.534859-1-asmadeus@codewreck.org> X-Mailer: git-send-email 2.38.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The request receiving thread writes into request then marks the request valid in p9_client_cb by setting status after a write barrier. p9_virtio_zc_request must like p9_client_rpc issue a read barrier after getting notified of the new request status before reading other request files. (This has been noticed while fixing the usage of READ/WRITE_ONCE macros for request status) Link: https://lkml.kernel.org/r/167052961.MU3OA6Uzks@silver Reported-by: Christian Schoenebeck Signed-off-by: Dominique Martinet Reviewed-by: Christian Schoenebeck --- net/9p/trans_virtio.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index 3c27ffb781e3..98425c63b3c3 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c @@ -533,6 +533,12 @@ p9_virtio_zc_request(struct p9_client *client, struct = p9_req_t *req, p9_debug(P9_DEBUG_TRANS, "virtio request kicked\n"); err =3D wait_event_killable(req->wq, READ_ONCE(req->status) >=3D REQ_STATUS_RCVD); + + /* Make sure our req is coherent with regard to updates in other + * threads - echoes to wmb() in the callback like p9_client_rpc + */ + smp_rmb(); + // RERROR needs reply (=3D=3D error string) in static data if (READ_ONCE(req->status) =3D=3D REQ_STATUS_RCVD && unlikely(req->rc.sdata[4] =3D=3D P9_RERROR)) --=20 2.38.1