[Skiboot] [SKIBOOT] [PATCH] core/flash: Only expect ELF header for BOOTKERNEL partition flash resource

Vasant Hegde hegdevasant at linux.vnet.ibm.com
Tue Sep 19 15:02:12 AEST 2017


On 01/01/1970 05:30 AM,  wrote:
> When loading a flash resource which isn't signed (secure and trusted
> boot) and which doesn't have a subpartition, we assume it's the
> BOOTKERNEL since previously this was the only such resource. Thus we
> also assumed it had an ELF header which we parsed to get the size of the
> partition rather than trusting the actual_size field in the FFS header.
> A previous commit (9727fe3 DT: Add ibm,firmware-versions node) added the
> version resource which isn't signed and also doesn't have a subpartition,
> thus we expect it to have an ELF header. It doesn't so we print the
> error message "FLASH: Invalid ELF header part VERSION".
>
> It is a fluke that this works currently since we load the secure boot
> header unconditionally and this happen to be the same size as the
> version partition. We also don't update the return code on error so
> happen to return OPAL_SUCCESS.

I was about to send fix for this issue. :-) In my fix I was skipping ELF header 
checking for RESOURCE_ID_VERSION. But if only  BOOTKERNEL has ELF header, then 
this patch is better.

Yeah. We have existing bug in this code and hence ibm,firmware-versions patch 
worked fine. My bad. I should have caught this earlier :-(

>
> To make this explicitly correct; only check for an ELF header if we are
> loading the BOOTKERNEL resource, otherwise use the partition size from
> the FFS header. Also set the return code on error so we don't
> erroneously return OPAL_SUCCESS. Add a check that the resource will fit
> in the supplied buffer to prevent buffer overrun.
>
> Fixes: 9727fe3 (DT: Add ibm,firmware-versions node)
>
> Reported-by: Pridhiviraj Paidipeddi <ppaidipe at in.ibm.com>
> Signed-off-by: Suraj Jitindar Singh <sjitindarsingh at gmail.com>

Patch looks good to me and works works fine on my P9 box :-)

Reviewed-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>

-Vasant



More information about the Skiboot mailing list