Received: by 10.192.165.156 with SMTP id m28csp231921imm; Tue, 17 Apr 2018 09:12:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+p61zK4Vga/3bXV3oVi2RURna5Z5SLwDRl/CswEEE2QXrxUTdNUbM/OD2CK/+hY1SpAQSF X-Received: by 10.99.0.4 with SMTP id 4mr2257935pga.107.1523981560474; Tue, 17 Apr 2018 09:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523981560; cv=none; d=google.com; s=arc-20160816; b=CghJUA6Hz2XYWEPQGej8eeH3PTDgmtkfDPBLyXMSFLJrStZx6oFsgaWFpimsUDsacH vdypNYrpavnFzDHf53IxmTtVrkMQAGKEUMRGw6nhgKzzQsm02IEMhy6y1GSRoDU8gjjC bhetl3z1poA/iBOBVvO31V4zSgop5B4tWAqu1zfFw1bWfwjFyTXm9vqJ5fj8OVuuepEc DCnPGscVIDa2o55pNrxaovHTbbgLuM7BSJsUsJZtYq/Am/0Fj7FQ0Ezm4btU+GJAq+cj 14umWgOpzmlrNqLP8dKYJu717D4gPv7SmpcJQIBaKUaE6yVChNNGNjGgIzdlJiwdFgeI VU4Q== 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=OmWPE69hCHHAIGAvkc1QFvjNuVEmfo6KNiEdzbPJKfw=; b=dfvBakMlNxnyt823LmUlJLQrR1wG7Y4+ND2xmfoVmil7+XxHi0ORearCLwYQi4+g/m fdNgKOlF22hGwNt7qHK3Xowgo/N4YN2LYaRsWKE3HoEY4a6b7jcGFPMQwosi2mwa4krP RbDkDa+qHkRMo8Gj7ofWTQ/oaVW8h3qyR0TpTo4S+s1m2FuEWuNIykrF2GU/Varz4x/4 rR/BB3mKwtPuat3+nDgEx07dNEJ4/BPRBcr5dBFfddRuh0Q6dYJX0ozTpe82AHxCA7PI u/yDQzRVYHjvIXGZy7uBvPp3LHE1euARauda8eHbXi2wZY5+iHYxTxklWCwBwC2so42d t4TA== 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 c87si9811782pfk.53.2018.04.17.09.12.26; Tue, 17 Apr 2018 09:12:40 -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 S1755940AbeDQQKx (ORCPT + 99 others); Tue, 17 Apr 2018 12:10:53 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36524 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755929AbeDQQKt (ORCPT ); Tue, 17 Apr 2018 12:10:49 -0400 Received: from localhost (unknown [46.44.180.42]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 2CE29D2D; Tue, 17 Apr 2018 16:10:49 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+65a84dde0214b0387ccd@syzkaller.appspotmail.com, Jason Wang , Stefan Hajnoczi , "Michael S. Tsirkin" , "David S. Miller" Subject: [PATCH 4.9 65/66] vhost: fix vhost_vq_access_ok() log check Date: Tue, 17 Apr 2018 17:59:38 +0200 Message-Id: <20180417155648.670658993@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180417155645.868055442@linuxfoundation.org> References: <20180417155645.868055442@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: Stefan Hajnoczi [ Upstream commit d14d2b78090c7de0557362b26a4ca591aa6a9faa ] 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 Acked-by: Michael S. Tsirkin Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/vhost/vhost.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -1175,10 +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) { - 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); }