[PATCH v3 08/14] bloblist: Checksum the entire bloblist
Raymond Mao
raymond.mao at linaro.org
Mon Dec 18 19:18:53 CET 2023
From: Simon Glass <sjg at chromium.org>
Spec v0.9 specifies that the entire bloblist area is checksummed,
including unused portions. Update the code to follow this.
Signed-off-by: Simon Glass <sjg at chromium.org>
Co-developed-by: Raymond Mao <raymond.mao at linaro.org>
Signed-off-by: Raymond Mao <raymond.mao at linaro.org>
Reviewed-by: Simon Glass <sjg at chromium.org>
---
common/bloblist.c | 9 +--------
test/bloblist.c | 10 ++++++++--
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/common/bloblist.c b/common/bloblist.c
index 32692d8319..705d9c6ae9 100644
--- a/common/bloblist.c
+++ b/common/bloblist.c
@@ -319,17 +319,10 @@ int bloblist_resize(uint tag, int new_size)
static u32 bloblist_calc_chksum(struct bloblist_hdr *hdr)
{
- struct bloblist_rec *rec;
u8 chksum;
- chksum = table_compute_checksum(hdr, hdr->hdr_size);
+ chksum = table_compute_checksum(hdr, hdr->alloced);
chksum += hdr->chksum;
- foreach_rec(rec, hdr) {
- chksum -= table_compute_checksum((void *)rec,
- rec_hdr_size(rec));
- chksum -= table_compute_checksum((void *)rec +
- rec_hdr_size(rec), rec->size);
- }
return chksum;
}
diff --git a/test/bloblist.c b/test/bloblist.c
index 8b435e27ca..49ac4b92ae 100644
--- a/test/bloblist.c
+++ b/test/bloblist.c
@@ -237,12 +237,18 @@ static int bloblist_test_checksum(struct unit_test_state *uts)
*data2 -= 1;
/*
- * Changing data outside the range of valid data should not affect
- * the checksum.
+ * Changing data outside the range of valid data should affect the
+ * checksum.
*/
ut_assertok(bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
data[TEST_SIZE]++;
+ ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
+ data[TEST_SIZE]--;
+ ut_assertok(bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
+
data2[TEST_SIZE2]++;
+ ut_asserteq(-EIO, bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
+ data[TEST_SIZE]--;
ut_assertok(bloblist_check(TEST_ADDR, TEST_BLOBLIST_SIZE));
return 0;
--
2.25.1
More information about the U-Boot
mailing list