Received: by 10.213.65.68 with SMTP id h4csp696554imn; Tue, 27 Mar 2018 07:10:03 -0700 (PDT) X-Google-Smtp-Source: AG47ELvVk5h6GoA/1b7vCVJLMo53EfDKtijYvuvpBs+++zn3yJDCZFxyYg1hEAkkqaipj+Vu9M6X X-Received: by 2002:a17:902:2d01:: with SMTP id o1-v6mr27384367plb.309.1522159802937; Tue, 27 Mar 2018 07:10:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522159802; cv=none; d=google.com; s=arc-20160816; b=bs95oGROnjpZnDOt0PHZP68uBy9rMN45TdSyEwfNJZAB6IxWXdL7hYQW3EYqq9E1EI 4OGYO9UMXbryi83NP4urTsryYGXIKfZgLciLlUUctlFrXHliddfo3cRlaFCTQPYTQjRq zRSDPevUTkPCw4bGsHRzUiBBzuAJziKkMOXQpmlWKsORlrcRGU/yl5MsftDxTZkE3DPr OeLFldFiR5NyvDlipl08oL3BxK+0sdH8PciH1kUYxbBqjBlHTE6jTXVBRfmgVWK5YmaN P8Dq/tjPadIpLyvrnvHL8XehXsVoEeLMKMEQnmMN05Aa1sVg7TrsBnBSEYBAPPmFwwGM IqdQ== 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=ufpFTua0oXS0md8Cn1VyYL+c11FgRz0QfSFKFT9jvls=; b=bAm4rsscyRF5+Qm1P8hbrvNOZyqufDZYmQ+6Kk2grtNBp6O4VU2aMDxvbulz7LaiVA l+2gIkbnBre9zmeqnIhcaGzIFFkMThMLqQCgPHVrCwuNwY9lKY3e0R+dsf+cEzVh+Ys9 XUu0r3aP5gQtfyPYaBYgWBhHRXrxhTdpsCsBQ8jKKCEHIO9IUrEskuqqaLab7UE6hgg/ vCg0Mmyju2V5+K/JOFkRc+YpcmBKI3ZsWKZHuIr349H1Zx4EoNmbG9hoaBv4HBDjdTRK IkIGwL3/4F2U7DvcaQWqjzuA2yI29HlEHuphGEuwxe1KXOXpQ9faWYJqrj+lVsnosicc GoUQ== 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 w24-v6si1287448plq.553.2018.03.27.07.09.47; Tue, 27 Mar 2018 07:10:02 -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 S1753082AbeC0OHb (ORCPT + 99 others); Tue, 27 Mar 2018 10:07:31 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36100 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752672AbeC0OH3 (ORCPT ); Tue, 27 Mar 2018 10:07:29 -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 F1FA67CBBA; Tue, 27 Mar 2018 14:07:28 +0000 (UTC) Received: from redhat.com (ovpn-124-179.rdu2.redhat.com [10.10.124.179]) by smtp.corp.redhat.com (Postfix) with SMTP id 1B59F6F9E6; Tue, 27 Mar 2018 14:07:28 +0000 (UTC) Date: Tue, 27 Mar 2018 17:07:27 +0300 From: "Michael S. Tsirkin" To: Suzuki K Poulose Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, cdall@kernel.org, marc.zyngier@arm.com, punit.agrawal@arm.com, will.deacon@arm.com, catalin.marinas@arm.com, pbonzini@redhat.com, rkrcmar@redhat.com, ard.biesheuvel@linaro.org, peter.maydell@linaro.org, kristina.martsenko@arm.com, mark.rutland@arm.com, Jason Wang , Jean-Philippe Brucker Subject: Re: [PATCH v2 01/17] virtio: mmio-v1: Validate queue PFN Message-ID: <20180327170119-mutt-send-email-mst@kernel.org> References: <1522156531-28348-1-git-send-email-suzuki.poulose@arm.com> <1522156531-28348-2-git-send-email-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1522156531-28348-2-git-send-email-suzuki.poulose@arm.com> 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.2]); Tue, 27 Mar 2018 14:07:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Tue, 27 Mar 2018 14:07:29 +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 Tue, Mar 27, 2018 at 02:15:11PM +0100, Suzuki K Poulose wrote: > virtio-mmio with virtio-v1 uses a 32bit PFN for the queue. > If the queue pfn is too large to fit in 32bits, which > we could hit on arm64 systems with 52bit physical addresses > (even with 64K page size), we simply miss out a proper link > to the other side of the queue. > > Add a check to validate the PFN, rather than silently breaking > the devices. > > Cc: "Michael S. Tsirkin" > Cc: Jason Wang > Cc: Marc Zyngier > Cc: Christoffer Dall > Cc: Peter Maydel > Cc: Jean-Philippe Brucker > Signed-off-by: Suzuki K Poulose OK - seems harmless so I will queue this. But I really think effort should be spent on adding v1.0 support in QEMU. > --- > drivers/virtio/virtio_mmio.c | 18 ++++++++++++++++-- > 1 file changed, 16 insertions(+), 2 deletions(-) > > diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c > index 67763d3..b2f9b5c 100644 > --- a/drivers/virtio/virtio_mmio.c > +++ b/drivers/virtio/virtio_mmio.c > @@ -397,9 +397,21 @@ static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned index, > /* Activate the queue */ > writel(virtqueue_get_vring_size(vq), vm_dev->base + VIRTIO_MMIO_QUEUE_NUM); > if (vm_dev->version == 1) { > + u64 q_pfn = virtqueue_get_desc_addr(vq) >> PAGE_SHIFT; > + > + /* > + * virtio-mmio v1 uses a 32bit QUEUE PFN. If we have something > + * that doesn't fit in 32bit, fail the setup rather than > + * pretending to be successful. > + */ > + if (q_pfn >> 32) { > + dev_err(&vdev->dev, "virtio-mmio: queue address too large\n"); > + err = -ENOMEM; > + goto error_bad_pfn; > + } > + > writel(PAGE_SIZE, vm_dev->base + VIRTIO_MMIO_QUEUE_ALIGN); > - writel(virtqueue_get_desc_addr(vq) >> PAGE_SHIFT, > - vm_dev->base + VIRTIO_MMIO_QUEUE_PFN); > + writel(q_pfn, vm_dev->base + VIRTIO_MMIO_QUEUE_PFN); > } else { > u64 addr; > > @@ -430,6 +442,8 @@ static struct virtqueue *vm_setup_vq(struct virtio_device *vdev, unsigned index, > > return vq; > > +error_bad_pfn: > + vring_del_virtqueue(vq); > error_new_virtqueue: > if (vm_dev->version == 1) { > writel(0, vm_dev->base + VIRTIO_MMIO_QUEUE_PFN); > -- > 2.7.4