mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH][RFC] lib: zstd: resolve maybe-uninitialized warning
@ 2023-06-14  8:09 yegorslists
  2023-06-14  8:10 ` Yegor Yefremov
  2023-06-14  8:55 ` Ahmad Fatoum
  0 siblings, 2 replies; 5+ messages in thread
From: yegorslists @ 2023-06-14  8:09 UTC (permalink / raw)
  To: barebox

From: Yegor Yefremov <yegorslists@googlemail.com>

Perform memset() at the very beginning of the ZSTD_getFrameParams()
routine.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
---
 lib/zstd/decompress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/zstd/decompress.c b/lib/zstd/decompress.c
index 19bf712881..78df7d660a 100644
--- a/lib/zstd/decompress.c
+++ b/lib/zstd/decompress.c
@@ -207,6 +207,7 @@ static size_t ZSTD_frameHeaderSize(const void *src, size_t srcSize)
 size_t ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t srcSize)
 {
 	const BYTE *ip = (const BYTE *)src;
+	memset(fparamsPtr, 0, sizeof(*fparamsPtr));
 
 	if (srcSize < ZSTD_frameHeaderSize_prefix)
 		return ZSTD_frameHeaderSize_prefix;
@@ -214,7 +215,6 @@ size_t ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t
 		if ((ZSTD_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) {
 			if (srcSize < ZSTD_skippableHeaderSize)
 				return ZSTD_skippableHeaderSize; /* magic number + skippable frame length */
-			memset(fparamsPtr, 0, sizeof(*fparamsPtr));
 			fparamsPtr->frameContentSize = ZSTD_readLE32((const char *)src + 4);
 			fparamsPtr->windowSize = 0; /* windowSize==0 means a frame is skippable */
 			return 0;
-- 
2.34.1




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

* Re: [PATCH][RFC] lib: zstd: resolve maybe-uninitialized warning
  2023-06-14  8:09 [PATCH][RFC] lib: zstd: resolve maybe-uninitialized warning yegorslists
@ 2023-06-14  8:10 ` Yegor Yefremov
  2023-06-14  8:55 ` Ahmad Fatoum
  1 sibling, 0 replies; 5+ messages in thread
From: Yegor Yefremov @ 2023-06-14  8:10 UTC (permalink / raw)
  To: barebox

On Wed, Jun 14, 2023 at 10:09 AM <yegorslists@googlemail.com> wrote:
>
> From: Yegor Yefremov <yegorslists@googlemail.com>
>
> Perform memset() at the very beginning of the ZSTD_getFrameParams()
> routine.
>
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> ---
>  lib/zstd/decompress.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/zstd/decompress.c b/lib/zstd/decompress.c
> index 19bf712881..78df7d660a 100644
> --- a/lib/zstd/decompress.c
> +++ b/lib/zstd/decompress.c
> @@ -207,6 +207,7 @@ static size_t ZSTD_frameHeaderSize(const void *src, size_t srcSize)
>  size_t ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t srcSize)
>  {
>         const BYTE *ip = (const BYTE *)src;
> +       memset(fparamsPtr, 0, sizeof(*fparamsPtr));
>
>         if (srcSize < ZSTD_frameHeaderSize_prefix)
>                 return ZSTD_frameHeaderSize_prefix;
> @@ -214,7 +215,6 @@ size_t ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t
>                 if ((ZSTD_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) {
>                         if (srcSize < ZSTD_skippableHeaderSize)
>                                 return ZSTD_skippableHeaderSize; /* magic number + skippable frame length */
> -                       memset(fparamsPtr, 0, sizeof(*fparamsPtr));
>                         fparamsPtr->frameContentSize = ZSTD_readLE32((const char *)src + 4);
>                         fparamsPtr->windowSize = 0; /* windowSize==0 means a frame is skippable */
>                         return 0;
> --
> 2.34.1

This patch is compile-tested only.

Yegor



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

* Re: [PATCH][RFC] lib: zstd: resolve maybe-uninitialized warning
  2023-06-14  8:09 [PATCH][RFC] lib: zstd: resolve maybe-uninitialized warning yegorslists
  2023-06-14  8:10 ` Yegor Yefremov
@ 2023-06-14  8:55 ` Ahmad Fatoum
  2023-06-14  9:11   ` Yegor Yefremov
  1 sibling, 1 reply; 5+ messages in thread
From: Ahmad Fatoum @ 2023-06-14  8:55 UTC (permalink / raw)
  To: yegorslists, barebox

Hello Yegor,

On 14.06.23 10:09, yegorslists@googlemail.com wrote:
> From: Yegor Yefremov <yegorslists@googlemail.com>
> 
> Perform memset() at the very beginning of the ZSTD_getFrameParams()
> routine.

I saw this too a while back and I came to the conclusion that this
is a false positive. I wasn't able to reproduce this with
GCC 12, but saw it with GCC 11 IIRC.

Cheers,
Ahmad

> 
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> ---
>  lib/zstd/decompress.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/zstd/decompress.c b/lib/zstd/decompress.c
> index 19bf712881..78df7d660a 100644
> --- a/lib/zstd/decompress.c
> +++ b/lib/zstd/decompress.c
> @@ -207,6 +207,7 @@ static size_t ZSTD_frameHeaderSize(const void *src, size_t srcSize)
>  size_t ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t srcSize)
>  {
>  	const BYTE *ip = (const BYTE *)src;
> +	memset(fparamsPtr, 0, sizeof(*fparamsPtr));
>  
>  	if (srcSize < ZSTD_frameHeaderSize_prefix)
>  		return ZSTD_frameHeaderSize_prefix;
> @@ -214,7 +215,6 @@ size_t ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t
>  		if ((ZSTD_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) {
>  			if (srcSize < ZSTD_skippableHeaderSize)
>  				return ZSTD_skippableHeaderSize; /* magic number + skippable frame length */
> -			memset(fparamsPtr, 0, sizeof(*fparamsPtr));
>  			fparamsPtr->frameContentSize = ZSTD_readLE32((const char *)src + 4);
>  			fparamsPtr->windowSize = 0; /* windowSize==0 means a frame is skippable */
>  			return 0;

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




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

* Re: [PATCH][RFC] lib: zstd: resolve maybe-uninitialized warning
  2023-06-14  8:55 ` Ahmad Fatoum
@ 2023-06-14  9:11   ` Yegor Yefremov
  2023-06-14  9:16     ` Ahmad Fatoum
  0 siblings, 1 reply; 5+ messages in thread
From: Yegor Yefremov @ 2023-06-14  9:11 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

Hi Ahmad,

On Wed, Jun 14, 2023 at 10:55 AM Ahmad Fatoum <a.fatoum@pengutronix.de> wrote:
>
> Hello Yegor,
>
> On 14.06.23 10:09, yegorslists@googlemail.com wrote:
> > From: Yegor Yefremov <yegorslists@googlemail.com>
> >
> > Perform memset() at the very beginning of the ZSTD_getFrameParams()
> > routine.
>
> I saw this too a while back and I came to the conclusion that this
> is a false positive. I wasn't able to reproduce this with
> GCC 12, but saw it with GCC 11 IIRC.

You're right. I could reproduce it with GCC 10 but not 12. So, the
patch can be dropped.

Yegor

> Cheers,
> Ahmad
>
> >
> > Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> > ---
> >  lib/zstd/decompress.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/zstd/decompress.c b/lib/zstd/decompress.c
> > index 19bf712881..78df7d660a 100644
> > --- a/lib/zstd/decompress.c
> > +++ b/lib/zstd/decompress.c
> > @@ -207,6 +207,7 @@ static size_t ZSTD_frameHeaderSize(const void *src, size_t srcSize)
> >  size_t ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t srcSize)
> >  {
> >       const BYTE *ip = (const BYTE *)src;
> > +     memset(fparamsPtr, 0, sizeof(*fparamsPtr));
> >
> >       if (srcSize < ZSTD_frameHeaderSize_prefix)
> >               return ZSTD_frameHeaderSize_prefix;
> > @@ -214,7 +215,6 @@ size_t ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t
> >               if ((ZSTD_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) {
> >                       if (srcSize < ZSTD_skippableHeaderSize)
> >                               return ZSTD_skippableHeaderSize; /* magic number + skippable frame length */
> > -                     memset(fparamsPtr, 0, sizeof(*fparamsPtr));
> >                       fparamsPtr->frameContentSize = ZSTD_readLE32((const char *)src + 4);
> >                       fparamsPtr->windowSize = 0; /* windowSize==0 means a frame is skippable */
> >                       return 0;
>
> --
> Pengutronix e.K.                           |                             |
> Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
> 31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
>



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

* Re: [PATCH][RFC] lib: zstd: resolve maybe-uninitialized warning
  2023-06-14  9:11   ` Yegor Yefremov
@ 2023-06-14  9:16     ` Ahmad Fatoum
  0 siblings, 0 replies; 5+ messages in thread
From: Ahmad Fatoum @ 2023-06-14  9:16 UTC (permalink / raw)
  To: Yegor Yefremov; +Cc: barebox

On 14.06.23 11:11, Yegor Yefremov wrote:
> Hi Ahmad,
> 
> On Wed, Jun 14, 2023 at 10:55 AM Ahmad Fatoum <a.fatoum@pengutronix.de> wrote:
>>
>> Hello Yegor,
>>
>> On 14.06.23 10:09, yegorslists@googlemail.com wrote:
>>> From: Yegor Yefremov <yegorslists@googlemail.com>
>>>
>>> Perform memset() at the very beginning of the ZSTD_getFrameParams()
>>> routine.
>>
>> I saw this too a while back and I came to the conclusion that this
>> is a false positive. I wasn't able to reproduce this with
>> GCC 12, but saw it with GCC 11 IIRC.
> 
> You're right. I could reproduce it with GCC 10 but not 12. So, the
> patch can be dropped.

Kernel doesn't have this issue, because they did a wholesale sync
with upstream zstd a while back. We should be doing that for barebox
as well and extend zstd support to PBL and kernel images (currently
only available for ubifs and squashfs).

I attempted this last year:

  https://lore.barebox.org/barebox/20220713100922.1880282-1-a.fatoum@pengutronix.de/

But it had to be reverted because it caused regressions. Might be worth
giving it another shot and fix the issues with v1.

I don't know when I will get around to it, but if you are really
determined to fix the warning, this would be one way forward :-)

Thanks,
Ahmad

> 
> Yegor
> 
>> Cheers,
>> Ahmad
>>
>>>
>>> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
>>> ---
>>>  lib/zstd/decompress.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/lib/zstd/decompress.c b/lib/zstd/decompress.c
>>> index 19bf712881..78df7d660a 100644
>>> --- a/lib/zstd/decompress.c
>>> +++ b/lib/zstd/decompress.c
>>> @@ -207,6 +207,7 @@ static size_t ZSTD_frameHeaderSize(const void *src, size_t srcSize)
>>>  size_t ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t srcSize)
>>>  {
>>>       const BYTE *ip = (const BYTE *)src;
>>> +     memset(fparamsPtr, 0, sizeof(*fparamsPtr));
>>>
>>>       if (srcSize < ZSTD_frameHeaderSize_prefix)
>>>               return ZSTD_frameHeaderSize_prefix;
>>> @@ -214,7 +215,6 @@ size_t ZSTD_getFrameParams(ZSTD_frameParams *fparamsPtr, const void *src, size_t
>>>               if ((ZSTD_readLE32(src) & 0xFFFFFFF0U) == ZSTD_MAGIC_SKIPPABLE_START) {
>>>                       if (srcSize < ZSTD_skippableHeaderSize)
>>>                               return ZSTD_skippableHeaderSize; /* magic number + skippable frame length */
>>> -                     memset(fparamsPtr, 0, sizeof(*fparamsPtr));
>>>                       fparamsPtr->frameContentSize = ZSTD_readLE32((const char *)src + 4);
>>>                       fparamsPtr->windowSize = 0; /* windowSize==0 means a frame is skippable */
>>>                       return 0;
>>
>> --
>> Pengutronix e.K.                           |                             |
>> Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
>> 31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
>> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
>>
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




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

end of thread, other threads:[~2023-06-14  9:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-14  8:09 [PATCH][RFC] lib: zstd: resolve maybe-uninitialized warning yegorslists
2023-06-14  8:10 ` Yegor Yefremov
2023-06-14  8:55 ` Ahmad Fatoum
2023-06-14  9:11   ` Yegor Yefremov
2023-06-14  9:16     ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox