Received: from eggs.gnu.org ([2001:4830:134:3::10]:60306) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXX5s-0003iK-1d for qemu-devel@nongnu.org; Mon, 16 Mar 2015 11:38:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YXX5m-0001Qq-Um for qemu-devel@nongnu.org; Mon, 16 Mar 2015 11:38:15 -0400 Received: from e06smtp13.uk.ibm.com ([195.75.94.109]:46475) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXX5m-0001NY-MX for qemu-devel@nongnu.org; Mon, 16 Mar 2015 11:38:10 -0400 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Mar 2015 15:38:09 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 527D917D8066 for ; Mon, 16 Mar 2015 15:38:31 +0000 (GMT) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t2GFc7PC9699698 for ; Mon, 16 Mar 2015 15:38:07 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t2GFc4Pb022915 for ; Mon, 16 Mar 2015 09:38:04 -0600 Date: Mon, 16 Mar 2015 16:37:44 +0100 From: Cornelia Huck Message-ID: <20150316163744.5e4609d5.cornelia.huck@de.ibm.com> In-Reply-To: <20150316060034-mutt-send-email-mst@redhat.com> References: <20150311061935.GA13037@redhat.com> <20150311064747.GF1437@ad.nay.redhat.com> <20150311074938-mutt-send-email-mst@redhat.com> <87pp8fyddj.fsf@rustcorp.com.au> <20150311133242-mutt-send-email-mst@redhat.com> <87bnjzxbz0.fsf@rustcorp.com.au> <20150312073038-mutt-send-email-mst@redhat.com> <87bnjxwva9.fsf@rustcorp.com.au> <20150313143624-mutt-send-email-mst@redhat.com> <87bnjtmy5t.fsf@rustcorp.com.au> <20150316060034-mutt-send-email-mst@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 0/2] virtio len fixes for qemu. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: Rusty Russell , Fam Zheng , QEMU Developers , stefanha@redhat.com On Mon, 16 Mar 2015 06:03:24 +0100 "Michael S. Tsirkin" wrote: > On Mon, Mar 16, 2015 at 01:44:22PM +1030, Rusty Russell wrote: > > diff --git a/content.tex b/content.tex > > index 6ba079d..2c946a5 100644 > > --- a/content.tex > > +++ b/content.tex > > @@ -600,10 +600,19 @@ them: it is only written to by the device, and read by the driver. > > Each entry in the ring is a pair: \field{id} indicates the head entry of the > > descriptor chain describing the buffer (this matches an entry > > placed in the available ring by the guest earlier), and \field{len} the total > > -of bytes written into the buffer. The latter is extremely useful > > -for drivers using untrusted buffers: if you do not know exactly > > -how much has been written by the device, you usually have to zero > > -the buffer to ensure no data leakage occurs. > > +of bytes written into the buffer. > > + > > +\begin{note} > > +\field{len} is useful > > +for drivers using untrusted buffers: if a driver does not know exactly > > +how much has been written by the device, the driver would have to zero > > +the buffer in advance to ensure no data leakage occurs. > > + > > +For example, a network driver may hand a received buffer directly to > > +an unprivileged userspace application. If the network device has not > > +overwritten the bytes which were in that buffer, this may leak the s/may/might/ in both cases, so it doesn't get confused with MAY? > > +contents of freed memory from other processes to the application. > > +\end{note} > > > > \begin{note} > > The legacy \hyperref[intro:Virtio PCI Draft]{[Virtio PCI Draft]} > > @@ -612,6 +621,28 @@ the constant as VRING_USED_F_NO_NOTIFY, but the layout and value were > > identical. > > \end{note} > > > > +\devicenormative{\subsubsection}{Virtqueue Notification Suppression}{Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Used Ring} > > + > > +The device MUST set \field{len} prior to updating the used \field{idx}. > > + > > +The device MUST write at least \field{len} bytes to descriptor, > > +beginning at the first device-writable buffer, > > +prior to updating the used \field{idx}. > > + > > +The device MAY write more than \field{len} bytes to descriptor. > > + > > +\begin{note} > > +There are potential error cases where a device might not know what > > +parts of the buffers have been written. This is why \field{len} may > > +be an underestimate, but that's preferable to the driver believing > > +that uninitialized memory has been overwritten when it has not. > > +\end{note} > > + > > +\drivernormative{\subsubsection}{Virtqueue Notification Suppression}{Basic Facilities of a Virtio Device / Virtqueues / The Virtqueue Used Ring} > > + > > +The driver MUST NOT make assumptions about data in device-writable buffers > > +beyond the first \field{len} bytes, and SHOULD ignore it. > > it -> this data. > > Otherwise on first reading I thought "it" refers to len field. > > > + > > \subsection{Virtqueue Notification Suppression}\label{sec:Basic Facilities of a Virtio Device / Virtqueues / Virtqueue Notification Suppression} > > > > The device can suppress notifications in a manner analogous to the way > > Sounds good, let's move discussion to virtio/virtio-dev now? FWIW, this sounds good to me as well. > I think it's 1.1 material - agree? Given that nobody seems to have cared about this before, I agree.