From patchwork Wed Feb 21 14:13:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13884161 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 1BC2CD68BFD for ; Sun, 24 Nov 2024 17:08:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFG5O-0003k0-65; Sun, 24 Nov 2024 12:07:50 -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 <3d6449d4df25bcdd3e807eff169f46f1385e5257@kylie.crudebyte.com>) id 1tFG5M-0003jE-64; Sun, 24 Nov 2024 12:07:48 -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 <3d6449d4df25bcdd3e807eff169f46f1385e5257@kylie.crudebyte.com>) id 1tFG5K-0005H3-OB; Sun, 24 Nov 2024 12:07:47 -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=8eE59iENcUdzeUBXiMcAkpaESk28ON3bMfkwrIcP5vg=; b=ibziH B5pI2v95HYySR5Ol7PT/Wrt2Cs4aFtmfrYql1AoEINSg6XqmjV0tiZpWyVFk+1K65WmC1lmkRsL7L xUyss+pRblyGJ5nK8nwqYfzbN9NnA8Ysaw/TznbZAySfPFd67rsBQxZAD5xZlnE1G6ettXp2UBgEX rDkzSB4045qb2kQ8k76WuDaYRM0Ot3lTTj/eWTDZMgnkh7Z2U7uFZWJ9sQBYmShiNCp4YX+bVy5Qx 9LlGbXJektbYYF6K645YMREHeog2ImkeFSf01gB6uU28QOao4LSEUI2bAke6USEzWoMeME+aYftUZ wcKU+7f+ACVCZ+COgY/NN7vilbP8ZQrVpkNHo1IX0+WTFKr+qFqY5NCADKO+ElPjFuVHIEZFDlNZ0 2ndOWenkY/JmBlyduRKiYaTfQpPfwY6vhthad4BqtCP360x/+wNfIbDoH+59K2memUJRSrRRxHQ9J lK7WWTh6Ex6sCfCx0Pka3r9Gyei1/oLjoAdUDcAV3C4DmcGECmwuOwvErDzhfJgoHlY0jj9OvztKy EUntgjyAXw4Ve3WOsH4pQ58FwjFJvhu+PMSbdqYNFPD0kjY6XgGymv3FXDuhU8+8hbEb1dhOoFCBF 5ACtA/Pn0GJ1v66T6bqRmWA8aHvEQisOvjzni5ZFHbpbngqgrNmEs1Jr+3ZVlc=; Message-Id: <3d6449d4df25bcdd3e807eff169f46f1385e5257.1732465720.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Feb 2024 15:13:13 +0100 Subject: [PATCH 1/6] tests/9p: add 'use-after-unlink' test To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Greg Kurz Received-SPF: pass client-ip=5.189.157.229; envelope-from=3d6449d4df25bcdd3e807eff169f46f1385e5257@kylie.crudebyte.com; helo=kylie.crudebyte.com X-Spam_score_int: 13 X-Spam_score: 1.3 X-Spam_bar: + X-Spam_report: (1.3 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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 --- 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 Sun Nov 24 13:34:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13884165 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 407A3D68BF8 for ; Sun, 24 Nov 2024 17:10:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFG5X-0003mG-9D; Sun, 24 Nov 2024 12:07:59 -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 1tFG5V-0003lU-1R; Sun, 24 Nov 2024 12:07: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 1tFG5T-0005Hk-PF; Sun, 24 Nov 2024 12:07: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=AS+IrlCVZDaIn5QIF9PwB79XyCeyEMVXYEcy54dkzfo=; b=TPy5s Itr8he/AZW2lFK/6ejlxJrWl6plsk1ApZuNn1x8yRZjuQbcZtml8On1nVoD8NFotze2EuGmBf5muX bVLtv7Wxut2azHtLWRWXHTeCWA6RyvPxV0pR6V+pakW4oIHxvflRoKR0jvwRiCOSRdFVQMxBPolP6 ObkbspujDvAMZgMJB8s7sUvDUs8Gg6HTAA282Ob5TyWcMcJ4wDAbI4GEgCOXq0aoXAx+/f8Y9oi/K fmbrbftIoflswanEJRMjr0rNMDmGvdmra7dDVNfq3hGSXX04CrGrinsYMd1d4kRTMWtCDJaYH3KJf Exv1CHl+12DV+Ab6DKmPICqnQyQrP6raE5etW1u/X61I9RdgJLQHlhaAG9DE4wu1pLif3cn2OCs/V i26m0e9cg6vo92K4UlY7YB4By+XcmFtL/8WuBbN5LqBJikNO3BlY7wWK0451tdr0oM9qQEIdOEuos V+SPVtR5ol8rgk3jRCPsTEaHu2ASigbRo4y3kl/ZE9AaTAKriSgjh2rvkDRwY5qLpGpN8KeHmM2M0 fYyAYMfrrmFc+YxCs06sAGRmkbSDW7UpYiVgC6TxqRINTC2/GjaU5cWEIhsevsZLgpqDPQCVr84Xt SMMA08eBiUHcXgMYs03PmQlQCZXeQ8fHTNskitF3KjJ++T36FA6HAHpFVQUbKg=; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 24 Nov 2024 14:34:31 +0100 Subject: [PATCH 2/6] tests/9p: fix Rreaddir response name To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Greg Kurz Received-SPF: pass client-ip=5.189.157.229; envelope-from=daad7af58b403aaa2487c566032beca36664b30e@kylie.crudebyte.com; helo=kylie.crudebyte.com X-Spam_score_int: -4 X-Spam_score: -0.5 X-Spam_bar: / X-Spam_report: (-0.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_03_06=1.592, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no 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(). Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- 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 Sun Nov 24 14:49:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13884164 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 A752FE668BC for ; Sun, 24 Nov 2024 17:09:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFG5K-0003if-AV; Sun, 24 Nov 2024 12:07:46 -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 1tFG5J-0003iS-3Q; Sun, 24 Nov 2024 12:07:45 -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 1tFG5H-0005Gg-Bk; Sun, 24 Nov 2024 12:07:44 -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=NTS/m9q0lUtbEO9KOENkH2r7ycV71tXpqWTqX6H4Evg=; b=tTsC1 YP7nGEshAs4GVfYC8xbsUEuK/Q0X5/FQmpCXT6Z7qYTegul4moU4xJ1LWUxJA4HZerbT2nVn6XjHR KhH4oN/lQ62ScthNK0YwSjNIIiqz8Q19RwD68Z2AgcJo8BbUAr6TqW+mp+gAeUG3LHOGHYcGFdbe3 SIFIsaOvlSGHYItVslQRO9s/0v7w3+bddtDUGFayhl5ZL8q5kQ0XVlEJ45lMUQlxLBkrEaOMy3FK3 E5dhT/qP18v73DX510Jwomnu0U9PUg8qVxf1P83n6arJRnh/6gHBPKHWfdxzS+IfgvFpUPHFjbOlP cAWO7gbMiMk1SfFI6jkRKSyCibCCsXuPoQPRgjFgwmDWdcSviQ1bQhnWFuYdUpCAc9nppDOuUmka+ /eTcMW+V/S7Zu2hadMBohi1yek3Tn7KL9n2gS6V7WBaF4nKFHqhIVPsq5Ed7FdTdV7cXH9z5O9iEe SBmxFY3VR4n2v++58p5YtrlKkQlxRuggD1YEVv/pcJdEQvy5P8rZAVOGO4cEHDnxxZZ+f6cquFZ2Z k33qDKkSVw1/Hzi94RaLRx0AbcRy0jy9VDMXi28J9rVXU+eGDc165xH2O9o2/lVUmu1PZapucCGMF f1z0ufuXeWuazXWeiSGHSDcj7eSfIAUJ+IcK1GMJEr9qn4Qr6Ctuutx1zpXiU4=; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 24 Nov 2024 15:49:55 +0100 Subject: [PATCH 3/6] tests/9p: add missing Rgetattr response name To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Greg Kurz Received-SPF: pass client-ip=5.189.157.229; envelope-from=e183da80d390cfd7d55bdbce92f0ff6e3e5cdced@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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- 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 Sun Nov 24 15:06:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13884159 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 78E9FE668BC for ; Sun, 24 Nov 2024 17:08:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFG5T-0003kd-0J; Sun, 24 Nov 2024 12:07:55 -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 1tFG5P-0003k3-0I; Sun, 24 Nov 2024 12:07:51 -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 1tFG5N-0005HK-NJ; Sun, 24 Nov 2024 12:07:50 -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=bglsoUlhCRKaokV268JNEiCI901dRlYpBAqwZbBilN0=; b=cLr+C deHGt8YAEOCN+xPUP9rvyPapIQL3OmgOkTcvBVChfV48Is7JKjxnXuUVEewnBokb9ZDCtx/UbkhRi mrAborIfqadnM09cRE+LdniuP1bXhKkJMVmPC4vDsoSBPPwhVsagcoeo5w/Hg9tLqvbQiXfsFNgt6 9kNKyaU1/cCPMmn+dde10GAxaWpcnUALQ2F9gicNIWNrT1F01lC2gLRhE+++IWAoDHXMPsFEL15w1 JYYYRhJVrNJqSE2HC1vMnZA8OkOu1GKx/ldJzEtNZT5iwVGzAOC1QRtMGXiFlHogYQ0eAOi0wGCZU TMTae9FW/Iglf52ockEfifix1KlLx0jH1v8bRVgSTV87DxS8AZY8sUqdj4kwH65pKXa0XXRpjFf3f gG7Ui93ICZ6ZYIJ7R5TIkTNcBsJmMdNvqf4qt7PqElVzH9g+kk3OKHrIvZXZ81fXofJHABwZgNtPC wg39P+teRA0v3Y9rLy1poxjR4bx2mbd5ou9+N2BYmbWnbLBtbls/qAJeqhrWBLsiAhDIOF+0mzIzB LBKFDjUDPF3Ilpqm97huz13mL2myVqei7B7UUNj0xrsf98pIaOpRruyL0+ixiaTg+bNPiRl8EHeAd WGzecWU5iPsigdAi/jvkcUv+trw76EvGfbwAA1tVN9rN736GwyFFWKjB6lKANs=; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 24 Nov 2024 16:06:40 +0100 Subject: [PATCH 4/6] 9pfs: remove obsolete comment in v9fs_getattr() To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Greg Kurz Received-SPF: pass client-ip=5.189.157.229; envelope-from=fb364d12045217a4c6ccd0dd6368103ddb80698b@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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- 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 Sun Nov 24 15:50:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13884160 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 7BDBDD68BF8 for ; Sun, 24 Nov 2024 17:08:27 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFG5T-0003kf-M8; Sun, 24 Nov 2024 12:07:55 -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 <4c41ad47f449a5cc8bfa9285743e029080d5f324@kylie.crudebyte.com>) id 1tFG5S-0003kN-2y; Sun, 24 Nov 2024 12:07: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 <4c41ad47f449a5cc8bfa9285743e029080d5f324@kylie.crudebyte.com>) id 1tFG5Q-0005HX-Jh; Sun, 24 Nov 2024 12:07:53 -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=JUlu1jwF1AFo/JL219ofOcoYRnKg7uQEG0oLsTvCOO8=; b=oynSg TTv64ToyAm5Ctu0iXWqCRkp4BsWvn4Dg92QPX1maziDPRBOVleLaXgofH6Be2tgBCOQM0h/YnXUWT dhCxUtsDBYUaid1rQ1+jHu5uB3mOY3oDqIFTfCYWnmyyxEon0y2Z63W6MAEJc+e52AgO1P8BOL2XL DUvY4dncSj9w7mq8D/lffJ1Ruy3kx6BYH9/KAovJOK1/B5ZY5mB+tYiKbdblhiBD3iZSuw4JfFdFN RsBb1zOjXj5ue/rq6GHtnzFgfanGNuYgC9yyu9F/O3iaI0zJslNOKIvYoYQE7YfAhfZYCzpbdAU0N aP+Btz4YyBY/j0hIGoB7OeCeQo2Fj3vDdskT/Ghg8lDzsF3fri5hsmEMf76knr1CgbpUfqoxhwS4z uRWBIcjHyoUN+l/ofVoA/yGVNmR+UA/CmQCpJkMLSDGESOPE5W5LDFYzUrwTnFyWoYKkhTdBGg0AZ xi887yCj3QH8aVSafpOw6l32xkYNUpGNtfkbKbEKAEzdV8Ily0iEVuunBWgX96AZ3H3h1cwJ2vFoM 1rmHd0BEfqxq88+CRBuUlHYBHCQK9AT+zNO4UMTVLtz/XzL5WrC7RFln3zWfQUDd9FIZP9GtRRiZA 0qHnomh9vB6SkDG4voP1nQftRQt8DupOgFYdPacU9yehyR1swEzyLNrwE5C9kw=; Message-Id: <4c41ad47f449a5cc8bfa9285743e029080d5f324.1732465720.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 24 Nov 2024 16:50:03 +0100 Subject: [PATCH 5/6] 9pfs: fix 'Tgetattr' after unlink To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Greg Kurz Received-SPF: pass client-ip=5.189.157.229; envelope-from=4c41ad47f449a5cc8bfa9285743e029080d5f324@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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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 stat() call which fails as soon as the file got removed. So to fix this, use fstat() whenever we have an open file descriptor already. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/103 Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- 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 Sun Nov 24 16:05:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Schoenebeck X-Patchwork-Id: 13884162 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 97ADCE668BC for ; Sun, 24 Nov 2024 17:09:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tFG5o-0003oK-21; Sun, 24 Nov 2024 12:08:18 -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 <7017658155c517b9665b75333a97c79aa2d4f3df@kylie.crudebyte.com>) id 1tFG5c-0003nI-27; Sun, 24 Nov 2024 12:08:05 -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 <7017658155c517b9665b75333a97c79aa2d4f3df@kylie.crudebyte.com>) id 1tFG5a-0005I8-OK; Sun, 24 Nov 2024 12:08: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=B88aiuakURSSwHg4O7Ir3dYxYVHzQIe08g+J0gXncyE=; b=cKVyV d6xjcKdfOTkke6ROc+bab+X+OEQvghR2qkIF0jHBoJSMPxj1sXIBnWnMF0u8HE2UzE+oTPmdemsv0 dQCeC3q1QOleZ27AP0CBr7b/tXY3q77Zqf1KKddib/wMe+fcD88rOjlkWAMIXzFxHMILNRPQojsve OnYrUiF+w6wj+yvUyHPUceyJab8UgNfF7FXnhmlJospAO54Szuciq8cQVIzLMyyB8Nt6VJM9vLc2+ BXvVhHOGYqOp4DSJBU6OAXhB+KSKVQ8WIrVQ56L2MBLMFSiKof43/JxvcY9sl9R2lz1osyac7qJhz 79qRPsViD7HiB0c8ATzQo0ryXe53dCRXaIlO13r0f0Y37G94cF+ULTlOrIbCE4OF9LrNwuaqzzXkU SaJULCXpCwW9V3rnR0ZpK3xgiEgOiU+49cd84VEV/Gj2e4bNEQiI0LEx/iMTdl2IeLPaZhS/W3Ilp OpM+1XPpoTK8sylFO5Kw9e7wmEDG4egNZoQgv5TNAA+qikzJguKMeDGTCbp7UO5ozd8cd0J2aBtQs rfZWMHhZa7+Id/GWEXR5MmG4YKDHIvVA+QHh61oLFzL3txGY+oRseWCvkfeBkyS0VCjQKQw9/a629 wqdUhPQ6Ibxf1PfMRT4gem5GbqB4okRCFkkz6EQl4HKk0FK0pxHTUjLgys0Ifg=; Message-Id: <7017658155c517b9665b75333a97c79aa2d4f3df.1732465720.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 24 Nov 2024 17:05:32 +0100 Subject: [PATCH 6/6] tests/9p: also check 'Tgetattr' in 'use-after-unlink' test To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Greg Kurz Received-SPF: pass client-ip=5.189.157.229; envelope-from=7017658155c517b9665b75333a97c79aa2d4f3df@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_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_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 --- 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