public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* Compile error with SPL_FIT_FULL_CHECK and SPL_LOAD_FIT_FULL enabled
@ 2022-02-08 15:43 Johann Neuhauser
  2022-02-08 17:12 ` Philippe REYNES
  2022-02-08 17:13 ` Simon Glass
  0 siblings, 2 replies; 5+ messages in thread
From: Johann Neuhauser @ 2022-02-08 15:43 UTC (permalink / raw)
  To: u-boot@lists.denx.de; +Cc: sjg@chromium.org

Dear developers and Simon,

we wanna run secure boot with U-Boot's SPL_FIT_SIGNATURE and FIT_SIGNATURE on our STM32MP1 boards and discovered the CVE-2021-27097.
To mitigate this vulnerability we wanna enable SPL_LOAD_FIT_FULL and SPL_FIT_FULL_CHECK.
If I compile any U-Boot SPL with the mentioned config symbols after commit 6f3c2d8a, it fails always with the following error message:

Used defconfig: stm32mp15_dhcom_basic_defconfig (+ mentioned configs enabled)
```
...
  LD      spl/lib/built-in.o
  LD      spl/u-boot-spl
/usr/bin/arm-linux-gnueabihf-ld.bfd: common/built-in.o: in function `fit_check_format':
/mnt/work/dev/u-boot/common/image-fit.c:1591: undefined reference to `fdt_check_full'
make[1]: *** [scripts/Makefile.spl:432: spl/u-boot-spl] Error 1
make: *** [Makefile:1941: spl/u-boot-spl] Error 2
```
After diging around to find the cause, we're out of ideas.
Does anyone have a clue why the needed function is not compiled in libfdt for the spl build?

Many thanks in advance.

Best regards,

Johann Neuhauser

DH electronics GmbH | Am Anger 8 | 83346 Bergen | Germany | Fon: +49 8662 4882 0
Board of Management: Stefan Daxenberger, Helmut Henschke | HRB Traunstein 9602

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

* Re: Compile error with SPL_FIT_FULL_CHECK and SPL_LOAD_FIT_FULL enabled
  2022-02-08 15:43 Compile error with SPL_FIT_FULL_CHECK and SPL_LOAD_FIT_FULL enabled Johann Neuhauser
@ 2022-02-08 17:12 ` Philippe REYNES
  2022-02-08 22:28   ` Simon Glass
  2022-02-08 17:13 ` Simon Glass
  1 sibling, 1 reply; 5+ messages in thread
From: Philippe REYNES @ 2022-02-08 17:12 UTC (permalink / raw)
  To: Johann Neuhauser, u-boot@lists.denx.de; +Cc: sjg@chromium.org

Hi Johann,

Le 08/02/2022 à 16:43, Johann Neuhauser a écrit :
> Dear developers and Simon,
>
> we wanna run secure boot with U-Boot's SPL_FIT_SIGNATURE and FIT_SIGNATURE on our STM32MP1 boards and discovered the CVE-2021-27097.
> To mitigate this vulnerability we wanna enable SPL_LOAD_FIT_FULL and SPL_FIT_FULL_CHECK.
> If I compile any U-Boot SPL with the mentioned config symbols after commit 6f3c2d8a, it fails always with the following error message:
>
> Used defconfig: stm32mp15_dhcom_basic_defconfig (+ mentioned configs enabled)
> ```
> ...
>    LD      spl/lib/built-in.o
>    LD      spl/u-boot-spl
> /usr/bin/arm-linux-gnueabihf-ld.bfd: common/built-in.o: in function `fit_check_format':
> /mnt/work/dev/u-boot/common/image-fit.c:1591: undefined reference to `fdt_check_full'
> make[1]: *** [scripts/Makefile.spl:432: spl/u-boot-spl] Error 1
> make: *** [Makefile:1941: spl/u-boot-spl] Error 2
> ```
> After diging around to find the cause, we're out of ideas.
> Does anyone have a clue why the needed function is not compiled in libfdt for the spl build?
I have reproduced this issue with this config 
(stm32mp15_dhcom_basic_defconfig (+ mentioned configs enabled)).
The function fdt_check_full is build conditionnaly:

#if !defined(FDT_ASSUME_MASK) || FDT_ASSUME_MASK != 0xff
int fdt_check_full(const void *fdt, size_t bufsize)

{

...

}

In this config FDT_ASSUME_MASK is 0xff, so the function fdt_check_full 
is not compiled.
I succeed to build (not tested) with this patch:

--- a/scripts/dtc/libfdt/fdt_ro.c
+++ b/scripts/dtc/libfdt/fdt_ro.c
@@ -937,4 +937,9 @@ int fdt_check_full(const void *fdt, size_t bufsize)
                 }
         }
  }
+#else
+int fdt_check_full(const void *fdt, size_t bufsize)
+{
+       return 0;
+}
  #endif


If simon agrees with this fix, I may sent a patch.

>
> Many thanks in advance.
>
> Best regards,
>
> Johann Neuhauser
>
> DH electronics GmbH | Am Anger 8 | 83346 Bergen | Germany | Fon: +49 8662 4882 0
> Board of Management: Stefan Daxenberger, Helmut Henschke | HRB Traunstein 9602


Regards,
Philippe



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

* Re: Compile error with SPL_FIT_FULL_CHECK and SPL_LOAD_FIT_FULL enabled
  2022-02-08 15:43 Compile error with SPL_FIT_FULL_CHECK and SPL_LOAD_FIT_FULL enabled Johann Neuhauser
  2022-02-08 17:12 ` Philippe REYNES
