Received: by 10.213.65.68 with SMTP id h4csp3466061imn; Mon, 9 Apr 2018 22:30:29 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/9B3MNfKywaLF7OvPcg6fmXcAULDfatMMVpEZLQKDdDDtOL261Shkj01oJTngA3uIi7qvd X-Received: by 10.98.163.74 with SMTP id s71mr1558239pfe.72.1523338229503; Mon, 09 Apr 2018 22:30:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523338229; cv=none; d=google.com; s=arc-20160816; b=y6enoZAvowhqbw+xaeRUHZ17nrTBKEldPKEkEGcs9/wIxU7q7ZjHhUd/M6l+OROq7K SyhZAnPlCf+6gtupiTQ+WBH1SIgrD+Dd16L+BFR1YucAWIOHNRQ07b8ZZGruZfLcbQs5 zz1SqOC/c2Pi145nriHz7Tf0mPJm6Yrv44h85AJjHPJPC4CpH1zhnTPQAJlFNWL5lB8u SCkrNSyAGWTdGqu93Y4QoWJEo4IQRaECkfCFudtziV9FaBoYKDmMSYJ7HyDmO2T+GYq/ 0yMerMxQY0anwgw452ERN9z8oEaodpP01zS4tr2dbJB/h6OgWKigADtV5vfGSni8+H3f mFDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=MwBvImhGts1XUdI/sG4ty74jEhndYuRL5gmdhgNewRM=; b=U9dl2L/EWiYUSczdkNyVPhxlcGmaiGwXQWbxsb8kCjXsUZGK+TzgWGpB62ya41JGYR vEq774k4Nzlwi+hU3zk3E1EfSOGVwV3CuasRFzdKlQTJkCJWheNGyLWQt8l1yDO9HxZw oggg7fzWfy2qjCKECAP+lTaO3TK8Fe8hgzH1XyLpYM6vdSvhflcnVfN0RnEtNva5FGp2 TRe+jVTifwQZ+vCyOuw3Vv8o3FWW/x2eBH6QPlgF7cVCmDsDJMB8vbn9TzqAKCVooUm/ v/lgfkoO5+FwkCP/74M2p95Rg2QnSCIbn6mmWMo98foAWsuhxLKAl3FxENxO/8m6sc/J rWwg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3-v6si1888164plw.626.2018.04.09.22.29.52; Mon, 09 Apr 2018 22:30:29 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752184AbeDJF1L (ORCPT + 99 others); Tue, 10 Apr 2018 01:27:11 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50628 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751595AbeDJF1I (ORCPT ); Tue, 10 Apr 2018 01:27:08 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 59555A2C76; Tue, 10 Apr 2018 05:27:08 +0000 (UTC) Received: from localhost (ovpn-116-126.ams2.redhat.com [10.36.116.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 187E9218CC09; Tue, 10 Apr 2018 05:27:06 +0000 (UTC) From: Stefan Hajnoczi To: virtualization@lists.linux-foundation.org Cc: syzkaller-bugs@googlegroups.com, mst@redhat.com, Linus Torvalds , kvm@vger.kernel.org, jasowang@redhat.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Stefan Hajnoczi Subject: [PATCH v2 1/2] vhost: fix vhost_vq_access_ok() log check Date: Tue, 10 Apr 2018 13:26:29 +0800 Message-Id: <20180410052630.11270-2-stefanha@redhat.com> In-Reply-To: <20180410052630.11270-1-stefanha@redhat.com> References: <20180410052630.11270-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 10 Apr 2018 05:27:08 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 10 Apr 2018 05:27:08 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit d65026c6c62e7d9616c8ceb5a53b68bcdc050525 ("vhost: validate log when IOTLB is enabled") introduced a regression. The logic was originally: if (vq->iotlb) return 1; return A && B; After the patch the short-circuit logic for A was inverted: if (A || vq->iotlb) return A; return B; This patch fixes the regression by rewriting the checks in the obvious way, no longer returning A when vq->iotlb is non-NULL (which is hard to understand). Reported-by: syzbot+65a84dde0214b0387ccd@syzkaller.appspotmail.com Cc: Jason Wang Signed-off-by: Stefan Hajnoczi --- drivers/vhost/vhost.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 5320039671b7..93fd0c75b0d8 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -1244,10 +1244,12 @@ static int vq_log_access_ok(struct vhost_virtqueue *vq, /* Caller should have vq mutex and device mutex */ int vhost_vq_access_ok(struct vhost_virtqueue *vq) { - int ret = vq_log_access_ok(vq, vq->log_base); + if (!vq_log_access_ok(vq, vq->log_base)) + return 0; - if (ret || vq->iotlb) - return ret; + /* Access validation occurs at prefetch time with IOTLB */ + if (vq->iotlb) + return 1; return vq_access_ok(vq, vq->num, vq->desc, vq->avail, vq->used); } -- 2.14.3