Received: by 10.192.165.156 with SMTP id m28csp30290imm; Tue, 10 Apr 2018 15:45:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx49b3PbMfvTjgeWrz6h+84QI5z+cCCxvilPy/g17qfy9yFHGq3LwJGkPkmMnMkNocMgkm/2I X-Received: by 2002:a17:902:d20a:: with SMTP id t10-v6mr2316683ply.151.1523400308539; Tue, 10 Apr 2018 15:45:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523400308; cv=none; d=google.com; s=arc-20160816; b=TzJ1Y2VhAOoc6HHJEDbyCtzOgCiE5aTiTBnWt8KwCbaQ7mzOKaM71DKCeY7TkLklY2 7b0q4CnMj6l0+r6+i7n7G/9aEyKYJHcnvEf2P9rkxNXItetf4Rz9vYIu0Wf/+f12oKE/ RilWtHEbJavSbtDXS32kBnxGagsWBORxU2HW9rzxa3SYbmPDwql4oQTFqdiSbjJ78kKB TIqwgzDCWl2zMhpeDm9DkAyUZHKl20nISbu6mFp80TcdNQJRMT8cHqb7Zfprb2OPSJgH jH8EdnMKVOs1Mxg81gsHK4f+R9AY1+Pyh+bdBH7aJQ103KcFl4go7mZA/1vhrA2Fwtjz edXQ== 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=woi7oeHj2QGaPmtXXDKkjhuy1hn7OXcoRMzNq86jIRg=; b=iZhxwWf9uCCh1XtKkgcx/r4qcdMJvh7B5YsMy5m7NNOGDtF2mDxX7uoD926s2fp7kK xXCPI31JQhjn47xlCr0upli39kyXOTzAfdDI5YEm5ARyAeHMZTSADMvrk7hAjaWAt6t+ BBVXrL4Tc/Kz8DIz3CzlBx0euZlVHPjCcKgFtj4wdasJwxmAkeQgPjwquS542FdI7ojA Sl+eFyvCeCpwKr9Vol1GtsZ+tZuNfqtPswFV5jNhv8LmFBqMgmm0JvKWxTIxbGIcPviM A4Ay2XTGqiohk7KxtnAdA68LUwr72qS8V53bHOdBLPUigDvinnss8eQQR3KqeYt7l04W +u7Q== 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 3-v6si3507823plz.179.2018.04.10.15.44.27; Tue, 10 Apr 2018 15:45: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 S932763AbeDJWkY (ORCPT + 99 others); Tue, 10 Apr 2018 18:40:24 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46734 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932736AbeDJWkV (ORCPT ); Tue, 10 Apr 2018 18:40:21 -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 676A8E07; Tue, 10 Apr 2018 22:40:20 +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.14 134/138] vhost: validate log when IOTLB is enabled Date: Wed, 11 Apr 2018 00:25:24 +0200 Message-Id: <20180410212917.818627954@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212902.121524696@linuxfoundation.org> References: <20180410212902.121524696@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.14-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 @@ -1252,14 +1252,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);