befs: fix shift-out-of-bounds in befs_check_sb
PATCH 1/1 befs: fix shift-out-of-bounds in befs_check_sb
The consistency check for the block_size by using the block_shift caused integer overflow. Thus a max limit to the block_shift was defined named BEFS_MAX_BLOCK_SHIFT in befs.h. Also check for the block_shift was added so that overflow does not occur.
Reported-by [email protected]
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by Gowtham S Bhushan <[email protected]>
--- fs/befs/befs.h | 2 +- fs/befs/super.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
fs/befs/befs.h +1 -1
@@ -13,7 +13,7 @@/* used in debug.c */ #define BEFS_VERSION "0.9.3" - +#define BEFS_MAX_BLOCK_SHIFT 31typedef u64 befs_blocknr_t ;/*
fs/befs/super.c +10 -0
@@ -88,6 +88,16 @@ befs_check_sb(struct super_block *sb)return BEFS_ERR ; } +/* +* block_shift check added so that overflow does not +* occer during the block_size check +*/ + +if (befs_sb->block_shift >BEFS_MAX_BLOCK_SHIFT ) { +befs_error (sb,"block_size too large, Corruption likely. " ); +return BEFS_ERR ; + } +/* * block_shift and block_size encode the same information * in different ways as a consistency check.
Signature · 1 line
2.56.0