Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp959789pxb; Wed, 6 Apr 2022 05:21:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfvEmlqbZjY6jU6pUqw33KY2H0k1NeRHpDd1BUlrMQ3Em+/A7eGiaQzh4b6zljXid/t5oc X-Received: by 2002:a17:90a:380d:b0:1c9:d9bb:7602 with SMTP id w13-20020a17090a380d00b001c9d9bb7602mr9385256pjb.216.1649247689759; Wed, 06 Apr 2022 05:21:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649247689; cv=none; d=google.com; s=arc-20160816; b=I0iecWSeH2QRO72A5w7FoFNzG2PL76cuzlaMCu9dPgdSC7Cr/SPhlTQNh6ezl763vN TjWYWap1rgBfCW4N6tzvHtLOj3ySqdm/KZMZUkw5chPw8BOc0+fT7axi6qSYHkSrei88 2E1/KdEqAl/uYH8swj2A+5tCgpURPs73ab/+/uxEirfMmgHdS0/HCphUDsfNfJ49/eKH KM+jeBmN6LiNqKzhH5Hg3/UHX/8Nau4fl82g3lgRAdLCc8XBIAWVmsSi8QEU2IULWGEm BW17hfQcE3qlV0Syo7GW3Ve7dsrZZJ3wb9TDRBOh4xfmzL3NXHizwdsksz4a5s5JKW2G Z3mA== 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=IlxuiOLf4XU1rS3P7JLfqKrIv2J9NoO5l1atL74c0lIQE3y17e0sUPWsK96l2Stb6r PvcGDXkxHSoVnvwFOOdnmHaCCGDf7RFs1cuioP63UMgc6XAGkDrTYdKuvB7PF+6/OY06 lI4u9uK6mMVUKdjLU3c3SPWnjAD1kwncGl84hmmqBVYoWAV+2Jcu0GpRfKl1SS9jpa61 dpSc6OlkSePSYVL74/BNem+2ZwiltFnIUdO3WP3d4RBcREKSkW49sKULHuCfypRBJMSm Og8S+RveWej1VplHp9O9KCjW0WF+l7MrmyJ/sntlihvMyi+wkTfZaM04CVUh/uwxJIj5 YZLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hjzXSrNa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q2-20020a63e942000000b003816043ef39si15466863pgj.302.2022.04.06.05.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:21:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hjzXSrNa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 B1DBB6D387B; Wed, 6 Apr 2022 04:18:13 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1843053AbiDFBjK (ORCPT + 99 others); Tue, 5 Apr 2022 21:39:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354167AbiDEKMO (ORCPT ); Tue, 5 Apr 2022 06:12:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C03D517F1; Tue, 5 Apr 2022 02:57:51 -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 ams.source.kernel.org (Postfix) with ESMTPS id 1FD7BB81B18; Tue, 5 Apr 2022 09:57:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87D86C385A2; Tue, 5 Apr 2022 09:57:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649152668; bh=uJf7pj87pn7mUSWMH3sAg8R4hUfURYzVn3VcFRGN990=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hjzXSrNaGFXKvodrd3Ic7S0X2gADiqEjWLPPyTicETdsPNI87QdRyEPL168w+YYBI rTxbHIi8Q0wnVO72GDp4iAvIorC/kP3FzAJA8a6LnlfdvRqVifETwwO0hug26QVQ57 A0ddh/bJidhaMoBQc1/Tbf1INdPp3mOwNfpUrAnE= 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.15 859/913] vhost: handle error while adding split ranges to iotlb Date: Tue, 5 Apr 2022 09:32:01 +0200 Message-Id: <20220405070405.575603365@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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; }