From: "Michael S. Tsirkin" <mst@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Max Gurtovoy <mgurtovoy@nvidia.com>,
israelr@nvidia.com, virtualization@lists.linux.dev,
linux-block@vger.kernel.org, oren@nvidia.com, nitzanc@nvidia.com,
dbenbasat@nvidia.com, smalin@nvidia.com, larora@nvidia.com,
izach@nvidia.com, aaptel@nvidia.com, parav@nvidia.com,
kvm@vger.kernel.org
Subject: Re: [PATCH v1 0/2] virtio: Add length checks for device writable portions
Date: Thu, 27 Feb 2025 03:53:20 -0500 [thread overview]
Message-ID: <20250227034434-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20250227081747.GE85709@fedora>
On Thu, Feb 27, 2025 at 04:17:47PM +0800, Stefan Hajnoczi wrote:
> On Tue, Feb 25, 2025 at 01:31:04AM +0200, Max Gurtovoy wrote:
> > Hi,
> >
> > This patch series introduces safety checks in virtio-blk and virtio-fs
> > drivers to ensure proper handling of device-writable buffer lengths as
> > specified by the virtio specification.
> >
> > The virtio specification states:
> > "The driver MUST NOT make assumptions about data in device-writable
> > buffers beyond the first len bytes, and SHOULD ignore this data."
> >
> > To align with this requirement, we introduce checks in both drivers to
> > verify that the length of data written by the device is at least as
> > large as the expected/needed payload.
> >
> > If this condition is not met, we set an I/O error status to prevent
> > processing of potentially invalid or incomplete data.
> >
> > These changes improve the robustness of the drivers and ensure better
> > compliance with the virtio specification.
> >
> > Max Gurtovoy (2):
> > virtio_blk: add length check for device writable portion
> > virtio_fs: add length check for device writable portion
> >
> > drivers/block/virtio_blk.c | 20 ++++++++++++++++++++
> > fs/fuse/virtio_fs.c | 9 +++++++++
> > 2 files changed, 29 insertions(+)
> >
> > --
> > 2.18.1
> >
>
> There are 3 cases:
> 1. The device reports len correctly.
> 2. The device reports len incorrectly, but the in buffers contain valid
> data.
> 3. The device reports len incorrectly and the in buffers contain invalid
> data.
>
> Case 1 does not change behavior.
>
> Case 3 never worked in the first place. This patch might produce an
> error now where garbage was returned in the past.
>
> It's case 2 that I'm worried about: users won't be happy if the driver
> stops working with a device that previously worked.
>
> Should we really risk breakage for little benefit?
>
> I remember there were cases of invalid len values reported by devices in
> the past. Michael might have thoughts about this.
>
> Stefan
Indeed, there were. This is where Jason's efforts to validate
length stalled.
See message id 20230526063041.18359-1-jasowang@redhat.com
I am not sure I get the motivation for this patch. And yes, seems to
risky especially for blk. If it's to help device validation, I suggest a
Kconfig option.
--
MST
next prev parent reply other threads:[~2025-02-27 8:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-24 23:31 [PATCH v1 0/2] virtio: Add length checks for device writable portions Max Gurtovoy
2025-02-24 23:31 ` [PATCH 1/2] virtio_blk: add length check for device writable portion Max Gurtovoy
2025-05-14 12:41 ` Michael S. Tsirkin
2025-02-24 23:31 ` [PATCH 2/2] virtio_fs: " Max Gurtovoy
2025-02-27 8:17 ` [PATCH v1 0/2] virtio: Add length checks for device writable portions Stefan Hajnoczi
2025-02-27 8:53 ` Michael S. Tsirkin [this message]
2025-02-27 13:53 ` Max Gurtovoy
2025-05-14 12:40 ` Michael S. Tsirkin
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=20250227034434-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=aaptel@nvidia.com \
--cc=dbenbasat@nvidia.com \
--cc=israelr@nvidia.com \
--cc=izach@nvidia.com \
--cc=kvm@vger.kernel.org \
--cc=larora@nvidia.com \
--cc=linux-block@vger.kernel.org \
--cc=mgurtovoy@nvidia.com \
--cc=nitzanc@nvidia.com \
--cc=oren@nvidia.com \
--cc=parav@nvidia.com \
--cc=smalin@nvidia.com \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox