From patchwork Thu Nov 28 18:53:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13888299 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 31427D70DED for ; Thu, 28 Nov 2024 19:38:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGkL9-00061t-5P; Thu, 28 Nov 2024 14:38:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGkL7-00061J-Ga; Thu, 28 Nov 2024 14:38:13 -0500 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGkL6-0001jj-2R; Thu, 28 Nov 2024 14:38:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=WpNnfdMSmJ9VqxtVLFQyTz3SmuQbK7pH3Ndcci69wQ8=; b=Puspp OSMc4T3ovGoUq6/SNFfkbDTtXdwbzJGMvW6NVI2guEmwpcYQuArs+hfvsk//vCJR3NcRvpOKSTI6V PPuPtDEg8EjO5TPZx/5QYjSYIG6PX2Txqda5wZK9qzOtXV/C1YHJqZBTzMSpC+Mx+0g+Nkz5oXjBk MivrIS0poeVr3ydStFZjqhcwxH0dSy1EUmW1o+mfYtrikgzZytx0M8JnDE+gwbutSP4ojiEJD9e8c lWIvbV2yKWy0FepHd/spujSuvLDqrS7aihdsGZ+Yw49ZkJmi4itaVAC+usF5xP881Pnydu7PGUwbe LBwnxW2c2lZN3gSXVkwr0UMYPzVtyB/Y2lqqjBaYGju29SefG/FYzXquU6AEAb3OP1InB+DqLV0KP hIWOcjNF2ec7bHLVvrq+ovkbuBquq55c2jHzAlEz8klzywXLMgV08ZHdGI/k0HEG8Pdbnm92dPZ7n zP4O+asNR1nlVpMcqaJdvHdnQb/VyHAv8t+2pqruTndmElHpQ7o/b+ObL0QwQT6vjy/CQpSwP1Fgq AsS3tnvOUJfUWVYxB1UgeBxO+MIcU3gRvkhhsDjbYIDgjYC/9CDN5dCAIKxTL07blhq3BBQIXEofv BQuI5dDqBvPtFo2AdRQL1nMn6qWmxeg3cbqJHAY48meNMRwvb8KmuuxxGos2LQ=; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 28 Nov 2024 19:53:58 +0100 Subject: [PULL for-9.2 1/7] 9pfs: cleanup V9fsFidState To: qemu-devel@nongnu.org, Peter Maydell Cc: qemu-stable@nongnu.org, Greg Kurz Received-SPF: pass client-ip=5.189.157.229; envelope-from=f2db23ede5b3015330c2314f796dd694f35c7508@kylie.crudebyte.com; helo=kylie.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Drop V9fsFidState's 'next' member, which is no longer used since: f5265c8f917e ('9pfs: use GHashTable for fid table') Fixes: f5265c8f917e ('9pfs: use GHashTable for fid table') Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: --- hw/9pfs/9p.h | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index a6f59abccb..5e041e1f60 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -280,7 +280,6 @@ struct V9fsFidState { uid_t uid; int ref; bool clunked; - QSIMPLEQ_ENTRY(V9fsFidState) next; QSLIST_ENTRY(V9fsFidState) reclaim_next; }; From patchwork Thu Nov 28 18:53:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13888306 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 865ABD70DEB for ; Thu, 28 Nov 2024 19:39:47 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGkL0-0005yQ-Qg; Thu, 28 Nov 2024 14:38:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <462db8fb1d405391b83a0d3099fdb9bfb85c2d92@kylie.crudebyte.com>) id 1tGkKy-0005qT-1R; Thu, 28 Nov 2024 14:38:04 -0500 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <462db8fb1d405391b83a0d3099fdb9bfb85c2d92@kylie.crudebyte.com>) id 1tGkKw-0001ft-Il; Thu, 28 Nov 2024 14:38:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=pI02vUEzLaL6hvgao20/kKv0iB3ubx0RrXQPy8qFfY4=; b=VCkWL qsn/H3aD2SJJeGxqDzkuzCq6n/CZRPvFPAQ+FEG5z6gIrEw2yJwG9mpVxRRNOOeFUmqOzx1A8vNtZ D5VoUvt8emUDFh2AZW3CcUukImk9ukl9Lypth2TyN1qzo/zaRx355yiaI317ht6wTE2xI93qNqy9m iN148WX6QnUbgEtMyaTjitbuC02UFju+nUgghOSvnYZj81mo4fFKbUJspxi8umI0L+mc/mQjdGaG9 unXaU4VavSDo1e/p0fXBrHHMJ/o3uHifU0yiV7RHOqfzTM+4FGWN5vuqMAbXJKBlCEzVCdlNT5H5n InsODab0xp6i0IoL9bSzACYG3XFL6d40KBaN0AV9ouGnNza2EC9CDwXVBmlgVQ5IrHwy8WJBJ/GfX xOXrNt5aVuXyXVreUChgi5v2gwS7j4hAklqEofLc9KfafaIUbJvT9g+yqt9wg0IKmi6C5Hc5VqdGe CfLVPoN0sGPTml6+l3JTuiwn2QRXCI+lWlV2UrxUjXWg4Sk8YsThqTVAj5oV9f6lZPrNfgfDcOHb2 1XixKVXI+Ba2jaWB2RhD5jSx14txVnILyEhCqZG1mgVgYipRanCFtCNN0jWhSvbGYlaPA4Cb1ECtW wiDUChkCtgjkoJk/g25HrPRHVErRVMXjxTd1V2n/uSx5SQGn5l6sz+yOGQuJfY=; Message-Id: <462db8fb1d405391b83a0d3099fdb9bfb85c2d92.1732820037.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 28 Nov 2024 19:53:58 +0100 Subject: [PULL for-9.2 2/7] tests/9p: add 'use-after-unlink' test To: qemu-devel@nongnu.org, Peter Maydell Cc: qemu-stable@nongnu.org, Greg Kurz Received-SPF: pass client-ip=5.189.157.229; envelope-from=462db8fb1d405391b83a0d3099fdb9bfb85c2d92@kylie.crudebyte.com; helo=kylie.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org After removing a file from the file system, we should still be able to work with the file if we already had it open before removal. As a first step we verify that it is possible to write to an unlinked file, as this is what already works. This test is extended later on after having fixed other use cases after unlink that are not working yet. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: <3d6449d4df25bcdd3e807eff169f46f1385e5257.1732465720.git.qemu_oss@crudebyte.com> --- tests/qtest/virtio-9p-test.c | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 3c8cd235cf..f6d7400a87 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -693,6 +693,45 @@ static void fs_unlinkat_hardlink(void *obj, void *data, g_assert(stat(real_file, &st_real) == 0); } +static void fs_use_after_unlink(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QVirtio9P *v9p = obj; + v9fs_set_allocator(t_alloc); + static const uint32_t write_count = P9_MAX_SIZE / 2; + g_autofree char *real_file = virtio_9p_test_path("09/doa_file"); + g_autofree char *buf = g_malloc0(write_count); + struct stat st_file; + uint32_t fid_file; + uint32_t count; + + tattach({ .client = v9p }); + + /* create a file "09/doa_file" and make sure it exists and is regular */ + tmkdir({ .client = v9p, .atPath = "/", .name = "09" }); + tlcreate({ .client = v9p, .atPath = "09", .name = "doa_file" }); + g_assert(stat(real_file, &st_file) == 0); + g_assert((st_file.st_mode & S_IFMT) == S_IFREG); + + /* request a FID for that regular file that we can work with next */ + fid_file = twalk({ + .client = v9p, .fid = 0, .path = "09/doa_file" + }).newfid; + g_assert(fid_file != 0); + + /* now first open the file in write mode before ... */ + tlopen({ .client = v9p, .fid = fid_file, .flags = O_WRONLY }); + /* ... removing the file from file system */ + tunlinkat({ .client = v9p, .atPath = "09", .name = "doa_file" }); + + /* file is removed, but we still have it open, so this should succeed */ + count = twrite({ + .client = v9p, .fid = fid_file, .offset = 0, .count = write_count, + .data = buf + }).count; + g_assert_cmpint(count, ==, write_count); +} + static void cleanup_9p_local_driver(void *data) { /* remove previously created test dir when test is completed */ @@ -758,6 +797,8 @@ static void register_virtio_9p_test(void) qos_add_test("local/hardlink_file", "virtio-9p", fs_hardlink_file, &opts); qos_add_test("local/unlinkat_hardlink", "virtio-9p", fs_unlinkat_hardlink, &opts); + qos_add_test("local/use_after_unlink", "virtio-9p", fs_use_after_unlink, + &opts); } libqos_init(register_virtio_9p_test); From patchwork Thu Nov 28 18:53:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13888304 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3847CD70DEE for ; Thu, 28 Nov 2024 19:39:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGkL6-00060a-Ib; Thu, 28 Nov 2024 14:38:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGkL4-000609-F0; Thu, 28 Nov 2024 14:38:10 -0500 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGkL3-0001i5-4a; Thu, 28 Nov 2024 14:38:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=Qk5/KF/1vF+ZSw5b8p5vFLsVZz9aE1CGi3a3hyOPSlM=; b=d5Nym Df9Qb+BBRe7hgedaCSn2W1Hn8fSdtkCjYYjUak9RMvmsqfoXUo2mWMj6V2cc7ctIn4/HJkcszVd/k HLUP6YduSTFeQGJnxxv1NWcKfYujqfUgNMVH67lYgP/YmMSMshEekwT6srq3SwTnVCB0dWygDfYPl qiRY9nBEqdo+oENR7wfTr29a1FdaGSXhIAxXfqvJqawu4U97qh55Wb2L9ZX6aVg0U7jit/J+T2aNR yRaSUVt3H6dO8T7fWt0eZpC/rohXn7HUIgfj6ZL3ZCpPVPJivxtQXwhpTPAIVyKr3I79zBzvmFU4U s3RwI16eiGNBKBP/Ji7adHpJItULe+lvIRT1ckCTaIVCI2AjDpJTnJrGOulR3LQy3e2bxYkQikWe2 AlZ4YVV5ZVgSDGYwAktGKysxRqaj+HOlyaZjzIVH92fLXCzatOvRx0AbC59l57wq5YcUmAomhP04g ZYID4xxwd7tGxzCVIhz2LmnSPXEVZ2kXBVjo7Qq1EAE4FYgDogr94ReLbhso+sIZNtwrOoK8h51D8 oxH8nVIr8TD6LjXK9WWY4PY1s41QBeH0nvIUiQ6Prwd8QZj9ryYORF/mvDsFYvQvCDUc0RiUKWxjw ZKsjgE86G5GGoOG1WnuNDhsHHiCsjLSS9T+g+HGW98gR9El3LhHZgaWjHk09VE=; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 28 Nov 2024 19:53:58 +0100 Subject: [PULL for-9.2 3/7] tests/9p: fix Rreaddir response name To: qemu-devel@nongnu.org, Peter Maydell Cc: qemu-stable@nongnu.org, Greg Kurz Received-SPF: pass client-ip=5.189.157.229; envelope-from=abf0f092c1dd33b9ffa986c6924addc0a9c1d0b8@kylie.crudebyte.com; helo=kylie.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org All 9p response types are prefixed with an "R", therefore fix "READDIR" -> "RREADDIR" in function rmessage_name(). Fixes: 4829469fd9ff ("tests/virtio-9p: added readdir test") Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: --- tests/qtest/libqos/virtio-9p-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qtest/libqos/virtio-9p-client.c b/tests/qtest/libqos/virtio-9p-client.c index b8adc8d4b9..c61632fcd3 100644 --- a/tests/qtest/libqos/virtio-9p-client.c +++ b/tests/qtest/libqos/virtio-9p-client.c @@ -238,7 +238,7 @@ static const char *rmessage_name(uint8_t id) id == P9_RLINK ? "RLINK" : id == P9_RUNLINKAT ? "RUNLINKAT" : id == P9_RFLUSH ? "RFLUSH" : - id == P9_RREADDIR ? "READDIR" : + id == P9_RREADDIR ? "RREADDIR" : ""; } From patchwork Thu Nov 28 18:53:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13888300 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 34FD6D70DEF for ; Thu, 28 Nov 2024 19:38:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGkKx-0005pE-PS; Thu, 28 Nov 2024 14:38:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <4ec984965079b51a9afce339af75edea6de973a2@kylie.crudebyte.com>) id 1tGkKm-0005jz-PP; Thu, 28 Nov 2024 14:37:54 -0500 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <4ec984965079b51a9afce339af75edea6de973a2@kylie.crudebyte.com>) id 1tGkKl-0001VB-0V; Thu, 28 Nov 2024 14:37:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=70oy+zIhcKqU3nbM95roDK6p30oLfuPq18fgj+sPGlc=; b=nMj0Z HxYrcgTBnv5/lwX0zcTNSbYYyDyk/SKyJ9hEMfosmWMbwk1TDmqD4wI4pYMCmoR3AoeEXNJ33Hz// wbPMfdBLIuTJlu84IHoHSLXEgLwH296+6AHRDf0hOLBNk554P5deAif0jKU4je/JZYNM+ft/N/b16 E/Hq4O6OrgTpvtQPd8uQjmd+etOYCXHb3W2tsZMFooRKU/3vepZ81jDTO2fOF/8vO7Aue9TztQ6UN I8SnX7iTVqqqZZCmtO8N88yV/zuanmo8oE8l+JLRUmMRxlVA6uun4GusbnWTIXFID5U7d89qzJUV+ hChjyT1xvE+aKW/4iUS5CSJHbCY1ID/dy3xd/cwLcxvbCTksWSwVgRKKqOgUQYyDkbeJNhsTzRkjw I6+L8Ebl0TpOFktMF1FEc1CXyISezh8llbtZl2OJXWJ9WgjEW0xze6VEYUqVFmXggNdlg6lYyj7PP X6/YNznwsOBInSaxkdsk3Q+ETAgzCDJ18w+TmL9fg14tUX70raWEWDPFuTDaU9/fzk9x90Tz+4ucQ LNWAnP1HQcMYXe/4zxcAua0Eb1lAPkEWUuy+b2StpWiJ+fGSDjnZ+0v3agI5CZAdrXdWmhNn8krfo AdnbR5UIKSSlhdL5jhlyS5i4ptaRr6C2EJmevKGpxVOiYMoprUGR7QBJ13eFrA=; Message-Id: <4ec984965079b51a9afce339af75edea6de973a2.1732820037.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 28 Nov 2024 19:53:58 +0100 Subject: [PULL for-9.2 4/7] tests/9p: add missing Rgetattr response name To: qemu-devel@nongnu.org, Peter Maydell Cc: qemu-stable@nongnu.org, Greg Kurz Received-SPF: pass client-ip=5.189.157.229; envelope-from=4ec984965079b51a9afce339af75edea6de973a2@kylie.crudebyte.com; helo=kylie.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org 'Tgetattr' 9p request and its 'Rgetattr' response types are already used by test client, however this response type is yet missing in function rmessage_name(), so add it. Fixes: a6821b828404 ("tests/9pfs: compare QIDs in fs_walk_none() test") Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: --- tests/qtest/libqos/virtio-9p-client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/qtest/libqos/virtio-9p-client.c b/tests/qtest/libqos/virtio-9p-client.c index c61632fcd3..98b77db51d 100644 --- a/tests/qtest/libqos/virtio-9p-client.c +++ b/tests/qtest/libqos/virtio-9p-client.c @@ -235,6 +235,7 @@ static const char *rmessage_name(uint8_t id) id == P9_RMKDIR ? "RMKDIR" : id == P9_RLCREATE ? "RLCREATE" : id == P9_RSYMLINK ? "RSYMLINK" : + id == P9_RGETATTR ? "RGETATTR" : id == P9_RLINK ? "RLINK" : id == P9_RUNLINKAT ? "RUNLINKAT" : id == P9_RFLUSH ? "RFLUSH" : From patchwork Thu Nov 28 18:53:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13888303 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3305DD70DED for ; Thu, 28 Nov 2024 19:39:30 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGkLD-00063Z-Aa; Thu, 28 Nov 2024 14:38:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3bc4db44430f53387d17145bb52b330a830a03fe@kylie.crudebyte.com>) id 1tGkLB-00062q-FI; Thu, 28 Nov 2024 14:38:17 -0500 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3bc4db44430f53387d17145bb52b330a830a03fe@kylie.crudebyte.com>) id 1tGkL9-0001kw-7m; Thu, 28 Nov 2024 14:38:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=yu2+fuCqlPpIhciUDx6LHQqmVm2hltzj+n6lloV1XYU=; b=fSzIY /KyiHI7rv04BqOMYeK0BGdgiAKwOpOmGz9yPEHMDVkGoU4NByf7u30NNmsAO1BC5X5UshHQElfOKy 33NPeubBG5MBhNC76u3Gh/lvvTIVdl8J2VMerVSeZT0Slunld5Elo0YDpogYv34g6svsdebZ1xGGM xFhSBZXOOChQMZAn1QVHJZJKsMX9Z/dlGNpyJa/XyoJ1d/63hbNmHBPtuUI7ogUAvS8b0Teli2mNr 4J9/oB5f5ZxrV6YVTsdpAZ2gmnQ3qK+rf1P49b1WEiW64QUkQL49AYjgqBod1OHCpZYIcXgHWdU5Z rV26EbRK1SdK1UWg/OpYraDZPRUJdG5nzYxa3HpjUoLO9nc75OTtdTBMzaBQLWsrRNDoPqW/b618C IVD1Xt+3syDQShf1dkqkp/0vgOH+/+Mv5owV0Ufj+Wez0jfLIkT8ef8jXZGFyq/YwtzNx+fra+ZIc KFDEalZbFAJ+roskpt3abjsRnIh9SVVrBuOWLvSXfgACg8WHjteZt6GYwIkBUgY7FD1vA3XdV6CB9 ZZAXUlryxwvT3NH7kpIhf/tgfJl0CajGPT86blmV3cAfmoqGXVhr7+5Md70q1l4gc3m3hDxuSOxwk QhK6Auy2RP5F8Sr5BTakJJLDj4oTLBTP/0hr3oUZeeplPySW3kbRaTeDUNDfsM=; Message-Id: <3bc4db44430f53387d17145bb52b330a830a03fe.1732820037.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 28 Nov 2024 19:53:58 +0100 Subject: [PULL for-9.2 5/7] 9pfs: remove obsolete comment in v9fs_getattr() To: qemu-devel@nongnu.org, Peter Maydell Cc: qemu-stable@nongnu.org, Greg Kurz Received-SPF: pass client-ip=5.189.157.229; envelope-from=3bc4db44430f53387d17145bb52b330a830a03fe@kylie.crudebyte.com; helo=kylie.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The comment claims that we'd only support basic Tgetattr fields. This is no longer true, so remove this comment. Fixes: e06a765efbe3 ("hw/9pfs: Add st_gen support in getattr reply") Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: --- hw/9pfs/9p.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 9a291d1b51..851e36b9a1 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1596,10 +1596,6 @@ static void coroutine_fn v9fs_getattr(void *opaque) retval = -ENOENT; goto out_nofid; } - /* - * Currently we only support BASIC fields in stat, so there is no - * need to look at request_mask. - */ retval = v9fs_co_lstat(pdu, &fidp->path, &stbuf); if (retval < 0) { goto out; From patchwork Thu Nov 28 18:53:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13888298 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 33121D70DEE for ; Thu, 28 Nov 2024 19:38:36 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGkKx-0005pU-Qb; Thu, 28 Nov 2024 14:38:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGkKq-0005nh-Ii; Thu, 28 Nov 2024 14:37:57 -0500 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGkKp-0001ai-0Y; Thu, 28 Nov 2024 14:37:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=sZ1E9BcYHFsRPyZxFsRdJMwSjmBFK1SLraoUCBW0/70=; b=ZhMPu j39Ti84RLdDnZat4MKffb/WE/Bq3mYl0pKgav84zVbbWbQ0YobugTZ2sURuvtA42LCbVjU8r2rzLr l/+GT2HOtj9vyiasj4xGmlkr70nlRW25AsHo8X9g3npfcV0HJZhdZpkzNWU8AVIb0cGWUxZW6Ujgb 524Ts9YGl9uhQD7ZX+2LcWHkkFhrdmcl4b5DtjjISff5w5gGMspS4T14cWPDl8ApKpI7DREOqGfsa 2e4szqcS4FgQthRDFU17yLw2iQSBT1M1SAlxBH5nZrGCYAUoptzlS4himyfWa5ut25IOEbT9sTV8e IixA1MbTsMyCviABXd/ySR9zJxUkp5Y0Ll7Q1pR9AJ9Gp4pi73xXiXP3b5GoMummvh3EZ9Dmc5KHb MUhprQG0/mVOUvRei0wB40ALcXCzCjys2inIy8THYc+bAqqBKxy1f9JxP2dXb68/dk5kawS07nidS as+Lbw2zTg490b7Poswf7IUxwUKslCa4XQABX9vTmrEIh8xxbnBEZ+FK4f9qSCJ4FRbVW+Epq/cFj D2Dc33uM6ZqSD55DsgVxtujzsIBhp5f5PeZok9JEUO0bKF8BZC2oosnkbtNdjHByeuJxqvhNGMgpv IIlZxj5IO2Kc40bVxfnzU48qI0IB2jfZQ6qssFDm7kEdjen5aBikNIO6MG4rro=; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 28 Nov 2024 19:53:58 +0100 Subject: [PULL for-9.2 6/7] 9pfs: fix 'Tgetattr' after unlink To: qemu-devel@nongnu.org, Peter Maydell Cc: qemu-stable@nongnu.org, Greg Kurz Received-SPF: pass client-ip=5.189.157.229; envelope-from=c81e7219e0736f80bfd3553676a19e2992cff41d@kylie.crudebyte.com; helo=kylie.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org With a valid file ID (FID) of an open file, it should be possible to send a 'Tgettattr' 9p request and successfully receive a 'Rgetattr' response, even if the file has been removed in the meantime. Currently this would fail with ENOENT. I.e. this fixes the following misbehaviour with a 9p Linux client: open("/home/tst/filename", O_RDWR|O_CREAT|O_EXCL, 0600) = 3 unlink("/home/tst/filename") = 0 fstat(3, 0x23aa1a8) = -1 ENOENT (No such file or directory) Expected results: open("/home/tst/filename", O_RDWR|O_CREAT|O_EXCL, 0600) = 3 unlink("/home/tst/filename") = 0 fstat(3, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0 This is because 9p server is always using a path name based lstat() call which fails as soon as the file got removed. So to fix this, use fstat() whenever we have an open file descriptor already. Fixes: 00ede4c2529b ("virtio-9p: getattr server implementation...") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/103 Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: <4c41ad47f449a5cc8bfa9285743e029080d5f324.1732465720.git.qemu_oss@crudebyte.com> --- hw/9pfs/9p.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 851e36b9a1..578517739a 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1596,7 +1596,13 @@ static void coroutine_fn v9fs_getattr(void *opaque) retval = -ENOENT; goto out_nofid; } - retval = v9fs_co_lstat(pdu, &fidp->path, &stbuf); + if ((fidp->fid_type == P9_FID_FILE && fidp->fs.fd != -1) || + (fidp->fid_type == P9_FID_DIR && fidp->fs.dir.stream)) + { + retval = v9fs_co_fstat(pdu, fidp, &stbuf); + } else { + retval = v9fs_co_lstat(pdu, &fidp->path, &stbuf); + } if (retval < 0) { goto out; } From patchwork Thu Nov 28 18:53:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13888302 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9603AD70DED for ; Thu, 28 Nov 2024 19:39:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGkL0-0005vy-6W; Thu, 28 Nov 2024 14:38:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGkKu-0005pF-Vh; Thu, 28 Nov 2024 14:38:01 -0500 Received: from kylie.crudebyte.com ([5.189.157.229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGkKt-0001e6-6v; Thu, 28 Nov 2024 14:38:00 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=kylie; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=4cxulYeO4NhY3t6U7QERTjOlXT5wKxyH+m3yclIV2gg=; b=UpGd5 9j2M+YyfJKOOJz4NDFXchilnA61SvNOkJ+np2oYtTv/pwemf4yuosqcnk/A078pC2k7ky6wGX/UD/ jUgpUealMDkdLIOz3GWiniuAyEYGTiXwDNH/uIvaocqqZjzg3qmjLMofgMYoJFBQwSAWyzenlpaqg 1kg0np98lJ4xsgKJadnKI/LL2d8xTnu1zP1+k4O+gTAjubKuqDHG6ZqaS22dZc8kHO9DYlICANtEP JZiwVHKtax3bXOLerHhL/4MJtE7PLR7G64aGPUif5trx6d0/Y8eyAtihl83E+CPf0LaHhS115l4Ix b4U8Qg991lAfv2P8AQ6cme86Y1RNBsZN/mXL0/TKfFRrXuZONB9oJYk4EP5hDRdGBOwcD7CQffilC 8/6prVLPcnWioeqfu6CkSweXbmqm7gDUjKF3Mim/bFC0HNJdI3BWmiQpjzJcjTsArqr+X6oa06/jF 0Df8R7ckzs4b0FI51rXJ47NkRPoZ2VyZUz0oTZroQrUNKALUKNUdghaMhyDudqq+TO25uWDu07tUF RYYvX778DO/4OImiqECzjMVlsRPXqeYk2IP00M9lD7wqQO6U97URztj+NsErlJS1/3CqtfUQGSXD2 9yYF4ChIII/C2krmc2Zc+RSZvYHCb6IMaBYLO+g4kFf+RR6U7VulocpBohnoRA=; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 28 Nov 2024 19:53:58 +0100 Subject: [PULL for-9.2 7/7] tests/9p: also check 'Tgetattr' in 'use-after-unlink' test To: qemu-devel@nongnu.org, Peter Maydell Cc: qemu-stable@nongnu.org, Greg Kurz Received-SPF: pass client-ip=5.189.157.229; envelope-from=eaab44ccc59b83d8dff60fca3361a9b98ec7fee6@kylie.crudebyte.com; helo=kylie.crudebyte.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org This verifies expected behaviour of previous bug fix patch. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz Message-Id: <7017658155c517b9665b75333a97c79aa2d4f3df.1732465720.git.qemu_oss@crudebyte.com> --- tests/qtest/virtio-9p-test.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index f6d7400a87..ab3a12c816 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -702,6 +702,7 @@ static void fs_use_after_unlink(void *obj, void *data, g_autofree char *real_file = virtio_9p_test_path("09/doa_file"); g_autofree char *buf = g_malloc0(write_count); struct stat st_file; + struct v9fs_attr attr; uint32_t fid_file; uint32_t count; @@ -725,6 +726,10 @@ static void fs_use_after_unlink(void *obj, void *data, tunlinkat({ .client = v9p, .atPath = "09", .name = "doa_file" }); /* file is removed, but we still have it open, so this should succeed */ + tgetattr({ + .client = v9p, .fid = fid_file, .request_mask = P9_GETATTR_BASIC, + .rgetattr.attr = &attr + }); count = twrite({ .client = v9p, .fid = fid_file, .offset = 0, .count = write_count, .data = buf