qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Prasad J Pandit" <pjp@fedoraproject.org>,
	Qemu-block <qemu-block@nongnu.org>,
	"Alistair Francis" <alistair@alistair23.me>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Alexander Bulekov" <alxndr@bu.edu>,
	"Niek Linnenbank" <nieklinnenbank@gmail.com>,
	"Cleber Rosa" <crosa@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [PATCH v2 7/9] hw/sd/sdcard: Do not allow invalid SD card sizes
Date: Mon, 13 Jul 2020 21:41:48 +0100	[thread overview]
Message-ID: <CAFEAcA-kJQSZ-pudOrgutf24BG3UxA6F2ErocArs=f4sfndvTQ@mail.gmail.com> (raw)
In-Reply-To: <20200713183209.26308-8-f4bug@amsat.org>

On Mon, 13 Jul 2020 at 19:32, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> QEMU allows to create SD card with unrealistic sizes. This could
> work, but some guests (at least Linux) consider sizes that are not
> a power of 2 as a firmware bug and fix the card size to the next
> power of 2.
>

> +            error_setg(errp, "Invalid SD card size: %s", blk_size_str);
> +            g_free(blk_size_str);
> +
> +            blk_size_str = size_to_str(blk_size_aligned);
> +            error_append_hint(errp,
> +                              "SD card size has to be a power of 2, e.g. %s.\n"
> +                              "You can resize disk images with "
> +                              "'qemu-img resize <imagefile> <new-size>'\n"
> +                              "(note that this will lose data if you make the "
> +                              "image smaller than it currently is).\n",
> +                              blk_size_str);
> +            g_free(blk_size_str);

Some places that create multi-line hints with error_append_hint()
do it by calling it once per line, eg in target/arm/cpu64.c:
                error_setg(errp, "cannot disable sve128");
                error_append_hint(errp, "Disabling sve128 results in all "
                                  "vector lengths being disabled.\n");
                error_append_hint(errp, "With SVE enabled, at least one "
                                  "vector length must be enabled.\n");

Some places don't, eg in block/vhdx-log.c:
            error_append_hint(errp,  "To replay the log, run:\n"
                              "qemu-img check -r all '%s'\n",
                              bs->filename);

Most places terminate with a '\n', but some places don't, eg
crypto/block-luks.c:
       error_append_hint(errp, "Failed to write to keyslot %i", keyslot);
       return -1;

The documentation says
 * May be called multiple times.  The resulting hint should end with a
 * newline.

which isn't very clear -- you can call it multiple times, but
must you, if it's multiline?

I assume that "should end with a newline" means "must end
with a newline", and places like block-luks.c are bugs.

Markus, do you know what the intended API here is?

It looks like the implementation just tacks the hint
string onto the end of any existing hint string, in
which case multiple-line strings are fine and the same
behaviour as calling the function multiple times.
(I had assumed we might be accumulating an array of strings,
or requiring multiline strings to be multiple calls so we
could have the argument not need to be \n-terminated,
to match error_setg(), but both those assumptions
are obviously wrong.)

Anyway, I guess this multiline-message usage is something
we do already and it will DTRT, so

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>


thanks
-- PMM


  parent reply	other threads:[~2020-07-13 20:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-13 18:32 [PATCH v2 0/9] hw/sd/sdcard: Fix CVE-2020-13253 Philippe Mathieu-Daudé
2020-07-13 18:32 ` [PATCH v2 1/9] MAINTAINERS: Cc qemu-block mailing list Philippe Mathieu-Daudé
2020-07-13 18:32 ` [PATCH v2 2/9] docs/orangepi: Add instructions for resizing SD image to power of two Philippe Mathieu-Daudé
2020-07-13 19:26   ` Alistair Francis
2020-07-13 18:32 ` [PATCH v2 3/9] tests/acceptance/boot_linux: Tag tests using a SD card with 'device:sd' Philippe Mathieu-Daudé
2020-07-13 18:58   ` Alistair Francis
2020-07-14  3:11   ` Cleber Rosa
2020-07-13 18:32 ` [PATCH v2 4/9] tests/acceptance/boot_linux: Expand SD card image to power of 2 Philippe Mathieu-Daudé
2020-07-13 19:28   ` Alistair Francis
2020-07-14  3:22   ` Cleber Rosa
2020-07-14 11:55     ` Philippe Mathieu-Daudé
2020-07-13 18:32 ` [PATCH v2 5/9] hw/sd/sdcard: Restrict Class 6 commands to SCSD cards Philippe Mathieu-Daudé
2020-07-13 18:32 ` [PATCH v2 6/9] hw/sd/sdcard: Simplify realize() a bit Philippe Mathieu-Daudé
2020-07-13 18:32 ` [PATCH v2 7/9] hw/sd/sdcard: Do not allow invalid SD card sizes Philippe Mathieu-Daudé
2020-07-13 19:30   ` Alistair Francis
2020-07-13 20:41   ` Peter Maydell [this message]
2020-07-14  9:40     ` Markus Armbruster
2020-07-13 18:32 ` [PATCH v2 8/9] hw/sd/sdcard: Update coding style to make checkpatch.pl happy Philippe Mathieu-Daudé
2020-07-13 19:34   ` Alexander Bulekov
2020-07-13 18:32 ` [PATCH v2 9/9] hw/sd/sdcard: Do not switch to ReceivingData if address is invalid Philippe Mathieu-Daudé
2020-07-14 13:37 ` [PATCH v2 0/9] hw/sd/sdcard: Fix CVE-2020-13253 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='CAFEAcA-kJQSZ-pudOrgutf24BG3UxA6F2ErocArs=f4sfndvTQ@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=alistair@alistair23.me \
    --cc=alxndr@bu.edu \
    --cc=armbru@redhat.com \
    --cc=crosa@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=nieklinnenbank@gmail.com \
    --cc=philmd@redhat.com \
    --cc=pjp@fedoraproject.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wainersm@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).