diff mbox series

[v3,2/9] bloblist: check bloblist with specified buffer size

Message ID 20231222213110.660402-3-raymond.mao@linaro.org
State Changes Requested
Delegated to: Tom Rini
Headers show
Series Handoff bloblist from previous boot stage | expand

Commit Message

Raymond Mao Dec. 22, 2023, 9:31 p.m. UTC
Instead of expecting the bloblist total size to be the same as the
pre-allocated buffer size, practically we are more interested in
whether the pre-allocated buffer size is bigger than the bloblist
total size.

Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
---
Changes in v2
- New patch file created for v2.

 common/bloblist.c | 2 +-
 test/bloblist.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Simon Glass Dec. 26, 2023, 9:47 a.m. UTC | #1
Hi Raymond,

On Fri, Dec 22, 2023 at 9:31 PM Raymond Mao <raymond.mao@linaro.org> wrote:
>
> Instead of expecting the bloblist total size to be the same as the
> pre-allocated buffer size, practically we are more interested in
> whether the pre-allocated buffer size is bigger than the bloblist
> total size.
>
> Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> ---
> Changes in v2
> - New patch file created for v2.
>
>  common/bloblist.c | 2 +-
>  test/bloblist.c   | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/common/bloblist.c b/common/bloblist.c
> index ba17dd851a..db3fbb20cf 100644
> --- a/common/bloblist.c
> +++ b/common/bloblist.c
> @@ -384,7 +384,7 @@ int bloblist_check(ulong addr, uint size)

Can you please also update the function comment for bloblist_check() ?

>                 return log_msg_ret("Bad magic", -ENOENT);
>         if (hdr->version != BLOBLIST_VERSION)
>                 return log_msg_ret("Bad version", -EPROTONOSUPPORT);
> -       if (!hdr->total_size || (size && hdr->total_size != size))
> +       if (!hdr->total_size || (size && hdr->total_size > size))
>                 return log_msg_ret("Bad total size", -EFBIG);
>         if (hdr->used_size > hdr->total_size)
>                 return log_msg_ret("Bad used size", -ENOENT);
> diff --git a/test/bloblist.c b/test/bloblist.c
> index 17d9dd03d0..7dab9addf8 100644
> --- a/test/bloblist.c
> +++ b/test/bloblist.c
> @@ -207,7 +207,7 @@ static int bloblist_test_checksum(struct unit_test_state *uts)
>         hdr->flags++;
>
>         hdr->total_size--;
> -       ut_asserteq(-EFBIG, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
> +       ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
>         hdr->total_size++;
>
>         hdr->spare++;
> --
> 2.25.1
>

Regards,
Simon
Raymond Mao Dec. 27, 2023, 4:24 p.m. UTC | #2
Hi Simon,

On Tue, 26 Dec 2023 at 04:47, Simon Glass <sjg@chromium.org> wrote:

> Hi Raymond,
>
> On Fri, Dec 22, 2023 at 9:31 PM Raymond Mao <raymond.mao@linaro.org>
> wrote:
> >
> > Instead of expecting the bloblist total size to be the same as the
> > pre-allocated buffer size, practically we are more interested in
> > whether the pre-allocated buffer size is bigger than the bloblist
> > total size.
> >
> > Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
> > Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> > ---
> > Changes in v2
> > - New patch file created for v2.
> >
> >  common/bloblist.c | 2 +-
> >  test/bloblist.c   | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/common/bloblist.c b/common/bloblist.c
> > index ba17dd851a..db3fbb20cf 100644
> > --- a/common/bloblist.c
> > +++ b/common/bloblist.c
> > @@ -384,7 +384,7 @@ int bloblist_check(ulong addr, uint size)
>
> Can you please also update the function comment for bloblist_check() ?
>
> Yes. I will update it.

[...]

Regards,
Raymond
diff mbox series

Patch

diff --git a/common/bloblist.c b/common/bloblist.c
index ba17dd851a..db3fbb20cf 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -384,7 +384,7 @@  int bloblist_check(ulong addr, uint size)
 		return log_msg_ret("Bad magic", -ENOENT);
 	if (hdr->version != BLOBLIST_VERSION)
 		return log_msg_ret("Bad version", -EPROTONOSUPPORT);
-	if (!hdr->total_size || (size && hdr->total_size != size))
+	if (!hdr->total_size || (size && hdr->total_size > size))
 		return log_msg_ret("Bad total size", -EFBIG);
 	if (hdr->used_size > hdr->total_size)
 		return log_msg_ret("Bad used size", -ENOENT);
diff --git a/test/bloblist.c b/test/bloblist.c
index 17d9dd03d0..7dab9addf8 100644
--- a/test/bloblist.c
+++ b/test/bloblist.c
@@ -207,7 +207,7 @@  static int bloblist_test_checksum(struct unit_test_state *uts)
 	hdr->flags++;
 
 	hdr->total_size--;
-	ut_asserteq(-EFBIG, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
+	ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
 	hdr->total_size++;
 
 	hdr->spare++;