Received: by 10.192.165.156 with SMTP id m28csp1092162imm; Wed, 11 Apr 2018 12:15:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+GlNA31cNO6/mlMYfrl+9jya7wtaNyJmoD3LA80cdmnRk0Mp7fhn/wjLkqroRNrCXgm7Zg X-Received: by 10.99.112.70 with SMTP id a6mr4373068pgn.294.1523474124950; Wed, 11 Apr 2018 12:15:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523474124; cv=none; d=google.com; s=arc-20160816; b=CVuTc6xq+UkshFqek+PcumKVLlQmhqQtMSr1DCAAE9GyLoamjO17tqRf21USz6P2ul 7iZ8/9X0vmQQXCsOCMxQC4T6qTU+l/ntiDfoBTHVznpi96qzk31F9WDxQebef4Pe+0ZL LvfnwuLmIE78xXKqKOqFnTETxZGCaaouNjzR1koUBthSMKDjJU1e+xwfxMUHh2J1bVUm 3croIJTo0PjWq17QKlxx0ya/kpI0WvE9Gt8SrEhXuQHIR5KNp0ErJuEIqiOmUCPV7kfC D1m2EXSDVSEzsZgUMSBeQF2NMIDfhCqGVdt6Y8IA+xHNmmvXhJpD5FyCl1uOaq42hTmv l8PQ== 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=1RXtb6ZQgju75o4EBzr+mc49op10abJFysDeWWVWLko=; b=G4yB/BVdYV1LEx9J1h2jB6QC+90qUsDnpKE89zwiN0rCv0fUajT/ZE4RwKtmk/OSIZ xIJuEzy3pzRIddLTaGbiFOvnKsCL5nWQQhcagir/8Qo+91zzXwJ5w+6g6SgW3RmHNyYh eNBNI44tXyes3hLqj08Vomf9ReI+JQ9ba12NJEWpFAx1TLVMZuPvLKhroDZdAe6Y8JnJ KKKFYz7RhqFQi3FaNlwo1JPzo/mN9DI1vV8XIDFYnAJ+eS6ewZ29R6FA6NjR55QjxREZ +owVvg86+/elnP41Ti1WStFAA/4wKyv4/gJYrLlxTfg/UgB8sfDiLsdS+DL+2AX1kzwS ztdw== 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 n13si540084pfh.31.2018.04.11.12.14.48; Wed, 11 Apr 2018 12:15:24 -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 S1756884AbeDKTKO (ORCPT + 99 others); Wed, 11 Apr 2018 15:10:14 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40836 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935232AbeDKTGb (ORCPT ); Wed, 11 Apr 2018 15:06:31 -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 450A4D3F; Wed, 11 Apr 2018 19:06:30 +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.9 303/310] vhost: validate log when IOTLB is enabled Date: Wed, 11 Apr 2018 20:37:22 +0200 Message-Id: <20180411183635.587286856@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@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.9-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 @@ -1175,14 +1175,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);