All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] xen/arm: kernel: Propagate the error if we fail to decompress the kernel
@ 2021-04-06 19:15 Julien Grall
  2021-04-12  6:45 ` Michal Orzel
  0 siblings, 1 reply; 4+ messages in thread
From: Julien Grall @ 2021-04-06 19:15 UTC (permalink / raw)
  To: xen-devel; +Cc: bertrand.marquis, Julien Grall

From: Julien Grall <jgrall@amazon.com>

Currently, we are ignoring any error from perform_gunzip() and replacing
the compressed kernel with the "uncompressed" kernel.

If there is a gzip failure, then it means that the output buffer may
contain garbagge. So it can result to various sort of behavior that may
be difficult to root cause.

In case of failure, free the output buffer and propagate the error.
We also need to adjust the return check for kernel_compress() as
perform_gunzip() may return a positive value.

Take the opportunity to adjust the code style for the check.

Signed-off-by: Julien Grall <jgrall@amazon.com>

---
    Changes in v2:
        - Fix build
---
 xen/arch/arm/kernel.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/kernel.c b/xen/arch/arm/kernel.c
index ab78689ed2a6..8f43caa1866d 100644
--- a/xen/arch/arm/kernel.c
+++ b/xen/arch/arm/kernel.c
@@ -292,6 +292,12 @@ static __init int kernel_decompress(struct bootmodule *mod)
     iounmap(input);
     vunmap(output);
 
+    if ( rc )
+    {
+        free_domheap_pages(pages, kernel_order_out);
+        return rc;
+    }
+
     mod->start = page_to_maddr(pages);
     mod->size = output_size;
 
@@ -503,7 +509,7 @@ int __init kernel_probe(struct kernel_info *info,
 
     /* if it is a gzip'ed image, 32bit or 64bit, uncompress it */
     rc = kernel_decompress(mod);
-    if (rc < 0 && rc != -EINVAL)
+    if ( rc && rc != -EINVAL )
         return rc;
 
 #ifdef CONFIG_ARM_64
-- 
2.17.1



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

* Re: [PATCH v2] xen/arm: kernel: Propagate the error if we fail to decompress the kernel
  2021-04-06 19:15 [PATCH v2] xen/arm: kernel: Propagate the error if we fail to decompress the kernel Julien Grall
@ 2021-04-12  6:45 ` Michal Orzel
  2021-04-18 18:26   ` Julien Grall
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Orzel @ 2021-04-12  6:45 UTC (permalink / raw)
  To: Julien Grall, xen-devel; +Cc: bertrand.marquis, Julien Grall

On 06.04.2021 21:15, Julien Grall wrote:
> From: Julien Grall <jgrall@amazon.com>
> 
> Currently, we are ignoring any error from perform_gunzip() and replacing
> the compressed kernel with the "uncompressed" kernel.
> 
> If there is a gzip failure, then it means that the output buffer may
> contain garbagge. So it can result to various sort of behavior that may
> be difficult to root cause.
> 
> In case of failure, free the output buffer and propagate the error.
> We also need to adjust the return check for kernel_compress() as
> perform_gunzip() may return a positive value.
> 
> Take the opportunity to adjust the code style for the check.
> 
> Signed-off-by: Julien Grall <jgrall@amazon.com>
> 
> ---
>     Changes in v2:
>         - Fix build
> ---

Reviewed-by: Michal Orzel <michal.orzel@arm.com>


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

* Re: [PATCH v2] xen/arm: kernel: Propagate the error if we fail to decompress the kernel
  2021-04-12  6:45 ` Michal Orzel
@ 2021-04-18 18:26   ` Julien Grall
  2021-05-10 17:47     ` PING " Julien Grall
  0 siblings, 1 reply; 4+ messages in thread
From: Julien Grall @ 2021-04-18 18:26 UTC (permalink / raw)
  To: Michal Orzel, xen-devel; +Cc: bertrand.marquis, Julien Grall

Hi Michal,

On 12/04/2021 07:45, Michal Orzel wrote:
> On 06.04.2021 21:15, Julien Grall wrote:
>> From: Julien Grall <jgrall@amazon.com>
>>
>> Currently, we are ignoring any error from perform_gunzip() and replacing
>> the compressed kernel with the "uncompressed" kernel.
>>
>> If there is a gzip failure, then it means that the output buffer may
>> contain garbagge. So it can result to various sort of behavior that may
>> be difficult to root cause.
>>
>> In case of failure, free the output buffer and propagate the error.
>> We also need to adjust the return check for kernel_compress() as
>> perform_gunzip() may return a positive value.
>>
>> Take the opportunity to adjust the code style for the check.
>>
>> Signed-off-by: Julien Grall <jgrall@amazon.com>
>>
>> ---
>>      Changes in v2:
>>          - Fix build
>> ---
> 
> Reviewed-by: Michal Orzel <michal.orzel@arm.com>

Thanks! @Stefano, can I get your acked-by?

Cheers,

-- 
Julien Grall


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

* PING Re: [PATCH v2] xen/arm: kernel: Propagate the error if we fail to decompress the kernel
  2021-04-18 18:26   ` Julien Grall
@ 2021-05-10 17:47     ` Julien Grall
  0 siblings, 0 replies; 4+ messages in thread
From: Julien Grall @ 2021-05-10 17:47 UTC (permalink / raw)
  To: xen-devel; +Cc: bertrand.marquis, Julien Grall, Michal Orzel



On 18/04/2021 19:26, Julien Grall wrote:
> On 12/04/2021 07:45, Michal Orzel wrote:
>> On 06.04.2021 21:15, Julien Grall wrote:
>>> From: Julien Grall <jgrall@amazon.com>
>>>
>>> Currently, we are ignoring any error from perform_gunzip() and replacing
>>> the compressed kernel with the "uncompressed" kernel.
>>>
>>> If there is a gzip failure, then it means that the output buffer may
>>> contain garbagge. So it can result to various sort of behavior that may
>>> be difficult to root cause.
>>>
>>> In case of failure, free the output buffer and propagate the error.
>>> We also need to adjust the return check for kernel_compress() as
>>> perform_gunzip() may return a positive value.
>>>
>>> Take the opportunity to adjust the code style for the check.
>>>
>>> Signed-off-by: Julien Grall <jgrall@amazon.com>
>>>
>>> ---
>>>      Changes in v2:
>>>          - Fix build
>>> ---
>>
>> Reviewed-by: Michal Orzel <michal.orzel@arm.com>
> 
> Thanks! @Stefano, can I get your acked-by?

Ping? I intend to commit it on Wednesday unless I hear otherwise.

Cheers,

-- 
Julien Grall


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

end of thread, other threads:[~2021-05-10 17:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-06 19:15 [PATCH v2] xen/arm: kernel: Propagate the error if we fail to decompress the kernel Julien Grall
2021-04-12  6:45 ` Michal Orzel
2021-04-18 18:26   ` Julien Grall
2021-05-10 17:47     ` PING " Julien Grall

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.