All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] sun4u: ensure kernel_top is always initialised
@ 2018-08-10 11:23 Mark Cave-Ayland
  2018-08-13  5:14 ` Thomas Huth
  0 siblings, 1 reply; 2+ messages in thread
From: Mark Cave-Ayland @ 2018-08-10 11:23 UTC (permalink / raw)
  To: qemu-devel, atar4qemu, thuth

Valgrind reports that when loading a non-ELF kernel, kernel_top may be used
uninitialised when checking for an initrd.

Since there are no known non-ELF kernels for SPARC64 then we can simply
initialise kernel_top to 0 and then skip the initrd load process if it hasn't
been set by load_elf().

Reported-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/sparc64/sun4u.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 74b748497e..d16843b30e 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -139,7 +139,7 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename,
     unsigned int i;
     long kernel_size;
     uint8_t *ptr;
-    uint64_t kernel_top;
+    uint64_t kernel_top = 0;
 
     linux_boot = (kernel_filename != NULL);
 
@@ -172,7 +172,7 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename,
         }
         /* load initrd above kernel */
         *initrd_size = 0;
-        if (initrd_filename) {
+        if (initrd_filename && kernel_top) {
             *initrd_addr = TARGET_PAGE_ALIGN(kernel_top);
 
             *initrd_size = load_image_targphys(initrd_filename,
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] sun4u: ensure kernel_top is always initialised
  2018-08-10 11:23 [Qemu-devel] [PATCH] sun4u: ensure kernel_top is always initialised Mark Cave-Ayland
@ 2018-08-13  5:14 ` Thomas Huth
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Huth @ 2018-08-13  5:14 UTC (permalink / raw)
  To: Mark Cave-Ayland, qemu-devel, atar4qemu

On 08/10/2018 01:23 PM, Mark Cave-Ayland wrote:
> Valgrind reports that when loading a non-ELF kernel, kernel_top may be used
> uninitialised when checking for an initrd.
> 
> Since there are no known non-ELF kernels for SPARC64 then we can simply
> initialise kernel_top to 0 and then skip the initrd load process if it hasn't
> been set by load_elf().
> 
> Reported-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> ---
>  hw/sparc64/sun4u.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
> index 74b748497e..d16843b30e 100644
> --- a/hw/sparc64/sun4u.c
> +++ b/hw/sparc64/sun4u.c
> @@ -139,7 +139,7 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename,
>      unsigned int i;
>      long kernel_size;
>      uint8_t *ptr;
> -    uint64_t kernel_top;
> +    uint64_t kernel_top = 0;
>  
>      linux_boot = (kernel_filename != NULL);
>  
> @@ -172,7 +172,7 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename,
>          }
>          /* load initrd above kernel */
>          *initrd_size = 0;
> -        if (initrd_filename) {
> +        if (initrd_filename && kernel_top) {
>              *initrd_addr = TARGET_PAGE_ALIGN(kernel_top);
>  
>              *initrd_size = load_image_targphys(initrd_filename,
> 

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-13  5:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-10 11:23 [Qemu-devel] [PATCH] sun4u: ensure kernel_top is always initialised Mark Cave-Ayland
2018-08-13  5:14 ` Thomas Huth

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.