]> git.baikalelectronics.ru Git - kernel.git/commit
md/bitmap: Fix bitmap chunk size overflow issues
authorFlorian-Ewald Mueller <florian-ewald.mueller@ionos.com>
Tue, 25 Oct 2022 07:37:05 +0000 (09:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:49 +0000 (11:41 +0100)
commit9cd41d651a6efd47fd230577919aa2804c3a8487
tree54553b4d522deb105b3e1cfc849819fce8274678
parente5292b4bde55420e0cffcaabcfcd3009265e875e
md/bitmap: Fix bitmap chunk size overflow issues

commit 205d618983455e7a947b70ee82c0b629ea2efdb2 upstream.

- limit bitmap chunk size internal u64 variable to values not overflowing
  the u32 bitmap superblock structure variable stored on persistent media
- assign bitmap chunk size internal u64 variable from unsigned values to
  avoid possible sign extension artifacts when assigning from a s32 value

The bug has been there since at least kernel 4.0.
Steps to reproduce it:
1: mdadm -C /dev/mdx -l 1 --bitmap=internal --bitmap-chunk=256M -e 1.2
-n2 /dev/rnbd1 /dev/rnbd2
2 resize member device rnbd1 and rnbd2 to 8 TB
3 mdadm --grow /dev/mdx --size=max

The bitmap_chunksize will overflow without patch.

Cc: stable@vger.kernel.org
Signed-off-by: Florian-Ewald Mueller <florian-ewald.mueller@ionos.com>
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
Signed-off-by: Song Liu <song@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/md-bitmap.c