From nobody Sun May 19 11:31:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1589135722; cv=none; d=zohomail.com; s=zohoarc; b=lpHxYpstnOwHTGr5hO45Oc0IaBc94ykvAQrVldQUlVRImorMTzJ4E5JS/zCciAR2Y0GQGm86c66PIs0cnRyfvYGgynvNCusnuAJd5xZrsZ2RD3Natx3Yup/Ra+BWgLUnkHzE9TVttNv97aBfYXMYj1ZHsJLxxbTDrFElPSplCmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589135722; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=vmF7NmnttbFuaHeIWeCyzKORtLSbSPMZue6Yg+i6MrE=; b=XqGmkK0UT+L42TyAvLjH+ubBUNL56X1Cp5hUW7NlhuuVxM7kjvRZghE0ciogF+p3uvr51RI8ePk/9r1BhuXr71C0R3LWN70g8Az05eijaC7WJRnFIi8STehO9A9cPnz5otr/AAmohEFKgYlLEr+IiTDtP/tEsyrC1ciIGjKiNZ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589135722834950.9920962806985; Sun, 10 May 2020 11:35:22 -0700 (PDT) Received: from localhost ([::1]:54758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXqnJ-00012W-10 for importer@patchew.org; Sun, 10 May 2020 14:35:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44868) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqhi-0006Ah-3Z for qemu-devel@nongnu.org; Sun, 10 May 2020 14:29:34 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:44391) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jXqhh-0005RE-BT for qemu-devel@nongnu.org; Sun, 10 May 2020 14:29:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=vmF7NmnttbFuaHeIWeCyzKORtLSbSPMZue6Yg+i6MrE=; b=nPnzn th+MlUrV0bY0+I2y7fObjOQ/LThcRxE2ZOW1h1Aoy9PIgYXzNbBwt9lEL1YGhgZ4GhDVVme3yoTs/ mEmdSz0p3eLR8I2mhggB3Z9U3nEoI8aH+CYETj2jxItnsTKKYKLArBlku1WTBFg68fSGIqQFDQwjB F5rM55E6JP5ihJ4oYg4YBsuLEo9NV/x6PTbaLnfC61zbCz5UXdqSj7qsi3K574Sjkp0mdIbm78JgK gU2OJHOP0bUGRNoJciNntwTvpI8uY1Uw9rA2wmnb0ZlNTZQ9IPCcW/BqsGKomfN43DynYScHDQFA8 GReJ9YmstH0Wxe3XaiWoG5lMnMiHg==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 10 May 2020 19:05:02 +0200 Subject: [PATCH 1/2] xen-9pfs: Fix log messages of reply errors To: qemu-devel@nongnu.org Cc: Greg Kurz , Stefano Stabellini , Anthony Perard , Paul Durrant Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=ad0e5a9b6abde52502aa40b30661d29aebe1590a@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/10 14:00:36 X-ACL-Warn: Detected OS = Linux 3.11 and newer 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If delivery of some 9pfs response fails for some reason, log the error message by mentioning the 9P protocol reply type, not by client's request type. The latter could be misleading that the error occurred already when handling the request input. Signed-off-by: Christian Schoenebeck Acked-by: Stefano Stabellini --- hw/9pfs/xen-9p-backend.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c index 18fe5b7c92..f04caabfe5 100644 --- a/hw/9pfs/xen-9p-backend.c +++ b/hw/9pfs/xen-9p-backend.c @@ -137,7 +137,8 @@ static ssize_t xen_9pfs_pdu_vmarshal(V9fsPDU *pdu, ret =3D v9fs_iov_vmarshal(in_sg, num, offset, 0, fmt, ap); if (ret < 0) { xen_pv_printf(&xen_9pfs->xendev, 0, - "Failed to encode VirtFS request type %d\n", pdu->id= + 1); + "Failed to encode VirtFS reply type %d\n", + pdu->id + 1); xen_be_set_state(&xen_9pfs->xendev, XenbusStateClosing); xen_9pfs_disconnect(&xen_9pfs->xendev); } @@ -201,9 +202,9 @@ static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pdu, =20 buf_size =3D iov_size(ring->sg, num); if (buf_size < P9_IOHDRSZ) { - xen_pv_printf(&xen_9pfs->xendev, 0, "Xen 9pfs request type %d" - "needs %zu bytes, buffer has %zu, less than minimum\n", - pdu->id, *size, buf_size); + xen_pv_printf(&xen_9pfs->xendev, 0, "Xen 9pfs reply type %d needs " + "%zu bytes, buffer has %zu, less than minimum\n", + pdu->id + 1, *size, buf_size); xen_be_set_state(&xen_9pfs->xendev, XenbusStateClosing); xen_9pfs_disconnect(&xen_9pfs->xendev); } --=20 2.20.1 From nobody Sun May 19 11:31:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1589135365; cv=none; d=zohomail.com; s=zohoarc; b=IDd6NUItRBlpc1qgeN6CxASxU4oxtwFqIiiQs0v10J4XK/axsCFtRHv+25+fLAswrfHa6RuwnH8gCuXC1QWmnrDJ7uCMmFbxO0bvf9Pl/ZtbXVvfeCug3uS+tAkr5BZgTyYNM2s0y/YTgIV34jHiGSs2r5WYyJ7U4qCOTF+3VIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589135365; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=dbVxlY5uoYntWjDm7o4KOAqYCxACWT1Q7BS/wBPpRow=; b=ARKZJwut3mxJqFED9s1IElAqs7kYQW6r8vaMw3K5011VG4jqWA7FmqsNMWsLrk6IwdDislxbecHEE3e3xz1aSrRKZ+L2XA+TqUPU9gZL+I5Msmrh+1M3VAVSB/IG2y/tgW0oLLTearLblurt3ji6qg/Ejkimd4oWS210R1vYAro= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1589135365113341.0997984280425; Sun, 10 May 2020 11:29:25 -0700 (PDT) Received: from localhost ([::1]:48396 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jXqhX-0005cL-0k for importer@patchew.org; Sun, 10 May 2020 14:29:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44826) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <54f3b9c9f05a77ccdd6103bd46c828fcb675cbac@lizzy.crudebyte.com>) id 1jXqgi-00058O-8l for qemu-devel@nongnu.org; Sun, 10 May 2020 14:28:32 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:51931) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <54f3b9c9f05a77ccdd6103bd46c828fcb675cbac@lizzy.crudebyte.com>) id 1jXqgg-0004CT-Lx for qemu-devel@nongnu.org; Sun, 10 May 2020 14:28:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=dbVxlY5uoYntWjDm7o4KOAqYCxACWT1Q7BS/wBPpRow=; b=dxVKd tddrilngLhFYKXN9vBoZnGCdqMz0mWtO6/91q1SzvZQwwVnLUzXuXB6i+2BhB4VjYxwbgk2rnt7Cm IiOjUYrzpIVwAJ51Y99yUhtSJh5MTj98NSpSAlskPLGEOgMd+4zb2DNCOBsdupSFF7TiecppSdI7y F4bF8t7kVKVXgzv1IsZgEPttF9JyKe2NuCwC/7loehbdLZ9u/ZQkn9SFphokEypcgoSpfBjF/akEG GDpSQCGzCE9ceTTm2CPOQ9CrPBgPTUFmm92okgorx2+cfCCloO0cIxCTXNEKjjiCYkv+K9bF0EyEp Asa8n389ErXSs3ZaMoY8EPZzj54Fw==; Message-Id: <54f3b9c9f05a77ccdd6103bd46c828fcb675cbac.1589132512.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Sun, 10 May 2020 19:18:21 +0200 Subject: [PATCH 2/2] 9pfs: fix init_in_iov_from_pdu truncating size To: qemu-devel@nongnu.org Cc: Greg Kurz , Stefano Stabellini , Anthony Perard , Paul Durrant Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=54f3b9c9f05a77ccdd6103bd46c828fcb675cbac@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/10 14:00:36 X-ACL-Warn: Detected OS = Linux 3.11 and newer 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, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit SHA-1 16724a173049ac29c7b5ade741da93a0f46edff7 introduced truncating the response to the currently available transport buffer size, which was supposed to fix an 9pfs error on Xen boot where transport buffer might still be smaller than required for response. Unfortunately this change broke small reads (with less than 12 bytes). To address both concerns, check the actual response type and only truncate reply for Rreaddir responses, and only if truncated reply would at least return one payload byte to client. Use Rreaddir's precise header size (11) for this instead of P9_IOHDRSZ. Fixes: 16724a173049ac29c7b5ade741da93a0f46edff7 Fixes: https://bugs.launchpad.net/bugs/1877688 Signed-off-by: Christian Schoenebeck --- hw/9pfs/virtio-9p-device.c | 35 +++++++++++++++++++++++++++-------- hw/9pfs/xen-9p-backend.c | 38 +++++++++++++++++++++++++++++--------- 2 files changed, 56 insertions(+), 17 deletions(-) diff --git a/hw/9pfs/virtio-9p-device.c b/hw/9pfs/virtio-9p-device.c index 536447a355..57e4d92ecb 100644 --- a/hw/9pfs/virtio-9p-device.c +++ b/hw/9pfs/virtio-9p-device.c @@ -154,15 +154,34 @@ static void virtio_init_in_iov_from_pdu(V9fsPDU *pdu,= struct iovec **piov, VirtQueueElement *elem =3D v->elems[pdu->idx]; size_t buf_size =3D iov_size(elem->in_sg, elem->in_num); =20 - if (buf_size < P9_IOHDRSZ) { - VirtIODevice *vdev =3D VIRTIO_DEVICE(v); + if (pdu->id + 1 =3D=3D P9_RREAD) { + /* size[4] Rread tag[2] count[4] data[count] */ + const size_t hdr_size =3D 11; + /* + * If current transport buffer size is smaller than actually requi= red + * for this Rreaddir response, then truncate the response to the + * currently available transport buffer size, however only if it w= ould + * at least allow to return 1 payload byte to client. + */ + if (buf_size < hdr_size + 1) { + VirtIODevice *vdev =3D VIRTIO_DEVICE(v); =20 - virtio_error(vdev, - "VirtFS reply type %d needs %zu bytes, buffer has %zu= , less than minimum", - pdu->id + 1, *size, buf_size); - } - if (buf_size < *size) { - *size =3D buf_size; + virtio_error(vdev, + "VirtFS reply type %d needs %zu bytes, buffer has= " + "%zu, less than minimum (%zu)", + pdu->id + 1, *size, buf_size, hdr_size + 1); + } + if (buf_size < *size) { + *size =3D buf_size; + } + } else { + if (buf_size < *size) { + VirtIODevice *vdev =3D VIRTIO_DEVICE(v); + + virtio_error(vdev, + "VirtFS reply type %d needs %zu bytes, buffer has= %zu", + pdu->id + 1, *size, buf_size); + } } =20 *piov =3D elem->in_sg; diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c index f04caabfe5..98f340d24b 100644 --- a/hw/9pfs/xen-9p-backend.c +++ b/hw/9pfs/xen-9p-backend.c @@ -201,15 +201,35 @@ static void xen_9pfs_init_in_iov_from_pdu(V9fsPDU *pd= u, xen_9pfs_in_sg(ring, ring->sg, &num, pdu->idx, *size); =20 buf_size =3D iov_size(ring->sg, num); - if (buf_size < P9_IOHDRSZ) { - xen_pv_printf(&xen_9pfs->xendev, 0, "Xen 9pfs reply type %d needs " - "%zu bytes, buffer has %zu, less than minimum\n", - pdu->id + 1, *size, buf_size); - xen_be_set_state(&xen_9pfs->xendev, XenbusStateClosing); - xen_9pfs_disconnect(&xen_9pfs->xendev); - } - if (buf_size < *size) { - *size =3D buf_size; + if (pdu->id + 1 =3D=3D P9_RREAD) { + /* size[4] Rread tag[2] count[4] data[count] */ + const size_t hdr_size =3D 11; + /* + * If current transport buffer size is smaller than actually requi= red + * for this Rreaddir response, then truncate the response to the + * currently available transport buffer size, however only if it w= ould + * at least allow to return 1 payload byte to client. + */ + if (buf_size < hdr_size + 1) { + xen_pv_printf(&xen_9pfs->xendev, 0, "Xen 9pfs reply type %d " + "needs %zu bytes, buffer has %zu, less than " + "minimum (%zu)\n", + pdu->id + 1, *size, buf_size, hdr_size + 1); + xen_be_set_state(&xen_9pfs->xendev, XenbusStateClosing); + xen_9pfs_disconnect(&xen_9pfs->xendev); + } + if (buf_size < *size) { + *size =3D buf_size; + } + } else { + if (buf_size < *size) { + xen_pv_printf(&xen_9pfs->xendev, 0, "Xen 9pfs reply type %d " + "needs %zu bytes, buffer has %zu\n", pdu->id + 1, + *size, buf_size); + + xen_be_set_state(&xen_9pfs->xendev, XenbusStateClosing); + xen_9pfs_disconnect(&xen_9pfs->xendev); + } } =20 *piov =3D ring->sg; --=20 2.20.1