[U-Boot] [PATCH] fs: cbfs: remove wrong header validation

Bin Meng bmeng.cn at gmail.com
Wed Sep 26 07:12:28 UTC 2018


+Simon,

Hi Christian,

On Thu, Sep 20, 2018 at 10:47 PM Christian Gmeiner
<christian.gmeiner at gmail.com> wrote:
>
> Coreboot does not contain such a check:
> https://github.com/coreboot/coreboot/blob/eeb4e20b2f6d786c92fe3efb30817e90389a2bfe/src/commonlib/cbfs.c#L64
>
> Before this change cbfsinit failed with 'Bad CBFS file'. After this change all cbfs commands
> are working as expected.
>
> Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
> ---
>  fs/cbfs/cbfs.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/fs/cbfs/cbfs.c b/fs/cbfs/cbfs.c
> index 0dce639b49..2a581f0c18 100644
> --- a/fs/cbfs/cbfs.c
> +++ b/fs/cbfs/cbfs.c
> @@ -96,11 +96,7 @@ static int file_cbfs_next_file(u8 *start, u32 size, u32 align,
>                 }
>
>                 swap_file_header(&header, fileHeader);
> -               if (header.offset < sizeof(struct cbfs_fileheader) ||
> -                   header.offset > header.len) {
> -                       file_cbfs_result = CBFS_BAD_FILE;
> -                       return -1;
> -               }

It looks to me the existing codes were doing some sanity checks. Can
you elaborate why this is failing on your board? In your coreboot
reference, I don't see exactly how U-Boot codes are connected to the
coreboot one.

> +
>                 newNode->next = NULL;
>                 newNode->type = header.type;
>                 newNode->data = start + header.offset;
> --

Regards,
Bin


More information about the U-Boot mailing list