Allow disabling non-FIT image loading from SPL
v2 cover Allow disabling non-FIT image loading from SPL
Hello all,
To address a needed feature brought up by Andreas[0], we need a way to disable SPL from loading non-FIT images.
The function spl_parse_image_header is common to all SPL loading paths (common/spl/spl_(nand|net|nor|etc..)) so we add the check here, much like the existing CONFIG_SPL_ABORT_ON_RAW_IMAGE.
My original attempt was to add CONFIG_SPL_PANIC_ON_MKIMAGE, but then if other formats are added, flaws in restricting image types may be introduced, so we would like a single option to restrict all non-FIT types vs disabling types individually.
Thanks,
Andrew
[0] https://www.mail-archive.com/u-boot at lists.denx.de/msg219253.html
Changes from v1:
- Changed to abort on non-FIT so other boot methods can be attempted.
- Made this a default if SPL_FIT_SIGNATURE is selected.
Andrew F. Davis (4):
Introduce CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE
ARM: AM57xx: Disable non-FIT based image loading for HS devices
ARM: AM437x: Disable non-FIT based image loading for HS devices
ARM: DRA7xx: Disable non-FIT based image loading for HS devices
Kconfig | 9 +++++++++ common/spl/spl.c | 5 +++++ configs/am43xx_hs_evm_defconfig | 1 + configs/am57xx_hs_evm_defconfig | 1 + configs/dra7xx_hs_evm_defconfig | 1 + 5 files changed, 17 insertions(+)
Signature · 1 line
2.10.1
PATCH v2 1/4 Introduce CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE
Introduce CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE. An SPL which define this will abort image loading if the image is not a FIT image.
--- Kconfig | 9 +++++++++ common/spl/spl.c | 5 +++++ 2 files changed, 14 insertions(+)
Kconfig +9 -0
@@ -291,6 +291,15 @@ config FIT_IMAGE_POST_PROCESS injected into the FIT creation (i.e. the blobs would have been pre- processed before being added to the FIT image). +config SPL_ABORT_ON_NON_FIT_IMAGE + bool "Disable SPL loading of non-FIT images" + default y if SPL_FIT_SIGNATURE + help + SPL will not load and image if it is not a FIT image. This is + useful for devices that only support authentication/encryption + through SPL FIT loading paths and do not want SPL falling back + to legacy image loading when a non-FIT image is present. + config SPL_DFU_SUPPORT bool "Enable SPL with DFU to load binaries to memory device" depends on USB
common/spl/spl.c +5 -0
@@ -93,6 +93,10 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image)int spl_parse_image_header (struct spl_image_info *spl_image,const struct image_header *header) { +#ifdef CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE +/* non-FIT image found, proceed to other boot methods. */ +return -EINVAL ; +#else u32 header_size =sizeof (struct image_header );if (image_get_magic (header) ==IH_MAGIC ) {
@@ -156,6 +160,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,spl_set_header_raw_uboot (spl_image); #endif } +#endif return 0 ; }
Signature · 1 line
2.10.1
PATCH v2 1/4 Introduce CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE
Hi Andrew,
Quoted 14 lines · Andrew F. Davis
Introduce
CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE. An SPL which define this will abort image loading if the image is not a FIT image.Signed-off-by Andrew F. Davis <[email protected]>--- Kconfig | 9 +++++++++ common/spl/spl.c | 5 +++++ 2 files changed, 14 insertions(+)Kconfig +0
-0
Kconfig config FIT_IMAGE_POST_PROCESS · line 294
Quoted 4 lines
Kconfig +1
-0@@ -291,6 +291,15 @@ config FIT_IMAGE_POST_PROCESS injected into the FIT creation (i.e. the blobs would have been pre- processed before being added to the FIT image). +config SPL_ABORT_ON_NON_FIT_IMAGE
We already have CONFIG_IMAGE_FORMAT_LEGACY so how about CONFIG_SPL_IMAGE_FORMAT_LEGACY instead? It can default to y if secure boot is disabled.
Quoted 16 lines
Kconfig +8
-0+ bool "Disable SPL loading of non-FIT images" + default y if SPL_FIT_SIGNATURE + help + SPL will not load and image if it is not a FIT image. This is + useful for devices that only support authentication/encryption + through SPL FIT loading paths and do not want SPL falling back + to legacy image loading when a non-FIT image is present. + config SPL_DFU_SUPPORT bool "Enable SPL with DFU to load binaries to memory device" depends on USBcommon/spl/spl.c +0
-0
common/spl/spl.c void spl_set_header_raw_uboot(struct spl_image_info *spl_image) · line 98
Quoted 6 lines
common/spl/spl.c +3
-0@@ -93,6 +93,10 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image)int spl_parse_image_header (struct spl_image_info *spl_image,const struct image_header *header) { +#ifdef CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE +/* non-FIT image found, proceed to other boot methods. */ +return -EINVAL ;
How about -EPROTONOSUPPORT since the request is not really invalid.
Quoted 13 lines
common/spl/spl.c +2
-1+#else u32 header_size =sizeof (struct image_header );if (image_get_magic (header) ==IH_MAGIC ) {@@ -156,6 +160,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,spl_set_header_raw_uboot (spl_image); #endif } +#endif return 0 ; } --
Quoted 2 lines
2.10.1
Regards,
Simon
PATCH v2 1/4 Introduce CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE
Quoted 20 lines · Simon Glass
Hi Andrew,
Quoted 17 lines · Andrew F. Davis
Introduce
CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE. An SPL which define this will abort image loading if the image is not a FIT image.Signed-off-by Andrew F. Davis <[email protected]>--- Kconfig | 9 +++++++++ common/spl/spl.c | 5 +++++ 2 files changed, 14 insertions(+)Kconfig +0
-0@@ -291,6 +291,15 @@ config FIT_IMAGE_POST_PROCESS injected into the FIT creation (i.e. the blobs would have been pre- processed before being added to the FIT image).
Quoted 6 lines
Kconfig config FIT_IMAGE_POST_PROCESS · line 294
Quoted 1 line
Kconfig +1
-0+config SPL_ABORT_ON_NON_FIT_IMAGEWe already have
CONFIG_IMAGE_FORMAT_LEGACYso how aboutCONFIG_SPL_IMAGE_FORMAT_LEGACYinstead? It can default to y if secure boot is disabled.
We also already have CONFIG_SPL_ABORT_ON_RAW_IMAGE on which this is based. If we only disable legacy image support then RAW images should still be allowed, but we will fail early anyway, we will start to need an unmaintainable amount of pre-processor logic to to handle the different image types and what is allowed/not allowed.
Even worse some boot modes don't seem to support FIT images (net, onenand) so these will alway expect legacy to work. Right now we simply have to disable these modes.
Quoted 44 lines
Quoted 16 lines
Kconfig +8
-0+ bool "Disable SPL loading of non-FIT images" + default y if SPL_FIT_SIGNATURE + help + SPL will not load and image if it is not a FIT image. This is + useful for devices that only support authentication/encryption + through SPL FIT loading paths and do not want SPL falling back + to legacy image loading when a non-FIT image is present. + config SPL_DFU_SUPPORT bool "Enable SPL with DFU to load binaries to memory device" depends on USBcommon/spl/spl.c +0
-0common/spl/spl.c void spl_set_header_raw_uboot(struct spl_image_info *spl_image) · line 98
Quoted 6 lines
common/spl/spl.c +3
-0@@ -93,6 +93,10 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image)int spl_parse_image_header (struct spl_image_info *spl_image,const struct image_header *header) { +#ifdef CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE +/* non-FIT image found, proceed to other boot methods. */ +return -EINVAL ;How about
-EPROTONOSUPPORTsince the request is not really invalid.Quoted 13 lines
common/spl/spl.c +2
-1+#else u32 header_size =sizeof (struct image_header );if (image_get_magic (header) ==IH_MAGIC ) {@@ -156,6 +160,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,spl_set_header_raw_uboot (spl_image); #endif } +#endif return 0 ; } --Quoted 2 lines
2.10.1
Regards,
Simon
PATCH v2 1/4 Introduce CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE
Hi Andrew,
Quoted 34 lines · Andrew F. Davis
Quoted 20 lines · Simon Glass
Hi Andrew,
Quoted 17 lines · Andrew F. Davis
Introduce
CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE. An SPL which define this will abort image loading if the image is not a FIT image.Signed-off-by Andrew F. Davis <[email protected]>--- Kconfig | 9 +++++++++ common/spl/spl.c | 5 +++++ 2 files changed, 14 insertions(+)Kconfig +0
-0@@ -291,6 +291,15 @@ config FIT_IMAGE_POST_PROCESS injected into the FIT creation (i.e. the blobs would have been pre- processed before being added to the FIT image).Quoted 6 lines
Kconfig config FIT_IMAGE_POST_PROCESS · line 294
Quoted 1 line
Kconfig +1
-0+config SPL_ABORT_ON_NON_FIT_IMAGEWe already have
CONFIG_IMAGE_FORMAT_LEGACYso how aboutCONFIG_SPL_IMAGE_FORMAT_LEGACYinstead? It can default to y if secure boot is disabled.We also already have
CONFIG_SPL_ABORT_ON_RAW_IMAGEon which this is based. If we only disable legacy image support then RAW images should still be allowed, but we will fail early anyway, we will start to need an unmaintainable amount of pre-processor logic to to handle the different image types and what is allowed/not allowed.
Quoted 3 lines
Even worse some boot modes don't seem to support FIT images (net, onenand) so these will alway expect legacy to work. Right now we simply have to disable these modes.
IMO CONFIG_SPL_ABORT_ON_RAW_IMAGE should become a positive option, to fit in with the legacy format. Otherwise we'll get very confused I think.
Quoted 38 lines
Quoted 38 lines
Quoted 17 lines
Kconfig +8
-0+ bool "Disable SPL loading of non-FIT images" + default y if SPL_FIT_SIGNATURE + help + SPL will not load and image if it is not a FIT image. This is + useful for devices that only support authentication/encryption + through SPL FIT loading paths and do not want SPL falling back + to legacy image loading when a non-FIT image is present. + config SPL_DFU_SUPPORT bool "Enable SPL with DFU to load binaries to memory device" depends on USBcommon/spl/spl.c +0
-0common/spl/spl.c void spl_set_header_raw_uboot(struct spl_image_info *spl_image) · line 98
Quoted 6 lines
common/spl/spl.c +3
-0@@ -93,6 +93,10 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image)int spl_parse_image_header (struct spl_image_info *spl_image,const struct image_header *header) { +#ifdef CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE +/* non-FIT image found, proceed to other boot methods. */ +return -EINVAL ;How about
-EPROTONOSUPPORTsince the request is not really invalid.Quoted 12 lines
common/spl/spl.c +2
-0+#else u32 header_size =sizeof (struct image_header );if (image_get_magic (header) ==IH_MAGIC ) {@@ -156,6 +160,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,spl_set_header_raw_uboot (spl_image); #endif } +#endif return 0 ; }
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
--
2.10.1
Regards,
Simon
PATCH v2 1/4 Introduce CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE
Quoted 37 lines · Simon Glass
Hi Andrew,
Quoted 34 lines · Andrew F. Davis
Quoted 20 lines · Simon Glass
Hi Andrew,
Quoted 17 lines · Andrew F. Davis
Introduce
CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE. An SPL which define this will abort image loading if the image is not a FIT image.Signed-off-by Andrew F. Davis <[email protected]>--- Kconfig | 9 +++++++++ common/spl/spl.c | 5 +++++ 2 files changed, 14 insertions(+)Kconfig +0
-0@@ -291,6 +291,15 @@ config FIT_IMAGE_POST_PROCESS injected into the FIT creation (i.e. the blobs would have been pre- processed before being added to the FIT image).Quoted 6 lines
Kconfig config FIT_IMAGE_POST_PROCESS · line 294
Quoted 1 line
Kconfig +1
-0+config SPL_ABORT_ON_NON_FIT_IMAGEWe already have
CONFIG_IMAGE_FORMAT_LEGACYso how aboutCONFIG_SPL_IMAGE_FORMAT_LEGACYinstead? It can default to y if secure boot is disabled.We also already have
CONFIG_SPL_ABORT_ON_RAW_IMAGEon which this is based. If we only disable legacy image support then RAW images should still be allowed, but we will fail early anyway, we will start to need an unmaintainable amount of pre-processor logic to to handle the different image types and what is allowed/not allowed.
Quoted 8 lines
Quoted 3 lines
Even worse some boot modes don't seem to support FIT images (net, onenand) so these will alway expect legacy to work. Right now we simply have to disable these modes.
IMO
CONFIG_SPL_ABORT_ON_RAW_IMAGEshould become a positive option, to fit in with the legacy format. Otherwise we'll get very confused I think.
I'm not sure what you are suggesting here, would you like
CONFIG_SPL_SUPPORT_RAW_IMAGECONFIG_SPL_SUPPORT_LEGACY_IMAGECONFIG_SPL_SUPPORT_FIT_IMAGE
And then we disable as needed? I'm not sure this will work in our case, as a new image type may be introduced and enabled by default, this will break our board security until we discover this and disabled it. The benefit of a negative option for us is that we can specify we *only* allow FIT, then it will be obvious to someone adding a new image type they will not meet this check and should not put code outside this block.
Quoted 45 lines
Quoted 38 lines
Quoted 38 lines
Quoted 17 lines
Kconfig +8
-0+ bool "Disable SPL loading of non-FIT images" + default y if SPL_FIT_SIGNATURE + help + SPL will not load and image if it is not a FIT image. This is + useful for devices that only support authentication/encryption + through SPL FIT loading paths and do not want SPL falling back + to legacy image loading when a non-FIT image is present. + config SPL_DFU_SUPPORT bool "Enable SPL with DFU to load binaries to memory device" depends on USBcommon/spl/spl.c +0
-0common/spl/spl.c void spl_set_header_raw_uboot(struct spl_image_info *spl_image) · line 98
Quoted 6 lines
common/spl/spl.c +3
-0@@ -93,6 +93,10 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image)int spl_parse_image_header (struct spl_image_info *spl_image,const struct image_header *header) { +#ifdef CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE +/* non-FIT image found, proceed to other boot methods. */ +return -EINVAL ;How about
-EPROTONOSUPPORTsince the request is not really invalid.Quoted 12 lines
common/spl/spl.c +2
-0+#else u32 header_size =sizeof (struct image_header );if (image_get_magic (header) ==IH_MAGIC ) {@@ -156,6 +160,7 @@ int spl_parse_image_header(struct spl_image_info *spl_image,spl_set_header_raw_uboot (spl_image); #endif } +#endif return 0 ; }Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
--
2.10.1Regards,
Simon
PATCH v2 1/4 Introduce CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE
Hi Andrew,
Quoted 53 lines · Andrew F. Davis
Quoted 37 lines · Simon Glass
Hi Andrew,
Quoted 34 lines · Andrew F. Davis
Quoted 20 lines · Simon Glass
Hi Andrew,
Quoted 17 lines · Andrew F. Davis
Introduce
CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE. An SPL which define this will abort image loading if the image is not a FIT image.Signed-off-by Andrew F. Davis <[email protected]>--- Kconfig | 9 +++++++++ common/spl/spl.c | 5 +++++ 2 files changed, 14 insertions(+)Kconfig +0
-0@@ -291,6 +291,15 @@ config FIT_IMAGE_POST_PROCESS injected into the FIT creation (i.e. the blobs would have been pre- processed before being added to the FIT image).Quoted 6 lines
Kconfig config FIT_IMAGE_POST_PROCESS · line 294
Quoted 1 line
Kconfig +1
-0+config SPL_ABORT_ON_NON_FIT_IMAGEWe already have
CONFIG_IMAGE_FORMAT_LEGACYso how aboutCONFIG_SPL_IMAGE_FORMAT_LEGACYinstead? It can default to y if secure boot is disabled.We also already have
CONFIG_SPL_ABORT_ON_RAW_IMAGEon which this is based. If we only disable legacy image support then RAW images should still be allowed, but we will fail early anyway, we will start to need an unmaintainable amount of pre-processor logic to to handle the different image types and what is allowed/not allowed.Quoted 8 lines
Quoted 3 lines
Even worse some boot modes don't seem to support FIT images (net, onenand) so these will alway expect legacy to work. Right now we simply have to disable these modes.
IMO
CONFIG_SPL_ABORT_ON_RAW_IMAGEshould become a positive option, to fit in with the legacy format. Otherwise we'll get very confused I think.I'm not sure what you are suggesting here, would you like
CONFIG_SPL_SUPPORT_RAW_IMAGECONFIG_SPL_SUPPORT_LEGACY_IMAGECONFIG_SPL_SUPPORT_FIT_IMAGE
Quoted 6 lines
And then we disable as needed? I'm not sure this will work in our case, as a new image type may be introduced and enabled by default, this will break our board security until we discover this and disabled it. The benefit of a negative option for us is that we can specify we *only* allow FIT, then it will be obvious to someone adding a new image type they will not meet this check and should not put code outside this block.
I don't think we add new image types often, and they should default to n just as we do for U-Boot proper. Although something odd has happened with DISABLE_IMAGE_LEGACY.
his should of thing should be caught in a security review.
Also you could add something to print a warning if secure boot is enabled but insecure boot options are available? Perhaps that should be another option, and default to y?
It's just that it is really hard to deal with multiple negative options, so best avoided if we can.
Regards,
Simon
PATCH v2 1/4 Introduce CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE
Quoted 67 lines · Simon Glass
Hi Andrew,
Quoted 53 lines · Andrew F. Davis
Quoted 37 lines · Simon Glass
Hi Andrew,
Quoted 34 lines · Andrew F. Davis
Quoted 20 lines · Simon Glass
Hi Andrew,
Quoted 17 lines · Andrew F. Davis
Introduce
CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE. An SPL which define this will abort image loading if the image is not a FIT image.Signed-off-by Andrew F. Davis <[email protected]>--- Kconfig | 9 +++++++++ common/spl/spl.c | 5 +++++ 2 files changed, 14 insertions(+)Kconfig +0
-0@@ -291,6 +291,15 @@ config FIT_IMAGE_POST_PROCESS injected into the FIT creation (i.e. the blobs would have been pre- processed before being added to the FIT image).Quoted 6 lines
Kconfig config FIT_IMAGE_POST_PROCESS · line 294
Quoted 1 line
Kconfig +1
-0+config SPL_ABORT_ON_NON_FIT_IMAGEWe already have
CONFIG_IMAGE_FORMAT_LEGACYso how aboutCONFIG_SPL_IMAGE_FORMAT_LEGACYinstead? It can default to y if secure boot is disabled.We also already have
CONFIG_SPL_ABORT_ON_RAW_IMAGEon which this is based. If we only disable legacy image support then RAW images should still be allowed, but we will fail early anyway, we will start to need an unmaintainable amount of pre-processor logic to to handle the different image types and what is allowed/not allowed.Quoted 8 lines
Quoted 3 lines
Even worse some boot modes don't seem to support FIT images (net, onenand) so these will alway expect legacy to work. Right now we simply have to disable these modes.
IMO
CONFIG_SPL_ABORT_ON_RAW_IMAGEshould become a positive option, to fit in with the legacy format. Otherwise we'll get very confused I think.I'm not sure what you are suggesting here, would you like
CONFIG_SPL_SUPPORT_RAW_IMAGECONFIG_SPL_SUPPORT_LEGACY_IMAGECONFIG_SPL_SUPPORT_FIT_IMAGEQuoted 6 lines
And then we disable as needed? I'm not sure this will work in our case, as a new image type may be introduced and enabled by default, this will break our board security until we discover this and disabled it. The benefit of a negative option for us is that we can specify we *only* allow FIT, then it will be obvious to someone adding a new image type they will not meet this check and should not put code outside this block.
I don't think we add new image types often, and they should default to n just as we do for U-Boot proper. Although something odd has happened with
DISABLE_IMAGE_LEGACY.
Quoted 9 lines
his should of thing should be caught in a security review.
Also you could add something to print a warning if secure boot is enabled but insecure boot options are available? Perhaps that should be another option, and default to y?
It's just that it is really hard to deal with multiple negative options, so best avoided if we can.
I agree in general, but this time I think this is hard to properly avoid. All that would be different with a positive option only case would be a bunch of checks that all other image modes are off, then block undefining the same code I am here.
Andrew
Quoted 3 lines
Regards,
Simon
PATCH v2 1/4 Introduce CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE
Hi Andrew,
Quoted 74 lines · Andrew F. Davis
Quoted 73 lines · Simon Glass
Hi Andrew,
Quoted 53 lines · Andrew F. Davis
Quoted 37 lines · Simon Glass
Hi Andrew,
Quoted 34 lines · Andrew F. Davis
Quoted 20 lines · Simon Glass
Hi Andrew,
Quoted 17 lines · Andrew F. Davis
Introduce
CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE. An SPL which define this will abort image loading if the image is not a FIT image.Signed-off-by Andrew F. Davis <[email protected]>--- Kconfig | 9 +++++++++ common/spl/spl.c | 5 +++++ 2 files changed, 14 insertions(+)Kconfig +0
-0@@ -291,6 +291,15 @@ config FIT_IMAGE_POST_PROCESS injected into the FIT creation (i.e. the blobs would have been pre- processed before being added to the FIT image).Quoted 6 lines
Kconfig config FIT_IMAGE_POST_PROCESS · line 294
Quoted 1 line
Kconfig +1
-0+config SPL_ABORT_ON_NON_FIT_IMAGEWe already have
CONFIG_IMAGE_FORMAT_LEGACYso how aboutCONFIG_SPL_IMAGE_FORMAT_LEGACYinstead? It can default to y if secure boot is disabled.We also already have
CONFIG_SPL_ABORT_ON_RAW_IMAGEon which this is based. If we only disable legacy image support then RAW images should still be allowed, but we will fail early anyway, we will start to need an unmaintainable amount of pre-processor logic to to handle the different image types and what is allowed/not allowed.Quoted 8 lines
Quoted 3 lines
Even worse some boot modes don't seem to support FIT images (net, onenand) so these will alway expect legacy to work. Right now we simply have to disable these modes.
IMO
CONFIG_SPL_ABORT_ON_RAW_IMAGEshould become a positive option, to fit in with the legacy format. Otherwise we'll get very confused I think.I'm not sure what you are suggesting here, would you like
CONFIG_SPL_SUPPORT_RAW_IMAGECONFIG_SPL_SUPPORT_LEGACY_IMAGECONFIG_SPL_SUPPORT_FIT_IMAGEQuoted 6 lines
And then we disable as needed? I'm not sure this will work in our case, as a new image type may be introduced and enabled by default, this will break our board security until we discover this and disabled it. The benefit of a negative option for us is that we can specify we *only* allow FIT, then it will be obvious to someone adding a new image type they will not meet this check and should not put code outside this block.
I don't think we add new image types often, and they should default to n just as we do for U-Boot proper. Although something odd has happened with
DISABLE_IMAGE_LEGACY.his should of thing should be caught in a security review.
Also you could add something to print a warning if secure boot is enabled but insecure boot options are available? Perhaps that should be another option, and default to y?
Quoted 8 lines
Quoted 3 lines
It's just that it is really hard to deal with multiple negative options, so best avoided if we can.
I agree in general, but this time I think this is hard to properly avoid. All that would be different with a positivoption only case would be a bunch of checks that all other image modes are off, then block undefining the same code I am here.
But why is SPL different from U-Boot proper on this point? It seems like we could use the same scheme in SPL as we do in U-Boot proper?
Positive options are easier to understand and combine. If we end up adding another image format it wouldn't be hard to default it to n if we are using secure boot.
Regards,
Simon
PATCH v2 1/4 Introduce CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE
Quoted 86 lines · Simon Glass
Hi Andrew,
Quoted 74 lines · Andrew F. Davis
Quoted 73 lines · Simon Glass
Hi Andrew,
Quoted 53 lines · Andrew F. Davis
Quoted 37 lines · Simon Glass
Hi Andrew,
Quoted 34 lines · Andrew F. Davis
Quoted 20 lines · Simon Glass
Hi Andrew,
Quoted 17 lines · Andrew F. Davis
Introduce
CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE. An SPL which define this will abort image loading if the image is not a FIT image.Signed-off-by Andrew F. Davis <[email protected]>--- Kconfig | 9 +++++++++ common/spl/spl.c | 5 +++++ 2 files changed, 14 insertions(+)Kconfig +0
-0@@ -291,6 +291,15 @@ config FIT_IMAGE_POST_PROCESS injected into the FIT creation (i.e. the blobs would have been pre- processed before being added to the FIT image).Quoted 6 lines
Kconfig config FIT_IMAGE_POST_PROCESS · line 294
Quoted 1 line
Kconfig +1
-0+config SPL_ABORT_ON_NON_FIT_IMAGEWe already have
CONFIG_IMAGE_FORMAT_LEGACYso how aboutCONFIG_SPL_IMAGE_FORMAT_LEGACYinstead? It can default to y if secure boot is disabled.We also already have
CONFIG_SPL_ABORT_ON_RAW_IMAGEon which this is based. If we only disable legacy image support then RAW images should still be allowed, but we will fail early anyway, we will start to need an unmaintainable amount of pre-processor logic to to handle the different image types and what is allowed/not allowed.Quoted 8 lines
Quoted 3 lines
Even worse some boot modes don't seem to support FIT images (net, onenand) so these will alway expect legacy to work. Right now we simply have to disable these modes.
IMO
CONFIG_SPL_ABORT_ON_RAW_IMAGEshould become a positive option, to fit in with the legacy format. Otherwise we'll get very confused I think.I'm not sure what you are suggesting here, would you like
CONFIG_SPL_SUPPORT_RAW_IMAGECONFIG_SPL_SUPPORT_LEGACY_IMAGECONFIG_SPL_SUPPORT_FIT_IMAGEQuoted 6 lines
And then we disable as needed? I'm not sure this will work in our case, as a new image type may be introduced and enabled by default, this will break our board security until we discover this and disabled it. The benefit of a negative option for us is that we can specify we *only* allow FIT, then it will be obvious to someone adding a new image type they will not meet this check and should not put code outside this block.
I don't think we add new image types often, and they should default to n just as we do for U-Boot proper. Although something odd has happened with
DISABLE_IMAGE_LEGACY.his should of thing should be caught in a security review.
Also you could add something to print a warning if secure boot is enabled but insecure boot options are available? Perhaps that should be another option, and default to y?
Quoted 8 lines
Quoted 3 lines
It's just that it is really hard to deal with multiple negative options, so best avoided if we can.
I agree in general, but this time I think this is hard to properly avoid. All that would be different with a positivoption only case would be a bunch of checks that all other image modes are off, then block undefining the same code I am here.
Quoted 7 lines
But why is SPL different from U-Boot proper on this point? It seems like we could use the same scheme in SPL as we do in U-Boot proper?
Positive options are easier to understand and combine. If we end up adding another image format it wouldn't be hard to default it to n if we are using secure boot.
Right after I send this response I caved and decided to do it your way in v3: https://www.mail-archive.com/u-boot at lists.denx.de/msg238520.html
Sorry I forgot to express that here.
Thanks,
Andrew
Quoted 3 lines
Regards,
Simon
PATCH v2 2/4 ARM: AM57xx: Disable non-FIT based image loading for HS devices
In reply to Andrew F. DavisDisable support for loading non-FIT images for AM57xx platforms using the high-security (HS) device variant.
--- configs/am57xx_hs_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/am57xx_hs_evm_defconfig +1 -0
@@ -11,6 +11,7 @@ CONFIG_FIT=y CONFIG_OF_BOARD_SETUP=y CONFIG_SPL_LOAD_FIT=y CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y +CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE=y CONFIG_FIT_IMAGE_POST_PROCESS=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_VERSION_VARIABLE=y
Signature · 1 line
2.10.1
PATCH v2 3/4 ARM: AM437x: Disable non-FIT based image loading for HS devices
In reply to Andrew F. DavisDisable support for loading non-FIT images for AM437x platforms using the high-security (HS) device variant.
--- configs/am43xx_hs_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/am43xx_hs_evm_defconfig +1 -0
@@ -10,6 +10,7 @@ CONFIG_FIT=y CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=1, NAND" CONFIG_SPL_LOAD_FIT=y CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y +CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE=y CONFIG_FIT_IMAGE_POST_PROCESS=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_VERSION_VARIABLE=y
Signature · 1 line
2.10.1
PATCH v2 4/4 ARM: DRA7xx: Disable non-FIT based image loading for HS devices
In reply to Andrew F. DavisDisable support for loading non-FIT images for DRA7xx platforms using the high-security (HS) device variant.
--- configs/dra7xx_hs_evm_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/dra7xx_hs_evm_defconfig +1 -0
@@ -12,6 +12,7 @@ CONFIG_FIT=y CONFIG_OF_BOARD_SETUP=y CONFIG_SPL_LOAD_FIT=y CONFIG_SPL_FIT_IMAGE_POST_PROCESS=y +CONFIG_SPL_ABORT_ON_NON_FIT_IMAGE=y CONFIG_FIT_IMAGE_POST_PROCESS=y CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_VERSION_VARIABLE=y
Signature · 1 line
2.10.1