All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Halil Pasic <pasic@linux.ibm.com>
Cc: "kaplan, david" <david.kaplan@amd.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	"Hetzelt, Felicitas" <f.hetzelt@tu-berlin.de>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	virtualization <virtualization@lists.linux-foundation.org>,
	mcgrof@kernel.org, Stefan Hajnoczi <stefanha@redhat.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: Re: [PATCH V5 1/4] virtio_ring: validate used buffer length
Date: Thu, 25 Nov 2021 10:27:54 +0800	[thread overview]
Message-ID: <CACGkMEu1ZsUFt4_-R74+6JtqCr+swBzYVnQU3E+XympEcTv_CA@mail.gmail.com> (raw)
In-Reply-To: <20211124123328.5ed9ce78.pasic@linux.ibm.com>

On Wed, Nov 24, 2021 at 7:33 PM Halil Pasic <pasic@linux.ibm.com> wrote:
>
> On Wed, 24 Nov 2021 10:33:28 +0800
> Jason Wang <jasowang@redhat.com> wrote:
>
> > > > > Let's see how far we can get. But yes, maybe we were too aggressive in
> > > > > breaking things by default, a warning might be a better choice for a
> > > > > couple of cycles.
> > >
> > > Ok, considering we saw the issues with balloons I think I can post a
> > > patch to use warn instead. I wonder if we need to taint the kernel in
> > > this case.
> >
> > Rethink this, consider we still have some time, I tend to convert the
> > drivers to validate the length by themselves. Does this make sense?
>
> I do find value in doing the validation in a single place for every
> driver. This is really a common concern. But I think, not breaking
> what used to work before is a good idea. So I would opt for producing
> a warning, but otherwise preserving old behavior unless there is an
> explicit opt-in for something more strict.

Yes, I totally agree with you after more thought and discussion.

>
> BTW AFAIU if we detect a problem here, there are basically two
> cases:
> (1) Either the device is over-reporting what it has written, or
> (2) we have a memory corruption in the guest because the device has
> written beyond the end of the provided buffer. This can be because
>   (2.1) the driver provided a smaller buffer than mandated by the spec,
>   or
>   (2.2) the device is broken.
>
> Case (1) is relatively harmless, and I believe a warning for it is more
> than appropriate. Whoever sees the warning should push for a fixed device
> if possible.

Yes.

>
> Case (2) is nasty. What would be the sanest course of action if we were
> reasonably sure we have have case (2.2)?

I think that's why a per driver validation is more preferable. The
driver can choose the comfortable action, e.g for networking it may
just drop the packets.

>
> Maybe we can detect case (2) with a canary. I.e. artificially extend
> the buffer with an extra descriptor that has a poisoned buffer, and
> check if the value of that poisoned buffer is different than poison. I'm
> not sure it is worth the effort though in production.

This might work but it might cause performance overhead. I still think
doing the validation per driver is better, the driver can choose to
fix the used length and taint the kernel anyway.

Thanks

>
> Regards,
> Halil
>

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

WARNING: multiple messages have this Message-ID (diff)
From: Jason Wang <jasowang@redhat.com>
To: Halil Pasic <pasic@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	virtualization <virtualization@lists.linux-foundation.org>,
	"Hetzelt, Felicitas" <f.hetzelt@tu-berlin.de>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	"kaplan, david" <david.kaplan@amd.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Stefano Garzarella <sgarzare@redhat.com>,
	mcgrof@kernel.org, David Hildenbrand <david@redhat.com>
Subject: Re: [PATCH V5 1/4] virtio_ring: validate used buffer length
Date: Thu, 25 Nov 2021 10:27:54 +0800	[thread overview]
Message-ID: <CACGkMEu1ZsUFt4_-R74+6JtqCr+swBzYVnQU3E+XympEcTv_CA@mail.gmail.com> (raw)
In-Reply-To: <20211124123328.5ed9ce78.pasic@linux.ibm.com>

On Wed, Nov 24, 2021 at 7:33 PM Halil Pasic <pasic@linux.ibm.com> wrote:
>
> On Wed, 24 Nov 2021 10:33:28 +0800
> Jason Wang <jasowang@redhat.com> wrote:
>
> > > > > Let's see how far we can get. But yes, maybe we were too aggressive in
> > > > > breaking things by default, a warning might be a better choice for a
> > > > > couple of cycles.
> > >
> > > Ok, considering we saw the issues with balloons I think I can post a
> > > patch to use warn instead. I wonder if we need to taint the kernel in
> > > this case.
> >
> > Rethink this, consider we still have some time, I tend to convert the
> > drivers to validate the length by themselves. Does this make sense?
>
> I do find value in doing the validation in a single place for every
> driver. This is really a common concern. But I think, not breaking
> what used to work before is a good idea. So I would opt for producing
> a warning, but otherwise preserving old behavior unless there is an
> explicit opt-in for something more strict.

Yes, I totally agree with you after more thought and discussion.

>
> BTW AFAIU if we detect a problem here, there are basically two
> cases:
> (1) Either the device is over-reporting what it has written, or
> (2) we have a memory corruption in the guest because the device has
> written beyond the end of the provided buffer. This can be because
>   (2.1) the driver provided a smaller buffer than mandated by the spec,
>   or
>   (2.2) the device is broken.
>
> Case (1) is relatively harmless, and I believe a warning for it is more
> than appropriate. Whoever sees the warning should push for a fixed device
> if possible.

