From: Milan Broz Date: Fri, 31 Jul 2026 14:27:45 +0000 (+0200) Subject: libblkid: befs: fix possible load of misaligned address X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5f00ac15c9da815cb7ed5a6d461c4e2262f59955;p=thirdparty%2Futil-linux.git libblkid: befs: fix possible load of misaligned address The misaligned uint16_t loads can come only form a corrupt metadata. Found by OSS-Fuzz by cryptsetup project fuzzers (issue 507641687). Signed-off-by: Milan Broz --- diff --git a/libblkid/src/superblocks/befs.c b/libblkid/src/superblocks/befs.c index a7a9d30a9..1e0550cb0 100644 --- a/libblkid/src/superblocks/befs.c +++ b/libblkid/src/superblocks/befs.c @@ -329,6 +329,10 @@ static int64_t get_key_value(blkid_probe pr, const struct befs_super_block *bs, keylengths = (uint16_t *) ((uint8_t *) bn + keylengths_offset); values = (int64_t *) ((uint8_t *) bn + values_offset); + /* Misaligned offset comes only from corrupt metadata. */ + if ((uintptr_t) keylengths % sizeof(*keylengths)) + return -ENOENT; /* Corrupt? */ + first = 0; mid = 0; last = all_key_count - 1;