Received: by 10.192.165.156 with SMTP id m28csp25369imm; Tue, 10 Apr 2018 15:38:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/otc5yeXFbYDeUT9hFfEhpIpU1QRzxhtjQuYzXaO93WpCxkmmL5pX8nZR61HsCa996tZKV X-Received: by 10.98.35.202 with SMTP id q71mr1860228pfj.9.1523399888973; Tue, 10 Apr 2018 15:38:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523399888; cv=none; d=google.com; s=arc-20160816; b=rlXkUzYxyO9Q8PTHpSi00VA0MxGvTC6vhzsW1H2Vdd119qDpdyFfTjVEkKfnZXs4fP 0qO6aRMWKVBWycyHO1cYWBFOHIkNaTTuAGkI36OOpIDlo4Idb2SBxKva75pT1VnqVh6S 91bQvfwgcFK4c6ntbxlW/uoUvYc0AG9z1u5C6m+iLe37NVj5tSp0G24tEK7TqFxoUJAw cLHmHLUn+WHW6N48UMYX+HhJ5uSWs510CPlf8jjWKoi6QCXTisrK952NpyAaMIyKa1vH 4FRXbXrIQ8lVHE2sR3cSjbx/BelYQCswrhH7McTpjywo/CJ8JKgY1c0eVVePRFFSR3u3 C6fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=/0ojZ56ezC7SYymsXbPQiOsnOmNswqG++diV3e7kd9U=; b=d95Bu5wMPQtkuJ00OBlJOjzq7igN7yeyIQ8O9zremHlXrp07QJYaBHMPWylybn/7tM 8so3Wkh2RGjvcOG/b9H88qN54KyDvjxzmtAAoUws6+nwaKGipJZ/UrkHYp9ZuGV6cylN g7H/dnBU1z+j7sdDh81l+KLu00K7HIho+32zJ3HRBVU8jf7x1Ue1na2cQcBZmrP+IrHr 9C/0RRQHAhepKYZkvmhCehwCY/GJNN79osdWPTV6z8QGMqIC2+KSnJAUEgKyRnBZmqeh 3cAv23p3AdIsA2NxTdRGJe/tmvP5u+9zQ73IVT0m1x4ukt9LQleXvzoEc9bZ4pAMLaf+ +QxQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j7si2365735pgq.426.2018.04.10.15.37.32; Tue, 10 Apr 2018 15:38:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755188AbeDJWdO (ORCPT + 99 others); Tue, 10 Apr 2018 18:33:14 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41198 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755146AbeDJWdL (ORCPT ); Tue, 10 Apr 2018 18:33:11 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A76B8BCF; Tue, 10 Apr 2018 22:33:10 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+6304bf97ef436580fede@syzkaller.appspotmail.com, Jason Wang , "Michael S. Tsirkin" , "David S. Miller" Subject: [PATCH 4.15 164/168] vhost: validate log when IOTLB is enabled Date: Wed, 11 Apr 2018 00:25:06 +0200 Message-Id: <20180410212808.207271433@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jason Wang [ Upstream commit d65026c6c62e7d9616c8ceb5a53b68bcdc050525 ] Vq log_base is the userspace address of bitmap which has nothing to do with IOTLB. So it needs to be validated unconditionally otherwise we may try use 0 as log_base which may lead to pin pages that will lead unexpected result (e.g trigger BUG_ON() in set_bit_to_user()). Fixes: 6b1e6cc7855b0 ("vhost: new device IOTLB API") Reported-by: syzbot+6304bf97ef436580fede@syzkaller.appspotmail.com Signed-off-by: Jason Wang Acked-by: Michael S. Tsirkin Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/vhost/vhost.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -1256,14 +1256,12 @@ static int vq_log_access_ok(struct vhost /* Caller should have vq mutex and device mutex */ int vhost_vq_access_ok(struct vhost_virtqueue *vq) { - if (vq->iotlb) { - /* When device IOTLB was used, the access validation - * will be validated during prefetching. - */ - return 1; - } - return vq_access_ok(vq, vq->num, vq->desc, vq->avail, vq->used) && - vq_log_access_ok(vq, vq->log_base); + int ret = vq_log_access_ok(vq, vq->log_base); + + if (ret || vq->iotlb) + return ret; + + return vq_access_ok(vq, vq->num, vq->desc, vq->avail, vq->used); } EXPORT_SYMBOL_GPL(vhost_vq_access_ok);