@ 2022-02-08 17:13 ` Simon Glass
  2022-02-09  7:31   ` Johann Neuhauser
  1 sibling, 1 reply; 5+ messages in thread
From: Simon Glass @ 2022-02-08 17:13 UTC (permalink / raw)
  To: Johann Neuhauser; +Cc: u-boot@lists.denx.de

Hi Johann,

On Tue, 8 Feb 2022 at 08:44, Johann Neuhauser
<jneuhauser@dh-electronics.com> wrote:
>
> Dear developers and Simon,
>
> we wanna run secure boot with U-Boot's SPL_FIT_SIGNATURE and FIT_SIGNATURE on our STM32MP1 boards and discovered the CVE-2021-27097.

That is already fixed in 2021.04 so you can just use a mainline U-Boot
to avoid it.

> To mitigate this vulnerability we wanna enable SPL_LOAD_FIT_FULL and SPL_FIT_FULL_CHECK.
> If I compile any U-Boot SPL with the mentioned config symbols after commit 6f3c2d8a, it fails always with the following error message:
>
> Used defconfig: stm32mp15_dhcom_basic_defconfig (+ mentioned configs enabled)
> ```
> ...
>   LD      spl/lib/built-in.o
>   LD      spl/u-boot-spl
> /usr/bin/arm-linux-gnueabihf-ld.bfd: common/built-in.o: in function `fit_check_format':
> /mnt/work/dev/u-boot/common/image-fit.c:1591: undefined reference to `fdt_check_full'
> make[1]: *** [scripts/Makefile.spl:432: spl/u-boot-spl] Error 1
> make: *** [Makefile:1941: spl/u-boot-spl] Error 2
> ```
> After diging around to find the cause, we're out of ideas.
> Does anyone have a clue why the needed function is not compiled in libfdt for the spl build?

SPL_OF_LIBFDT_ASSUME_MASK is set to 0xff so this check is not enabled.
I suspect that the value of that setting should change to 0 or 1 if
the full check is enabled.

Regards,
Simon

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

* Re: Compile error with SPL_FIT_FULL_CHECK and SPL_LOAD_FIT_FULL enabled
  2022-02-08 17:12 ` Philippe REYNES
@ 2022-02-08 22:28   ` Simon Glass
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Glass @ 2022-02-08 22:28 UTC (permalink / raw)
  To: Philippe REYNES; +Cc: Johann Neuhauser, u-boot@lists.denx.de

Hi Philippe,

