]> git.ipfire.org Git - thirdparty/grub.git/commit
zfs: Fix possible negative shift operation
authorDarren Kenny <darren.kenny@oracle.com>
Tue, 24 Nov 2020 16:41:49 +0000 (16:41 +0000)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 2 Mar 2021 14:54:16 +0000 (15:54 +0100)
commita02091834d3e167320d8a262ff04b8e83c5e616d
treebeb80eedb4c8ec67e4130bef6877fc0ca7b20ac2
parent2298f6e0d951251bb9ca97d891d1bc8b74515f8c
zfs: Fix possible negative shift operation

While it is possible for the return value from zfs_log2() to be zero
(0), it is quite unlikely, given that the previous assignment to blksz
is shifted up by SPA_MINBLOCKSHIFT (9) before 9 is subtracted at the
assignment to epbs.

But, while unlikely during a normal operation, it may be that a carefully
crafted ZFS filesystem could result in a zero (0) value to the
dn_datalbkszsec field, which means that the shift left does nothing
and assigns zero (0) to blksz, resulting in a negative epbs value.

Fixes: CID 73608
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/fs/zfs/zfs.c