| Message ID | tencent_6C5B293C811C2C4B1C6DC17B52A6E3C87E08@qq.com |
|---|---|
| State | New |
| Delegated to: | Tom Rini |
| Headers | show |
| Series | [1/2] spl: fit: add software rollback protection for verified FIT configurations | expand |
On 4 November 2026 14:11:16 GMT, eli <xjmps7114@qq.com> wrote: Awesome. Cover letter got kerplunked. >A verified FIT is authentic but not necessarily current: replacing the >next-stage image with an older, still correctly signed image reintroduces >vulnerabilities fixed in newer firmware. Yeah. I guess, maybe we could fit a (this is the version you cant go back) flag into it. > >After signature verification succeeds, compare the configuration's >'version' property (covered by the signature; missing counts as 0) against >CONFIG_SPL_MINIMUM_FIT_VERSION and refuse to boot if it is lower. 0 >disables the check. Hmm. > >Validated on real StarFive VisionFive2 (JH7110) hardware: signed >version=2 FITs pass, a correctly signed version=1 image is rejected >independently of hash verification. > >Signed-off-by: eli <xjmps7114@qq.com> >--- > boot/Kconfig | 11 +++++++++++ > common/spl/spl_fit.c | 24 ++++++++++++++++++++++++ > 2 files changed, 35 insertions(+) > >diff --git a/boot/Kconfig b/boot/Kconfig >index ae6f09a6..7ec0bde1 100644 >--- a/boot/Kconfig >+++ b/boot/Kconfig >@@ -224,6 +224,17 @@ config SPL_FIT_SIGNATURE_MAX_SIZE > device memory. Assure this size does not extend past expected storage > space. > >+config SPL_MINIMUM_FIT_VERSION >+ int "Minimum acceptable version for FIT configurations verified by SPL" >+ depends on SPL_FIT_SIGNATURE >+ default 0 >+ help >+ Software rollback protection: when verifying a signed FIT, the SPL >+ compares the selected configuration's "version" property against >+ this value and refuses to boot if it is lower (a missing property >+ counts as version 0). This rejects older but still correctly signed >+ images. Set to 0 to disable the check. See doc/develop/spl.rst. >+ > config SPL_LOAD_FIT > bool "Enable SPL loading U-Boot as a FIT (basic fitImage features)" > depends on SPL >diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c >index 46ebcabe..9dcc58a0 100644 >--- a/common/spl/spl_fit.c >+++ b/common/spl/spl_fit.c >@@ -781,6 +781,30 @@ static int spl_simple_fit_parse(struct spl_fit_info *ctx) > if (fit_config_verify(ctx->fit, ctx->conf_node)) > return -EPERM; > puts("OK\n"); >+ >+ /* >+ * Anti-rollback: a correctly signed but older FIT must be >+ * rejected too. The configuration's "version" property is >+ * covered by its signature; a missing property counts as >+ * version 0. CONFIG_SPL_MINIMUM_FIT_VERSION == 0 disables >+ * the check. >+ */ >+ if (CONFIG_SPL_MINIMUM_FIT_VERSION > 0) { >+ u32 version = 0; >+ const fdt32_t *verp; >+ >+ verp = fdt_getprop(ctx->fit, ctx->conf_node, >+ "version", NULL); >+ if (verp) >+ version = fdt32_to_cpu(*verp); >+ printf("## Checking rollback version: FIT %u, minimum %u ... ", >+ version, (u32)CONFIG_SPL_MINIMUM_FIT_VERSION); >+ if (version < CONFIG_SPL_MINIMUM_FIT_VERSION) { >+ puts("REJECTED\n"); >+ return -EPERM; >+ } >+ puts("OK\n"); >+ } I would like to note that Samsung did this I think, well, no, hang on, I don't know. Samsung when u-boot was used by them for their uhh DL mode and crap like that, that the arb would be in uhh the BROM (boot rom) The way to implement this isn't right ISH, well, it's conventionally, "ok", but my suggestion in the way is to like add a binary flag, that like tells you a version, sign it, can be flashed, simple, and then BROM or whatever is responsible for checking, can say, oh this binary flag is kerplunked, let's not flash it, too old. > } > > /* find the node holding the images information */ > --- Thanks!
On 11/4/26 3:11 PM, eli wrote: > A verified FIT is authentic but not necessarily current: replacing the > next-stage image with an older, still correctly signed image reintroduces > vulnerabilities fixed in newer firmware. > > After signature verification succeeds, compare the configuration's > 'version' property (covered by the signature; missing counts as 0) against > CONFIG_SPL_MINIMUM_FIT_VERSION and refuse to boot if it is lower. 0 > disables the check. > > Validated on real StarFive VisionFive2 (JH7110) hardware: signed > version=2 FITs pass, a correctly signed version=1 image is rejected > independently of hash verification. > > Signed-off-by: eli <xjmps7114@qq.com> > --- > boot/Kconfig | 11 +++++++++++ > common/spl/spl_fit.c | 24 ++++++++++++++++++++++++ > 2 files changed, 35 insertions(+) > > diff --git a/boot/Kconfig b/boot/Kconfig > index ae6f09a6..7ec0bde1 100644 > --- a/boot/Kconfig > +++ b/boot/Kconfig > @@ -224,6 +224,17 @@ config SPL_FIT_SIGNATURE_MAX_SIZE > device memory. Assure this size does not extend past expected storage > space. > > +config SPL_MINIMUM_FIT_VERSION > + int "Minimum acceptable version for FIT configurations verified by SPL" > + depends on SPL_FIT_SIGNATURE > + default 0 > + help > + Software rollback protection: when verifying a signed FIT, the SPL > + compares the selected configuration's "version" property against > + this value and refuses to boot if it is lower (a missing property > + counts as version 0). This rejects older but still correctly signed > + images. Set to 0 to disable the check. See doc/develop/spl.rst. > + > config SPL_LOAD_FIT > bool "Enable SPL loading U-Boot as a FIT (basic fitImage features)" > depends on SPL > diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c > index 46ebcabe..9dcc58a0 100644 > --- a/common/spl/spl_fit.c > +++ b/common/spl/spl_fit.c > @@ -781,6 +781,30 @@ static int spl_simple_fit_parse(struct spl_fit_info *ctx) > if (fit_config_verify(ctx->fit, ctx->conf_node)) > return -EPERM; > puts("OK\n"); > + > + /* > + * Anti-rollback: a correctly signed but older FIT must be > + * rejected too. The configuration's "version" property is > + * covered by its signature; a missing property counts as > + * version 0. CONFIG_SPL_MINIMUM_FIT_VERSION == 0 disables > + * the check. > + */ > + if (CONFIG_SPL_MINIMUM_FIT_VERSION > 0) { > + u32 version = 0; > + const fdt32_t *verp; > + > + verp = fdt_getprop(ctx->fit, ctx->conf_node, > + "version", NULL); > + if (verp) > + version = fdt32_to_cpu(*verp); > + printf("## Checking rollback version: FIT %u, minimum %u ... ", > + version, (u32)CONFIG_SPL_MINIMUM_FIT_VERSION); > + if (version < CONFIG_SPL_MINIMUM_FIT_VERSION) { > + puts("REJECTED\n"); > + return -EPERM; > + } > + puts("OK\n"); > + } Hi eli! On i.MX with HAB (CONFIG_IMX_HAB), SPL_FIT_SIGNATURE is usually not set, since HAB already authenticated the whole FIT. Therefore with HAB the minimum version check never runs, because it is inside the if (CONFIG_IS_ENABLED(FIT_SIGNATURE)) {..} block. I think it should be moved out of this block. BR, Lorenz > } > > /* find the node holding the images information */
diff --git a/boot/Kconfig b/boot/Kconfig index ae6f09a6..7ec0bde1 100644 --- a/boot/Kconfig +++ b/boot/Kconfig @@ -224,6 +224,17 @@ config SPL_FIT_SIGNATURE_MAX_SIZE device memory. Assure this size does not extend past expected storage space. +config SPL_MINIMUM_FIT_VERSION + int "Minimum acceptable version for FIT configurations verified by SPL" + depends on SPL_FIT_SIGNATURE + default 0 + help + Software rollback protection: when verifying a signed FIT, the SPL + compares the selected configuration's "version" property against + this value and refuses to boot if it is lower (a missing property + counts as version 0). This rejects older but still correctly signed + images. Set to 0 to disable the check. See doc/develop/spl.rst. + config SPL_LOAD_FIT bool "Enable SPL loading U-Boot as a FIT (basic fitImage features)" depends on SPL diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c index 46ebcabe..9dcc58a0 100644 --- a/common/spl/spl_fit.c +++ b/common/spl/spl_fit.c @@ -781,6 +781,30 @@ static int spl_simple_fit_parse(struct spl_fit_info *ctx) if (fit_config_verify(ctx->fit, ctx->conf_node)) return -EPERM; puts("OK\n"); + + /* + * Anti-rollback: a correctly signed but older FIT must be + * rejected too. The configuration's "version" property is + * covered by its signature; a missing property counts as + * version 0. CONFIG_SPL_MINIMUM_FIT_VERSION == 0 disables + * the check. + */ + if (CONFIG_SPL_MINIMUM_FIT_VERSION > 0) { + u32 version = 0; + const fdt32_t *verp; + + verp = fdt_getprop(ctx->fit, ctx->conf_node, + "version", NULL); + if (verp) + version = fdt32_to_cpu(*verp); + printf("## Checking rollback version: FIT %u, minimum %u ... ", + version, (u32)CONFIG_SPL_MINIMUM_FIT_VERSION); + if (version < CONFIG_SPL_MINIMUM_FIT_VERSION) { + puts("REJECTED\n"); + return -EPERM; + } + puts("OK\n"); + } } /* find the node holding the images information */
A verified FIT is authentic but not necessarily current: replacing the next-stage image with an older, still correctly signed image reintroduces vulnerabilities fixed in newer firmware. After signature verification succeeds, compare the configuration's 'version' property (covered by the signature; missing counts as 0) against CONFIG_SPL_MINIMUM_FIT_VERSION and refuse to boot if it is lower. 0 disables the check. Validated on real StarFive VisionFive2 (JH7110) hardware: signed version=2 FITs pass, a correctly signed version=1 image is rejected independently of hash verification. Signed-off-by: eli <xjmps7114@qq.com> --- boot/Kconfig | 11 +++++++++++ common/spl/spl_fit.c | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+)