From: Eric Blake <eblake@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>, qemu-devel@nongnu.org
Cc: Fam Zheng <fam@euphon.net>, Kevin Wolf <kwolf@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [RFC PATCH] block/null: Use 'read-zeroes' mode by default
Date: Tue, 9 Feb 2021 11:11:03 -0600 [thread overview]
Message-ID: <8abd4d2a-8afc-5386-e888-1a4302b25514@redhat.com> (raw)
In-Reply-To: <20210209170121.3310151-1-philmd@redhat.com>
On 2/9/21 11:01 AM, Philippe Mathieu-Daudé wrote:
> The null-co driver is meant for (performance) testing.
> By default, read operation does nothing, the provided buffer
> is not filled with zero values and its content is unchanged.
>
> This can confuse security experts. For example, using the default
> null-co driver, buf[] is uninitialized, the blk_pread() call
> succeeds and we then access uninitialized memory:
>
> static int guess_disk_lchs(BlockBackend *blk,
> int *pcylinders, int *pheads,
> int *psectors)
> {
> uint8_t buf[BDRV_SECTOR_SIZE];
> ...
>
> if (blk_pread(blk, 0, buf, BDRV_SECTOR_SIZE) < 0) {
> return -1;
> }
> /* test msdos magic */
> if (buf[510] != 0x55 || buf[511] != 0xaa) {
> return -1;
> }
>
> We could audit all the uninitialized buffers and the
> bdrv_co_preadv() handlers, but it is simpler to change the
> default of this testing driver. Performance tests will have
> to adapt and use 'null-co,read-zeroes=on'.
Wouldn't this rather be read-zeroes=off when doing performance testing?
>
> Suggested-by: Max Reitz <mreitz@redhat.com>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> RFC maybe a stricter approach is required?
Since the null driver is only for testing in the first place, opting in
to speed over security seems like a reasonable tradeoff. But I consider
the patch incomplete without an audit of the iotests that will want to
use explicit read-zeroes=off.
> ---
> block/null.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/null.c b/block/null.c
> index cc9b1d4ea72..f9658fd70ac 100644
> --- a/block/null.c
> +++ b/block/null.c
> @@ -93,7 +93,7 @@ static int null_file_open(BlockDriverState *bs, QDict *options, int flags,
> error_setg(errp, "latency-ns is invalid");
> ret = -EINVAL;
> }
> - s->read_zeroes = qemu_opt_get_bool(opts, NULL_OPT_ZEROES, false);
> + s->read_zeroes = qemu_opt_get_bool(opts, NULL_OPT_ZEROES, true);
> qemu_opts_del(opts);
> bs->supported_write_flags = BDRV_REQ_FUA;
> return ret;
>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2021-02-09 17:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-09 17:01 [RFC PATCH] block/null: Use 'read-zeroes' mode by default Philippe Mathieu-Daudé
2021-02-09 17:09 ` Max Reitz
2021-02-09 17:11 ` Eric Blake [this message]
2021-02-09 17:19 ` Philippe Mathieu-Daudé
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=8abd4d2a-8afc-5386-e888-1a4302b25514@redhat.com \
--to=eblake@redhat.com \
--cc=fam@euphon.net \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).