Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1502807pxp; Thu, 10 Mar 2022 06:45:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRPAqyth8CxEHTrpLHua5DmYDHticOiEANe2qI3ssQCTUuV2k3U6LukKiMnG5pSStXVevj X-Received: by 2002:a05:6a00:234f:b0:4f6:f0c0:ec68 with SMTP id j15-20020a056a00234f00b004f6f0c0ec68mr5199671pfj.14.1646923504694; Thu, 10 Mar 2022 06:45:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646923504; cv=none; d=google.com; s=arc-20160816; b=ekYAa+AfX3NLAmDlCvky+JByHDS97/06ezPfUD5QQH3KMy0+c+8nc1kXw03untwxaO flGAH5ia/79uZzjbEnub+2lpp9GWYXQcp8iHDcvErrRv+IopcwbiIhK61Aan4UAHvfRa 3Wo4zbjo5EsfZYTSVt5+8Z6/QvEhB5n9jRvx2UCaDJM3J5gswHRhQro/7RrfG0Xa0ehi jqYt2oSeUGNnNaJfe3DghQLU5LoPVCq6zHrK43BlAjjg6fJmf/2mUdKQqkmnbxjxhP+j nzqyiMqQDxTQZJ8jCRAj/aTyHgGlqIhDoy8GNCXZaAM9WXRtyMMm/Um9XBS4v7tdg7fn 9yEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=d/kJbw1ceOFiXhO5YIO+i0r0c+TxsMqa/iGcWfOLU3I=; b=LowVufom5UpsvWjWOGywtvCg0fHDY4armzs5e0Grm42kYdcs0EI1WmhfNHFlj0gf8O OLKpF15Ga+Olf70zw0uRDESfscg8RIuDNvZu+8tIuCsDUvoTGZpmgDfkuhk9SbqSm33N 7+5FiM1ZedidPslCB8xOkv/JHzMv+PAVfreG85RgY3DOvgbAean//CM4rjum6GL0BnN2 m2Dn/Rs4ALLCw8mYl+BGM3YbpFHnGPp17Kv246nlhdo4cJc5I9C2VAVLj4cW0LxCMPGp osExUb3Gj/bKXi15hqbW3li6+ryYWGPlDqEASO4g8RS0YZCsMPR5UrcZ79oaUj5YU5+Z ubRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Minv1FdX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n13-20020a170902e54d00b00151cae5685fsi5387033plf.142.2022.03.10.06.44.46; Thu, 10 Mar 2022 06:45:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Minv1FdX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233595AbiCJHxZ (ORCPT + 99 others); Thu, 10 Mar 2022 02:53:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238718AbiCJHxX (ORCPT ); Thu, 10 Mar 2022 02:53:23 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2751013296B for ; Wed, 9 Mar 2022 23:52:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646898741; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=d/kJbw1ceOFiXhO5YIO+i0r0c+TxsMqa/iGcWfOLU3I=; b=Minv1FdXstaXqnb44YLPJjpzR+M2/UVBfT6TbxAUKmpZFEXQJEXFc4QubEAzjiHE2YMboI FO6vMgjpemZ7fGQ6ph+nxVInZfosH5QFkPjvxIs0Ld+JVy5C+vvN2dGpZs/tO43TvTrZnE 4apT4AySu5o77wE3zx4+6zdflZLe52c= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-48-5l8F3TN-PgeNTt8YBimUDQ-1; Thu, 10 Mar 2022 02:52:17 -0500 X-MC-Unique: 5l8F3TN-PgeNTt8YBimUDQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A65FD51DC; Thu, 10 Mar 2022 07:52:16 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-194.pek2.redhat.com [10.72.13.194]) by smtp.corp.redhat.com (Postfix) with ESMTP id D69437A220; Thu, 10 Mar 2022 07:52:13 +0000 (UTC) From: Jason Wang To: mst@redhat.com Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jason Wang , Eli Cohen , Anirudh Rayabharam Subject: [PATCH] vhost: allow batching hint without size Date: Thu, 10 Mar 2022 15:52:11 +0800 Message-Id: <20220310075211.4801-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit e2ae38cf3d91 ("vhost: fix hung thread due to erroneous iotlb entries") tries to reject the IOTLB message whose size is zero. But the size is not necessarily meaningful, one example is the batching hint, so the commit breaks that. Fixing this be reject zero size message only if the message is used to update/invalidate the IOTLB. Fixes: e2ae38cf3d91 ("vhost: fix hung thread due to erroneous iotlb entries") Reported-by: Eli Cohen Cc: Anirudh Rayabharam Signed-off-by: Jason Wang --- drivers/vhost/vhost.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 082380c03a3e..1768362115c6 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -1170,7 +1170,9 @@ ssize_t vhost_chr_write_iter(struct vhost_dev *dev, goto done; } - if (msg.size == 0) { + if ((msg.type == VHOST_IOTLB_UPDATE || + msg.type == VHOST_IOTLB_INVALIDATE) && + msg.size == 0) { ret = -EINVAL; goto done; } -- 2.18.1