Received: by 10.213.65.68 with SMTP id h4csp3025509imn; Mon, 9 Apr 2018 12:58:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx48K08TrSkF5bsDIdJYciQ0LiTKrjNBV5pgLEZRn7ys3KomQiRTn934YOeqCjEuzNxTWPFaI X-Received: by 2002:a17:902:a588:: with SMTP id az8-v6mr6448773plb.35.1523303881961; Mon, 09 Apr 2018 12:58:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523303881; cv=none; d=google.com; s=arc-20160816; b=s3ALJqSayto+kZqO9tkXuZwRh3RAw54jDMn0fndDDsP4x+uqEf9WhsfiW2268a28fZ xuR5ck5Pxj1gISNgf2R+Fro0HxpMBaGbFOkumVOXHS5lOUcN7/60Vt2LAewUQiWVW6oI x8psewOX/6ZL4wPJMzzdqou1QSYFc35g3CxjQVU8SWKp/w25Mx6TVr0bDoUA6Q+SI9jR j3wTvk+OpLTAhRFVu3TUHO2ewOfQrqEXXmsSGhVCtsfsVmdfWiyIkJVNU7HvwuZCfuNn stMKJVKpXDGy2fPPiu5ZP+nDnxwu8g/UdMpzGPC/kFqyv0H3xv9sebamkp+AsBa2VdNz oV4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=AlLvDV/VzKvW5qubQIeJSi8vZ/Z0CGQbq96u39dtq/c=; b=rkwWS5IsFDuEffoyg9XV3XEEBW2t6jLXIjUMcs0/brM9HWBwl+FIVnQ1zasOi7jg+P 8JfNi7ZewVWz81c7cTsG+vv4EOXn5yZCeplfDtKvaDzlhef8vqh5Z5afaTVywIrkNi6r iABJhgJh9kodFcdEcoJkjno9bV737+e4Cj4OqsZ2Ifl8kW8nSQG6YbY3UBxEPnq6kLn2 jDffEG4qJS2U+WyjCWzV2etB0E4Ri+kPPT9KuYLM6QlOMSoBt0BhYndh5jTHCIAJfj4a kY38ubcUDuwChGJmKPG1Ticp4B01LhWYbVkiMRlodBpMtGZxEg66lwRvq1g8WOX7jU4T +j4A== 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 j2si9224pgn.815.2018.04.09.12.57.24; Mon, 09 Apr 2018 12:58:01 -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 S1753734AbeDITyi (ORCPT + 99 others); Mon, 9 Apr 2018 15:54:38 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41252 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751549AbeDITyh (ORCPT ); Mon, 9 Apr 2018 15:54:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 105B6EAEB2; Mon, 9 Apr 2018 19:54:37 +0000 (UTC) Received: from redhat.com (ovpn-125-238.rdu2.redhat.com [10.10.125.238]) by smtp.corp.redhat.com (Postfix) with SMTP id 954EC1C701; Mon, 9 Apr 2018 19:54:34 +0000 (UTC) Date: Mon, 9 Apr 2018 22:54:34 +0300 From: "Michael S. Tsirkin" To: Linus Torvalds Cc: Stefan Hajnoczi , virtualization , Linux Kernel Mailing List , Jason Wang , KVM list , syzkaller-bugs@googlegroups.com Subject: Re: [PATCH] vhost: fix vhost_vq_access_ok() log check Message-ID: <20180409224842-mutt-send-email-mst@kernel.org> References: <20180409131021.5132-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 09 Apr 2018 19:54:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Mon, 09 Apr 2018 19:54:37 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mst@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 09, 2018 at 09:52:13AM -0700, Linus Torvalds wrote: > On Mon, Apr 9, 2018 at 6:10 AM, Stefan Hajnoczi wrote: > > @@ -1246,7 +1246,7 @@ int vhost_vq_access_ok(struct vhost_virtqueue *vq) > > { > > int ret = vq_log_access_ok(vq, vq->log_base); > > > > - if (ret || vq->iotlb) > > + if (!ret || vq->iotlb) > > return ret; > > That logic is still very non-obvious. > > This code already had one bug because of an odd illegible test > sequence. Let's not keep the crazy code. > > Why not just do the *obvious* thing, and get rid of "ret" entirely, > and make the damn thing return a boolean, and then just write it all > as > > /* Caller should have vq mutex and device mutex */ > bool vhost_vq_access_ok(struct vhost_virtqueue *vq) > { > if (!vq_log_access_ok(vq, vq->log_base)) > return false; > > if (vq->iotlb || vq_access_ok(vq, vq->num, vq->desc, > vq->avail, vq->used); > } > > which makes the logic obvious: if vq_log_access_ok() fails, then then > vhost_vq_access_ok() fails unconditionally. > > Otherwise, we need to have an iotlb, or a successful vq_access_ok() check. > > Doesn't that all make more sense, and avoid the insane "ret" value use > that is really quite subtle? > > Linus I agree it's cleaner. Stefan, I reposted your patch on netdev (since the breakage got applied there too). Would you like to self-nak it and post v2? Pls remember to CC netdev. -- MST