Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2900896pxb; Tue, 24 Aug 2021 10:11:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCKKa65d1zcYB97/pUTFla6YP9mz4NbtqGqNei8newENJRBGEOZgIZDmb8DpMy5xAZ5cP7 X-Received: by 2002:adf:e68b:: with SMTP id r11mr20708396wrm.394.1629825088811; Tue, 24 Aug 2021 10:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629825088; cv=none; d=google.com; s=arc-20160816; b=Y3hlPYd/m8LXQyW65AAPicv5AEUojTO8CJDmJoxYvsTlmWhO3VK410F7cR+pt4px/T 1IAiH6n1hQYhiBIuFaPDVngQoTZbWXIYB+Yf4fVqYsufGWYsr+TZIuGvCfkBDIc3vXVD gS/LqowIC94mCY2Qply1Jq6rd+ltv7xOMwziCCKku/sPRwhWV+OmZAsAKR7KXhNylVQA sIJGVilKezu0tfDVZxljcCCg6wnHPH3jtvqfvmUhDXm4wI111X9RRdmm4mjmCc/D+KPJ 9KP+rps6mWSf/xdbRze2aIwfZmM5VxCKyu2LhoyKlS6wxeTvJDyrt+D1F4SvJ1MQq99K kJeA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/H4SR6eDxQScevxgqg4V+bMZJq+YxGIZ8Cwba3MIFz8=; b=zDEY95z7KvX9jzw4Cd3PbcvyGYALJOg8aZjlFdKblQTeTZ9XUXqgAYsAfmIbo0zdEZ C6AsnCcnR7Fd1s4xw7L0pmGJ9MLn+QHOvemVR556gsiZz885JAftsOKEn8DOvdMIxXiy MMaiern9uLwJk3e4hBQD6reM4vdq2u2Qt/Vd80muajXW6TDpHTzsEQUqT0SeDWhyLC57 IpxtYXJR+vdaAfSkNwwgtbrzu/vEmK9bs9UQJ+GnF1BjMjgk7pjgdVbGddqMZfH/LXMq zmKwr1Z+vHE+ViIcoZzDg/4+gZO/dtEqeWrLErXJ1zJTCypmvqrvMHi0dklGhUAaQ3cU GUyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FURbfTZ+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e10si22798943edj.183.2021.08.24.10.11.04; Tue, 24 Aug 2021 10:11:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FURbfTZ+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239378AbhHXRJK (ORCPT + 99 others); Tue, 24 Aug 2021 13:09:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:46230 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239293AbhHXRGu (ORCPT ); Tue, 24 Aug 2021 13:06:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2BE4D619FA; Tue, 24 Aug 2021 16:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629824390; bh=uwsmN8nWTEHWmw8gZ2TUrS8K/QuWhsW3qZyySIH122c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FURbfTZ+md0tWqOez7VqMfJu85fuGokc99OeONdFrT2lZBFFHNgC302Avx4AkxjjF na+d0EYYs1YPP34wrYkUujIrbyoI+U88P+7XubbhG7AJ/2pFBX5hPpk/dkKBFxlf3J 5tKvqVEEd/pYXrhsnjzwwpjzAnoIPVhRcskElyznRywllNcTQdwelYThdWeT6meQSL Sh5AWXvJlKgoiCXDZQe4uf+nqvEZ7fA+/Z04lUF064lnfu/oZXxES1AGoyL88i81eS 9Y5ZYyNAOTd2aev6gro9UBWvwymiW8wW//aoIjKHP7nR0zEyBCwILXgxPDS1stZXUG axYr09IshY21w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Xie Yongji , Dan Carpenter , Jason Wang , "Michael S . Tsirkin" , Sasha Levin Subject: [PATCH 5.10 41/98] vhost-vdpa: Fix integer overflow in vhost_vdpa_process_iotlb_update() Date: Tue, 24 Aug 2021 12:58:11 -0400 Message-Id: <20210824165908.709932-42-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210824165908.709932-1-sashal@kernel.org> References: <20210824165908.709932-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.10.61-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.10.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.10.61-rc1 X-KernelTest-Deadline: 2021-08-26T16:58+00:00 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xie Yongji [ Upstream commit 0e398290cff997610b66e73573faaee70c9a700e ] The "msg->iova + msg->size" addition can have an integer overflow if the iotlb message is from a malicious user space application. So let's fix it. Fixes: 1b48dc03e575 ("vhost: vdpa: report iova range") Reported-by: Dan Carpenter Signed-off-by: Xie Yongji Acked-by: Jason Wang Link: https://lore.kernel.org/r/20210728130756.97-1-xieyongji@bytedance.com Signed-off-by: Michael S. Tsirkin Signed-off-by: Sasha Levin --- drivers/vhost/vdpa.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 80184153ac7d..c4d53ff06bf8 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -623,7 +623,8 @@ static int vhost_vdpa_process_iotlb_update(struct vhost_vdpa *v, long pinned; int ret = 0; - if (msg->iova < v->range.first || + if (msg->iova < v->range.first || !msg->size || + msg->iova > U64_MAX - msg->size + 1 || msg->iova + msg->size - 1 > v->range.last) return -EINVAL; -- 2.30.2