qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Laurent Vivier <laurent@vivier.eu>, qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: Re: [PATCH] q800: fix segfault with invalid MacROM
Date: Fri, 7 Jan 2022 08:23:43 +0100	[thread overview]
Message-ID: <d086db31-a64c-40d3-3a2d-bd5d6a7ef5bb@redhat.com> (raw)
In-Reply-To: <20220106122247.771454-1-laurent@vivier.eu>

On 06/01/2022 13.22, Laurent Vivier wrote:
> "qemu-system-m68k -M q800 -bios /dev/null" crahses with a segfault
> in q800_init().
> This happens because the code doesn't check that rom_ptr() returned
> a non-NULL pointer .
> 
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/756
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>   hw/m68k/q800.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/m68k/q800.c b/hw/m68k/q800.c
> index e4c7c9b88ad0..6261716c8f7e 100644
> --- a/hw/m68k/q800.c
> +++ b/hw/m68k/q800.c
> @@ -672,10 +672,16 @@ static void q800_init(MachineState *machine)
>   
>           /* Remove qtest_enabled() check once firmware files are in the tree */
>           if (!qtest_enabled()) {
> -            if (bios_size < 0 || bios_size > MACROM_SIZE) {
> +            if (bios_size == -1) {
>                   error_report("could not load MacROM '%s'", bios_name);
>                   exit(1);
>               }
> +            if (bios_size != MACROM_SIZE) {
> +                error_report("Invalid size for MacROM '%s': %d bytes,"
> +                             " expected %d bytes", bios_name, bios_size,
> +                             MACROM_SIZE);
> +                exit(1);
> +            }
>   
>               ptr = rom_ptr(MACROM_ADDR, MACROM_SIZE);
>               stl_phys(cs->as, 0, ldl_p(ptr));    /* reset initial SP */

Reviewed-by: Thomas Huth <thuth@redhat.com>



  parent reply	other threads:[~2022-01-07  7:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-06 12:22 [PATCH] q800: fix segfault with invalid MacROM Laurent Vivier
2022-01-06 12:38 ` Philippe Mathieu-Daudé
2022-01-07  7:23 ` Thomas Huth [this message]
2022-01-07  8:15 ` Mark Cave-Ayland
2022-01-07  8:55   ` Laurent Vivier
2022-01-07  9:47     ` BALATON Zoltan
2022-01-07 10:00       ` Laurent Vivier

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=d086db31-a64c-40d3-3a2d-bd5d6a7ef5bb@redhat.com \
    --to=thuth@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=laurent@vivier.eu \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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 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).