UBSAN reports an invalid shift size: mr-fox kernel: UBSAN: shift-out-of-bounds in ./include/linux/log2.h:57:13 mr-fox kernel: shift exponent 64 is too large for 64-bit type 'long unsigned int'
Original report: https://lore.kernel.org/lkml/[email protected]/ Follow-up report: https://lore.kernel.org/lkml/[email protected]/T/#m9b604660925f9e8a544f7453130c31d083c1e5bb Willy suggested that get_init_ra_size() was being called with a size of 0, which would cause this (instead of some Huge value), so add a check in that function for size == 0, and if 0, default it to 32 (pages). Reported-by: Toralf Förster <[email protected]> Signed-off-by: Randy Dunlap <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Jens Axboe <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: [email protected] --- mm/readahead.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- linux-5.10.1.orig/mm/readahead.c +++ linux-5.10.1/mm/readahead.c @@ -310,7 +310,11 @@ void force_page_cache_ra(struct readahea */ static unsigned long get_init_ra_size(unsigned long size, unsigned long max) { - unsigned long newsize = roundup_pow_of_two(size); + unsigned long newsize; + + if (!size) + size = 32; + newsize = roundup_pow_of_two(size); if (newsize <= max / 32) newsize = newsize * 4;