Yes.

>
> Case (2) is nasty. What would be the sanest course of action if we were
> reasonably sure we have have case (2.2)?

I think that's why a per driver validation is more preferable. The
driver can choose the comfortable action, e.g for networking it may
just drop the packets.

>
> Maybe we can detect case (2) with a canary. I.e. artificially extend
> the buffer with an extra descriptor that has a poisoned buffer, and
> check if the value of that poisoned buffer is different than poison. I'm
> not sure it is worth the effort though in production.

This might work but it might cause performance overhead. I still think
doing the validation per driver is better, the driver can choose to
fix the used length and taint the kernel anyway.

Thanks

>
> Regards,
> Halil
>


  reply	other threads:[~2021-11-25  2:28 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-27  2:21 [PATCH V5 0/4] Validate used buffer length Jason Wang
2021-10-27  2:21 ` Jason Wang
2021-10-27  2:21 ` [PATCH V5 1/4] virtio_ring: validate " Jason Wang
2021-10-27  2:21   ` Jason Wang
2021-11-02  3:18   ` Xuan Zhuo
2021-11-02  3:54     ` Jason Wang
2021-11-02  3:54       ` Jason Wang
2021-11-19 15:09   ` Halil Pasic
2021-11-19 15:09     ` Halil Pasic
2021-11-22  3:51     ` Jason Wang
2021-11-22  3:51       ` Jason Wang
2021-11-22  5:35       ` Halil Pasic
2021-11-22  5:35         ` Halil Pasic
2021-11-22  5:49         ` Halil Pasic
2021-11-22  5:49           ` Halil Pasic
2021-11-22  6:25           ` Jason Wang
2021-11-22  6:25             ` Jason Wang
2021-11-22  7:55             ` Stefano Garzarella
2021-11-22  7:55               ` Stefano Garzarella
2021-11-22 11:08               ` Stefano Garzarella
2021-11-22 11:08                 ` Stefano Garzarella
2021-11-22 14:24                 ` Halil Pasic
2021-11-22 14:24                   ` Halil Pasic
2021-11-22 16:23                   ` Stefano Garzarella
2021-11-22 16:23                     ` Stefano Garzarella
2021-11-22 13:50             ` Halil Pasic
2021-11-22 13:50               ` Halil Pasic
2021-11-23  2:30               ` Jason Wang
2021-11-23  2:30                 ` Jason Wang
2021-11-23 12:17               ` Michael S. Tsirkin
2021-11-23 12:17                 ` Michael S. Tsirkin
2021-11-23 12:43                 ` Halil Pasic
2021-11-23 12:43                   ` Halil Pasic
2021-11-22 20:23             ` Halil Pasic
2021-11-22 20:23               ` Halil Pasic
2021-11-23  2:25               ` Jason Wang
2021-11-23  2:25                 ` Jason Wang
2021-11-23 11:05                 ` Michael S. Tsirkin
2021-11-23 11:05                   ` Michael S. Tsirkin
2021-11-24  1:30                   ` Michael Ellerman
2021-11-24  1:30                     ` Michael Ellerman
2021-11-24  2:26                     ` Jason Wang
2021-11-24  2:26                       ` Jason Wang
2021-11-24  2:33                       ` Jason Wang
2021-11-24  2:33                         ` Jason Wang
2021-11-24  7:22                         ` Michael S. Tsirkin
2021-11-24  7:22                           ` Michael S. Tsirkin
2021-11-24  7:59                           ` Jason Wang
2021-11-24  7:59                             ` Jason Wang
2021-11-24  8:24                             ` Michael S. Tsirkin
2021-11-24  8:24                               ` Michael S. Tsirkin
2021-11-24  8:28                               ` Jason Wang
2021-11-24  8:28                                 ` Jason Wang
2021-11-24 11:33                         ` Halil Pasic
2021-11-24 11:33                           ` Halil Pasic
2021-11-25  2:27                           ` Jason Wang [this message]
2021-11-25  2:27                             ` Jason Wang
2021-11-22  7:42       ` Stefano Garzarella
2021-11-22  7:42         ` Stefano Garzarella
2021-10-27  2:21 ` [PATCH V5 2/4] virtio-net: don't let virtio core to validate used length Jason Wang
2021-10-27  2:21   ` Jason Wang
2021-10-27  2:21 ` [PATCH V5 3/4] virtio-blk: " Jason Wang
2021-10-27  2:21   ` Jason Wang
2021-10-27  2:21 ` [PATCH V5 4/4] virtio-scsi: don't let virtio core to validate used buffer length Jason Wang
2021-10-27  2:21   ` Jason Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACGkMEu1ZsUFt4_-R74+6JtqCr+swBzYVnQU3E+XympEcTv_CA@mail.gmail.com \
    --to=jasowang@redhat.com \
    --cc=david.kaplan@amd.com \
    --cc=f.hetzelt@tu-berlin.de \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=mst@redhat.com \
    --cc=pasic@linux.ibm.com \
    --cc=stefanha@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.