On Tue, 8 Feb 2022 at 10:12, Philippe REYNES
<philippe.reynes@softathome.com> wrote:
>
> Hi Johann,
>
> Le 08/02/2022 à 16:43, Johann Neuhauser a écrit :
> > Dear developers and Simon,
> >
> > we wanna run secure boot with U-Boot's SPL_FIT_SIGNATURE and FIT_SIGNATURE on our STM32MP1 boards and discovered the CVE-2021-27097.
> > To mitigate this vulnerability we wanna enable SPL_LOAD_FIT_FULL and SPL_FIT_FULL_CHECK.
> > If I compile any U-Boot SPL with the mentioned config symbols after commit 6f3c2d8a, it fails always with the following error message:
> >
> > Used defconfig: stm32mp15_dhcom_basic_defconfig (+ mentioned configs enabled)
> > ```
> > ...
> >    LD      spl/lib/built-in.o
> >    LD      spl/u-boot-spl
> > /usr/bin/arm-linux-gnueabihf-ld.bfd: common/built-in.o: in function `fit_check_format':
> > /mnt/work/dev/u-boot/common/image-fit.c:1591: undefined reference to `fdt_check_full'
> > make[1]: *** [scripts/Makefile.spl:432: spl/u-boot-spl] Error 1
> > make: *** [Makefile:1941: spl/u-boot-spl] Error 2
> > ```
> > After diging around to find the cause, we're out of ideas.
> > Does anyone have a clue why the needed function is not compiled in libfdt for the spl build?
> I have reproduced this issue with this config
> (stm32mp15_dhcom_basic_defconfig (+ mentioned configs enabled)).
> The function fdt_check_full is build conditionnaly:
>
> #if !defined(FDT_ASSUME_MASK) || FDT_ASSUME_MASK != 0xff
> int fdt_check_full(const void *fdt, size_t bufsize)
>
> {
>
> ...
>
> }
>
> In this config FDT_ASSUME_MASK is 0xff, so the function fdt_check_full
> is not compiled.
> I succeed to build (not tested) with this patch:
>
> --- a/scripts/dtc/libfdt/fdt_ro.c
> +++ b/scripts/dtc/libfdt/fdt_ro.c
> @@ -937,4 +937,9 @@ int fdt_check_full(const void *fdt, size_t bufsize)
>                  }
>          }
>   }
> +#else
> +int fdt_check_full(const void *fdt, size_t bufsize)
> +{
> +       return 0;
> +}
>   #endif
>
>
> If simon agrees with this fix, I may sent a patch.

I suppose that is OK. It really should go upstream though, where this
code is slightly different at present.

Regards,
Simon

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

* RE: Compile error with SPL_FIT_FULL_CHECK and SPL_LOAD_FIT_FULL enabled
  2022-02-08 17:13 ` Simon Glass
@ 2022-02-09  7:31   ` Johann Neuhauser
  0 siblings, 0 replies; 5+ messages in thread
From: Johann Neuhauser @ 2022-02-09  7:31 UTC (permalink / raw)
  To: Simon Glass; +Cc: u-boot@lists.denx.de

> -----Original Message-----
> From: Simon Glass [mailto:sjg@chromium.org]
> Sent: Tuesday, February 8, 2022 6:13 PM
> 
> Hi Johann,
> 
Hi Simon,

thanks for your fast answer.

> On Tue, 8 Feb 2022 at 08:44, Johann Neuhauser
> <jneuhauser@dh-electronics.com> wrote:
> >
> > Dear developers and Simon,
> >
> > we wanna run secure boot with U-Boot's SPL_FIT_SIGNATURE and FIT_SIGNATURE on our STM32MP1 boards and discovered the CVE-2021-27097.
> 
> That is already fixed in 2021.04 so you can just use a mainline U-Boot
> to avoid it.
> 
So we don't need the FIT_FULL_CHECK config symbols to mitigate against
CVE-2021-27097 andwe're save if we use anything after 2021.04?

> > To mitigate this vulnerability we wanna enable SPL_LOAD_FIT_FULL and SPL_FIT_FULL_CHECK.
> > If I compile any U-Boot SPL with the mentioned config symbols after commit 6f3c2d8a, it fails always with the following error message:
> >
> > Used defconfig: stm32mp15_dhcom_basic_defconfig (+ mentioned configs enabled)
> > ```
> > ...
> >   LD      spl/lib/built-in.o
> >   LD      spl/u-boot-spl
> > /usr/bin/arm-linux-gnueabihf-ld.bfd: common/built-in.o: in function `fit_check_format':
> > /mnt/work/dev/u-boot/common/image-fit.c:1591: undefined reference to `fdt_check_full'
> > make[1]: *** [scripts/Makefile.spl:432: spl/u-boot-spl] Error 1
> > make: *** [Makefile:1941: spl/u-boot-spl] Error 2
> > ```
> > After diging around to find the cause, we're out of ideas.
> > Does anyone have a clue why the needed function is not compiled in libfdt for the spl build?
> 
> SPL_OF_LIBFDT_ASSUME_MASK is set to 0xff so this check is not enabled.
> I suspect that the value of that setting should change to 0 or 1 if
> the full check is enabled.
> 
I have come across this symbol before, but I did not pay any attention to it and
rather looked for the problem in Makefile's related to SPL build.
Many thanks for the hint.

> Regards,
> Simon

Best regards,
Johann

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

end of thread, other threads:[~2022-02-09  7:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-08 15:43 Compile error with SPL_FIT_FULL_CHECK and SPL_LOAD_FIT_FULL enabled Johann Neuhauser
2022-02-08 17:12 ` Philippe REYNES
2022-02-08 22:28   ` Simon Glass
2022-02-08 17:13 ` Simon Glass
2022-02-09  7:31   ` Johann Neuhauser

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