Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3996188pxu; Mon, 12 Oct 2020 06:58:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3V8omnf0dCkXFjicf91qRrAKVNsxc4XaKr0RRo0oJJhFhpViTKvGDN89wmNGNwKZCHXs9 X-Received: by 2002:a05:6402:2055:: with SMTP id bc21mr13855821edb.67.1602511138833; Mon, 12 Oct 2020 06:58:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602511138; cv=none; d=google.com; s=arc-20160816; b=zMhdR7o9V4aTUzqKL+eaTTb1n6dJI0S3w5zSWOVCBd6Vw0ht4x0RdeqWRVFIESj4LF HgU6xzPDlAb0sbDlREm4rmjBXu9SVHegjE96pWAb19m+KUAtgfe3RnjSXC/nLvqqOKCj AUORTllAetRcKLNYbjMt92eWTPNF9Kbmbd10y+U1Sza997vR/TJ9C+VZuHGykrRuiTiM 8m9NGysPS4uraOZ7umAbCu4xOZz1q4Fajz7EUH1DI6zFU5KjCa/duIupmRTedQUw6Vf0 bbsQtE+wYAK/IYaU4cieZ3ND/EZzcorC0BB8dzQLTYBEhxg6EQxCdH57j7GA04wiW6Ts SxGw== 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=pqMrEyVPbJaaDOvahdYRlds71Gs2pZPJsstoa0v4/Cw=; b=Y1gfoFsatxGXpTmncL/svwAY+xcHzyDtQCxuIruJHlSf19pHde7xorxQQgSfxcZa9/ 68ALuJnqldMwushvAtu0RJxDBblgHIJ7T27o4pGW+L0kFrMopW0NTA+zDn+yQolj9ktz HjDFYRrADueCcteMzeef56woE2DNUgfWrjcn30/N1tA1xWsTBgq3aRRBXyhfvyxrju6b gi5jVJ7+AmzbSSBQYM3ZF/ROIP693wnasbQMmH2KldXPQy6qP1L3HLeczV+p3VwR5vpF mDtPM/PVd6JASfxNC44KIJhb9bJDdVnp9AobMFLJftUkN5/0zdUj7QTahBwzNcQrsa4A Ae1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pliUJpDw; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ay11si4069426edb.464.2020.10.12.06.58.35; Mon, 12 Oct 2020 06:58:58 -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=default header.b=pliUJpDw; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389489AbgJLN4m (ORCPT + 99 others); Mon, 12 Oct 2020 09:56:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:48386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389479AbgJLNoY (ORCPT ); Mon, 12 Oct 2020 09:44:24 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0E40622246; Mon, 12 Oct 2020 13:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602510236; bh=HXMbN4jgL33eeLL6lMLP5iUm3/H8vcfYn3a/PWuKhkU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pliUJpDwcPaSOOiitSZ/bs/QjS4HsrvPWsiZerh7Q7CEdIrSIEdlG1ztSROzo+vRa UyYriY6GIdnEDiy1nm2/fUEyT9Xo4S7A4/dYQtBWAJvyK6bN9sJkhcAqfpcPHCzn+5 jDga6xcjMNCiKSfwgn/R1nEo3qxbTYU3A05h0MjU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, jasowang@redhat.com, Greg Kurz , "Michael S. Tsirkin" Subject: [PATCH 5.8 013/124] vhost: Dont call access_ok() when using IOTLB Date: Mon, 12 Oct 2020 15:30:17 +0200 Message-Id: <20201012133147.495615677@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012133146.834528783@linuxfoundation.org> References: <20201012133146.834528783@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kurz commit 0210a8db2aeca393fb3067e234967877e3146266 upstream. When the IOTLB device is enabled, the vring addresses we get from userspace are GIOVAs. It is thus wrong to pass them down to access_ok() which only takes HVAs. Access validation is done at prefetch time with IOTLB. Teach vq_access_ok() about that by moving the (vq->iotlb) check from vhost_vq_access_ok() to vq_access_ok(). This prevents vhost_vring_set_addr() to fail when verifying the accesses. No behavior change for vhost_vq_access_ok(). BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1883084 Fixes: 6b1e6cc7855b ("vhost: new device IOTLB API") Cc: jasowang@redhat.com CC: stable@vger.kernel.org # 4.14+ Signed-off-by: Greg Kurz Acked-by: Jason Wang Link: https://lore.kernel.org/r/160171931213.284610.2052489816407219136.stgit@bahia.lan Signed-off-by: Michael S. Tsirkin Signed-off-by: Greg Kroah-Hartman --- drivers/vhost/vhost.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -1283,6 +1283,11 @@ static bool vq_access_ok(struct vhost_vi vring_used_t __user *used) { + /* If an IOTLB device is present, the vring addresses are + * GIOVAs. Access validation occurs at prefetch time. */ + if (vq->iotlb) + return true; + return access_ok(desc, vhost_get_desc_size(vq, num)) && access_ok(avail, vhost_get_avail_size(vq, num)) && access_ok(used, vhost_get_used_size(vq, num)); @@ -1376,10 +1381,6 @@ bool vhost_vq_access_ok(struct vhost_vir if (!vq_log_access_ok(vq, vq->log_base)) return false; - /* Access validation occurs at prefetch time with IOTLB */ - if (vq->iotlb) - return true; - return vq_access_ok(vq, vq->num, vq->desc, vq->avail, vq->used); } EXPORT_SYMBOL_GPL(vhost_vq_access_ok);