From: Andre Heider <a.heider@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/3] cbfs: add support for cbfs header components
Date: Thu, 15 Feb 2018 07:40:12 +0100 [thread overview]
Message-ID: <20180215064012.28557-3-a.heider@gmail.com> (raw)
In-Reply-To: <20180215064012.28557-1-a.heider@gmail.com>
This fixes walking the cbfs file list because the bound checks do not
apply to header components.
Output of coreboot's cbfstool:
Name Offset Type Size Comp
cbfs master header 0x0 cbfs header 32 none
fallback/romstage 0x80 stage 21344 none
fallback/ramstage 0x5440 stage 36848 none
config 0xe480 raw 310 none
revision 0xe600 raw 575 none
fallback/bl31 0xe880 payload 15931 none
fallback/payload 0x12700 payload 205449 none
(empty) 0x44a00 null 111768 none
header pointer 0x5fec0 cbfs header 4 none
Output of u-boot's cbfsls:
size type name
------------------------------------------
32 cbfs header cbfs master header
21344 stage fallback/romstage
36848 stage fallback/ramstage
310 raw config
575 raw revision
15931 payload fallback/bl31
205449 payload fallback/payload
111768 null (empty)
4 cbfs header header pointer
Signed-off-by: Andre Heider <a.heider@gmail.com>
---
cmd/cbfs.c | 3 +++
fs/cbfs/cbfs.c | 10 ++++++----
include/cbfs.h | 1 +
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/cmd/cbfs.c b/cmd/cbfs.c
index 736f8c4527..f5ad04c45a 100644
--- a/cmd/cbfs.c
+++ b/cmd/cbfs.c
@@ -113,6 +113,9 @@ static int do_cbfs_ls(cmd_tbl_t *cmdtp, int flag, int argc,
printf(" %8d", file_cbfs_size(file));
switch (type) {
+ case CBFS_COMPONENT_CBFSHEADER:
+ type_name = "cbfs header";
+ break;
case CBFS_TYPE_STAGE:
type_name = "stage";
break;
diff --git a/fs/cbfs/cbfs.c b/fs/cbfs/cbfs.c
index 46da8f134f..389f60702b 100644
--- a/fs/cbfs/cbfs.c
+++ b/fs/cbfs/cbfs.c
@@ -97,10 +97,12 @@ 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;
+ if (header.type != CBFS_COMPONENT_CBFSHEADER) {
+ if (header.offset < sizeof(struct cbfs_fileheader) ||
+ header.offset > header.len) {
+ file_cbfs_result = CBFS_BAD_FILE;
+ return -1;
+ }
}
newNode->next = NULL;
newNode->type = header.type;
diff --git a/include/cbfs.h b/include/cbfs.h
index f50280107b..d5d9d8ce97 100644
--- a/include/cbfs.h
+++ b/include/cbfs.h
@@ -19,6 +19,7 @@ enum cbfs_result {
};
enum cbfs_filetype {
+ CBFS_COMPONENT_CBFSHEADER = 0x02,
CBFS_TYPE_STAGE = 0x10,
CBFS_TYPE_PAYLOAD = 0x20,
CBFS_TYPE_OPTIONROM = 0x30,
--
2.16.1
next prev parent reply other threads:[~2018-02-15 6:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-15 6:40 [U-Boot] [PATCH 1/3] cmd: cbfs: fix reading the end_of_rom pointer for 64bit archs Andre Heider
2018-02-15 6:40 ` [U-Boot] [PATCH 2/3] fs: cbfs: fix locating the cbfs header Andre Heider
2018-02-22 0:08 ` Alexander Graf
2018-04-01 14:19 ` Simon Glass
2018-04-01 14:28 ` Simon Glass
2018-02-15 6:40 ` Andre Heider [this message]
2018-02-22 0:15 ` [U-Boot] [PATCH 3/3] cbfs: add support for cbfs header components Alexander Graf
2018-04-01 14:19 ` Simon Glass
2018-02-21 23:59 ` [U-Boot] [PATCH 1/3] cmd: cbfs: fix reading the end_of_rom pointer for 64bit archs Alexander Graf
2018-04-01 14:28 ` Simon Glass
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180215064012.28557-3-a.heider@gmail.com \
--to=a.heider@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox