Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp644597pxb; Tue, 5 Apr 2022 17:06:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2YD1pHkfXzEutoxlVXngZyS7bvRifAZ9wuAUr3Ol99euuxrSsk0PfEGF9KL9ASZYSiB6p X-Received: by 2002:a63:af06:0:b0:378:3582:a49f with SMTP id w6-20020a63af06000000b003783582a49fmr4900525pge.125.1649203617572; Tue, 05 Apr 2022 17:06:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649203617; cv=none; d=google.com; s=arc-20160816; b=VcL9ouMZAkywiJXS25xhogO7OZmHnjpAiZ47uoxE3xwaZ9tyyxhFMhkioInwHSdCre miJmbbKSLKNsLvwoZMALQLz14xLujo3a7otaPJo5liXAX0uHes2Q3v3uAAa/8NDOiHGb 837N4iaJutd4Npcyk8ZurZ0z9HGekg0OnyOQGW3oRewQDnkTgFKjSlzxHRF6DJPjoqku 3TTlvJodxtqtEitOr45zj+75Kj0WgtVGZytq477im6vXRgNcdM3A0QwFH2C/RJecUhdC j4gXsDG+U6v3LOMdSN5tr1LpOozBnJEXsG8nl5vkeoLXdh9RJU9+xi1c86GRowk4zTJK 9CuA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=v41aqkON0hJhmq1tA7CKebQT508D6YbtmOjFMSt7wXU=; b=zTmNfKDmSX+FLsOK/pkoqGdU0eCRsw8qhTAI9yb4Vf2+bZeeX+yeGuNNeIa9baXlIP SXkklpBGhIt3X4OCoGVCi80i3g92ZwlaJLyP7HuvHe0mDKuCSDwkUIhzcRoptruw2vDj h4qX8pbltZbbz5vYWkTmcNfS8s3LDglU/xBOs2bwqK/7Ax4nDUJAmdL7GIQRIvkxjoZD tDCQ2u4P8Gi2EwMBIgJ/yTpOc7XDFMgSOAo+l0qjxYP9RUnjTQ8KctoXvyjw/EILcUkH 6JClo2Vq5L1nL94qBbjk6DDSek7crWKUIieYLQlBBFa6LIyxHqhA9xvCkiEa4IOR9zVT CvBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=V1C4j26T; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id j17-20020aa78dd1000000b004fa3a8e0078si12603482pfr.303.2022.04.05.17.06.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 17:06:57 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=V1C4j26T; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 753F317ADBB; Tue, 5 Apr 2022 16:51:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441846AbiDENxB (ORCPT + 99 others); Tue, 5 Apr 2022 09:53:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347393AbiDEJ0M (ORCPT ); Tue, 5 Apr 2022 05:26:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7673C9682D; Tue, 5 Apr 2022 02:15:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5694861576; Tue, 5 Apr 2022 09:15:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61FA4C385A0; Tue, 5 Apr 2022 09:15:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150110; bh=uJf7pj87pn7mUSWMH3sAg8R4hUfURYzVn3VcFRGN990=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V1C4j26T7gnyJA8QLDh/4cv3NGCO3yyQKF66ikTrb/JGvxI7D9ZEQtjo7Z24E/AGy JFSF4CmTVRtqN4N7HWlPWTmiSxR16dfjSWvMCIu1T8924kr2eSR0Alk51UEB8c0/Ix kZMUhgECtqe399Urav8e7ojDHy+5NKLZRVLo8WK8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anirudh Rayabharam , "Michael S. Tsirkin" , Stefano Garzarella Subject: [PATCH 5.16 0956/1017] vhost: handle error while adding split ranges to iotlb Date: Tue, 5 Apr 2022 09:31:09 +0200 Message-Id: <20220405070422.586330529@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Anirudh Rayabharam commit 03a91c9af2c42ae14afafb829a4b7e6589ab5892 upstream. vhost_iotlb_add_range_ctx() handles the range [0, ULONG_MAX] by splitting it into two ranges and adding them separately. The return value of adding the first range to the iotlb is currently ignored. Check the return value and bail out in case of an error. Signed-off-by: Anirudh Rayabharam Link: https://lore.kernel.org/r/20220312141121.4981-1-mail@anirudhrb.com Signed-off-by: Michael S. Tsirkin Fixes: e2ae38cf3d91 ("vhost: fix hung thread due to erroneous iotlb entries") Reviewed-by: Stefano Garzarella Signed-off-by: Greg Kroah-Hartman --- drivers/vhost/iotlb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/vhost/iotlb.c +++ b/drivers/vhost/iotlb.c @@ -62,8 +62,12 @@ int vhost_iotlb_add_range_ctx(struct vho */ if (start == 0 && last == ULONG_MAX) { u64 mid = last / 2; + int err = vhost_iotlb_add_range_ctx(iotlb, start, mid, addr, + perm, opaque); + + if (err) + return err; - vhost_iotlb_add_range_ctx(iotlb, start, mid, addr, perm, opaque); addr += mid + 1; start = mid + 1; }