ext4: fix bitmap position validation
Un-revert "ext4: add validity checks for bitmap block numbers" and apply this new fix on top of it.
This commit is contained in:
parent
c3c6a03a9c
commit
5b54699034
|
@ -18,12 +18,11 @@ linux (4.16.4-1) UNRELEASED; urgency=medium
|
||||||
* [x86,arm64] Disable code signing for upload to unstable
|
* [x86,arm64] Disable code signing for upload to unstable
|
||||||
* debian/lib/python/debian_linux/debian.py: Fix binNMU changelog parsing
|
* debian/lib/python/debian_linux/debian.py: Fix binNMU changelog parsing
|
||||||
* debian/lib/python/debian_linux/debian.py: Fix binNMU revision parsing
|
* debian/lib/python/debian_linux/debian.py: Fix binNMU revision parsing
|
||||||
* Revert "ext4: add validity checks for bitmap block numbers", which
|
|
||||||
caused a regression
|
|
||||||
* xfs: enhance dinode verifier (CVE-2018-10322)
|
* xfs: enhance dinode verifier (CVE-2018-10322)
|
||||||
* xfs: set format back to extents if xfs_bmap_extents_to_btree
|
* xfs: set format back to extents if xfs_bmap_extents_to_btree
|
||||||
(CVE-2018-10323)
|
(CVE-2018-10323)
|
||||||
* udeb: Add algif_skcipher to crypto-modules (Closes: #896968)
|
* udeb: Add algif_skcipher to crypto-modules (Closes: #896968)
|
||||||
|
* ext4: fix bitmap position validation (fixes regression in 4.15.17-1)
|
||||||
|
|
||||||
[ Vagrant Cascadian ]
|
[ Vagrant Cascadian ]
|
||||||
* [arm64] Add patches to support SATA on Tegra210/Jetson-TX1.
|
* [arm64] Add patches to support SATA on Tegra210/Jetson-TX1.
|
||||||
|
|
96
debian/patches/bugfix/all/ext4-add-validity-checks-for-bitmap-block-numbers.patch
vendored
Normal file
96
debian/patches/bugfix/all/ext4-add-validity-checks-for-bitmap-block-numbers.patch
vendored
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
From: Theodore Ts'o <tytso@mit.edu>
|
||||||
|
Date: Mon, 26 Mar 2018 23:54:10 -0400
|
||||||
|
Subject: ext4: add validity checks for bitmap block numbers
|
||||||
|
Origin: https://git.kernel.org/linus/7dac4a1726a9c64a517d595c40e95e2d0d135f6f
|
||||||
|
Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2018-1093
|
||||||
|
|
||||||
|
An privileged attacker can cause a crash by mounting a crafted ext4
|
||||||
|
image which triggers a out-of-bounds read in the function
|
||||||
|
ext4_valid_block_bitmap() in fs/ext4/balloc.c.
|
||||||
|
|
||||||
|
This issue has been assigned CVE-2018-1093.
|
||||||
|
|
||||||
|
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=199181
|
||||||
|
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1560782
|
||||||
|
Reported-by: Wen Xu <wen.xu@gatech.edu>
|
||||||
|
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
||||||
|
Cc: stable@vger.kernel.org
|
||||||
|
---
|
||||||
|
fs/ext4/balloc.c | 16 ++++++++++++++--
|
||||||
|
fs/ext4/ialloc.c | 7 +++++++
|
||||||
|
2 files changed, 21 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
--- a/fs/ext4/balloc.c
|
||||||
|
+++ b/fs/ext4/balloc.c
|
||||||
|
@@ -338,20 +338,25 @@ static ext4_fsblk_t ext4_valid_block_bit
|
||||||
|
/* check whether block bitmap block number is set */
|
||||||
|
blk = ext4_block_bitmap(sb, desc);
|
||||||
|
offset = blk - group_first_block;
|
||||||
|
- if (!ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
|
||||||
|
+ if (offset < 0 || EXT4_B2C(sbi, offset) >= sb->s_blocksize ||
|
||||||
|
+ !ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
|
||||||
|
/* bad block bitmap */
|
||||||
|
return blk;
|
||||||
|
|
||||||
|
/* check whether the inode bitmap block number is set */
|
||||||
|
blk = ext4_inode_bitmap(sb, desc);
|
||||||
|
offset = blk - group_first_block;
|
||||||
|
- if (!ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
|
||||||
|
+ if (offset < 0 || EXT4_B2C(sbi, offset) >= sb->s_blocksize ||
|
||||||
|
+ !ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
|
||||||
|
/* bad block bitmap */
|
||||||
|
return blk;
|
||||||
|
|
||||||
|
/* check whether the inode table block number is set */
|
||||||
|
blk = ext4_inode_table(sb, desc);
|
||||||
|
offset = blk - group_first_block;
|
||||||
|
+ if (offset < 0 || EXT4_B2C(sbi, offset) >= sb->s_blocksize ||
|
||||||
|
+ EXT4_B2C(sbi, offset + sbi->s_itb_per_group) >= sb->s_blocksize)
|
||||||
|
+ return blk;
|
||||||
|
next_zero_bit = ext4_find_next_zero_bit(bh->b_data,
|
||||||
|
EXT4_B2C(sbi, offset + sbi->s_itb_per_group),
|
||||||
|
EXT4_B2C(sbi, offset));
|
||||||
|
@@ -417,6 +422,7 @@ struct buffer_head *
|
||||||
|
ext4_read_block_bitmap_nowait(struct super_block *sb, ext4_group_t block_group)
|
||||||
|
{
|
||||||
|
struct ext4_group_desc *desc;
|
||||||
|
+ struct ext4_sb_info *sbi = EXT4_SB(sb);
|
||||||
|
struct buffer_head *bh;
|
||||||
|
ext4_fsblk_t bitmap_blk;
|
||||||
|
int err;
|
||||||
|
@@ -425,6 +431,12 @@ ext4_read_block_bitmap_nowait(struct sup
|
||||||
|
if (!desc)
|
||||||
|
return ERR_PTR(-EFSCORRUPTED);
|
||||||
|
bitmap_blk = ext4_block_bitmap(sb, desc);
|
||||||
|
+ if ((bitmap_blk <= le32_to_cpu(sbi->s_es->s_first_data_block)) ||
|
||||||
|
+ (bitmap_blk >= ext4_blocks_count(sbi->s_es))) {
|
||||||
|
+ ext4_error(sb, "Invalid block bitmap block %llu in "
|
||||||
|
+ "block_group %u", bitmap_blk, block_group);
|
||||||
|
+ return ERR_PTR(-EFSCORRUPTED);
|
||||||
|
+ }
|
||||||
|
bh = sb_getblk(sb, bitmap_blk);
|
||||||
|
if (unlikely(!bh)) {
|
||||||
|
ext4_error(sb, "Cannot get buffer for block bitmap - "
|
||||||
|
--- a/fs/ext4/ialloc.c
|
||||||
|
+++ b/fs/ext4/ialloc.c
|
||||||
|
@@ -122,6 +122,7 @@ static struct buffer_head *
|
||||||
|
ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
|
||||||
|
{
|
||||||
|
struct ext4_group_desc *desc;
|
||||||
|
+ struct ext4_sb_info *sbi = EXT4_SB(sb);
|
||||||
|
struct buffer_head *bh = NULL;
|
||||||
|
ext4_fsblk_t bitmap_blk;
|
||||||
|
int err;
|
||||||
|
@@ -131,6 +132,12 @@ ext4_read_inode_bitmap(struct super_bloc
|
||||||
|
return ERR_PTR(-EFSCORRUPTED);
|
||||||
|
|
||||||
|
bitmap_blk = ext4_inode_bitmap(sb, desc);
|
||||||
|
+ if ((bitmap_blk <= le32_to_cpu(sbi->s_es->s_first_data_block)) ||
|
||||||
|
+ (bitmap_blk >= ext4_blocks_count(sbi->s_es))) {
|
||||||
|
+ ext4_error(sb, "Invalid inode bitmap blk %llu in "
|
||||||
|
+ "block_group %u", bitmap_blk, block_group);
|
||||||
|
+ return ERR_PTR(-EFSCORRUPTED);
|
||||||
|
+ }
|
||||||
|
bh = sb_getblk(sb, bitmap_blk);
|
||||||
|
if (unlikely(!bh)) {
|
||||||
|
ext4_error(sb, "Cannot read inode bitmap - "
|
|
@ -0,0 +1,76 @@
|
||||||
|
From: Lukas Czerner <lczerner@redhat.com>
|
||||||
|
Date: Tue, 24 Apr 2018 11:31:44 -0400
|
||||||
|
Subject: ext4: fix bitmap position validation
|
||||||
|
Origin: https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git/commit?id=22be37acce25d66ecf6403fc8f44df9c5ded2372
|
||||||
|
|
||||||
|
Currently in ext4_valid_block_bitmap() we expect the bitmap to be
|
||||||
|
positioned anywhere between 0 and s_blocksize clusters, but that's
|
||||||
|
wrong because the bitmap can be placed anywhere in the block group. This
|
||||||
|
causes false positives when validating bitmaps on perfectly valid file
|
||||||
|
system layouts. Fix it by checking whether the bitmap is within the group
|
||||||
|
boundary.
|
||||||
|
|
||||||
|
The problem can be reproduced using the following
|
||||||
|
|
||||||
|
mkfs -t ext3 -E stride=256 /dev/vdb1
|
||||||
|
mount /dev/vdb1 /mnt/test
|
||||||
|
cd /mnt/test
|
||||||
|
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.16.3.tar.xz
|
||||||
|
tar xf linux-4.16.3.tar.xz
|
||||||
|
|
||||||
|
This will result in the warnings in the logs
|
||||||
|
|
||||||
|
EXT4-fs error (device vdb1): ext4_validate_block_bitmap:399: comm tar: bg 84: block 2774529: invalid block bitmap
|
||||||
|
|
||||||
|
[ Changed slightly for clarity and to not drop a overflow test -- TYT ]
|
||||||
|
|
||||||
|
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
|
||||||
|
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
||||||
|
Reported-by: Ilya Dryomov <idryomov@gmail.com>
|
||||||
|
Fixes: 7dac4a1726a9 ("ext4: add validity checks for bitmap block numbers")
|
||||||
|
Cc: stable@vger.kernel.org
|
||||||
|
---
|
||||||
|
fs/ext4/balloc.c | 9 +++++----
|
||||||
|
1 file changed, 5 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
|
||||||
|
index a33d8fb1bf2a..508b905d744d 100644
|
||||||
|
--- a/fs/ext4/balloc.c
|
||||||
|
+++ b/fs/ext4/balloc.c
|
||||||
|
@@ -321,6 +321,7 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb,
|
||||||
|
struct ext4_sb_info *sbi = EXT4_SB(sb);
|
||||||
|
ext4_grpblk_t offset;
|
||||||
|
ext4_grpblk_t next_zero_bit;
|
||||||
|
+ ext4_grpblk_t max_bit = EXT4_CLUSTERS_PER_GROUP(sb);
|
||||||
|
ext4_fsblk_t blk;
|
||||||
|
ext4_fsblk_t group_first_block;
|
||||||
|
|
||||||
|
@@ -338,7 +339,7 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb,
|
||||||
|
/* check whether block bitmap block number is set */
|
||||||
|
blk = ext4_block_bitmap(sb, desc);
|
||||||
|
offset = blk - group_first_block;
|
||||||
|
- if (offset < 0 || EXT4_B2C(sbi, offset) >= sb->s_blocksize ||
|
||||||
|
+ if (offset < 0 || EXT4_B2C(sbi, offset) >= max_bit ||
|
||||||
|
!ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
|
||||||
|
/* bad block bitmap */
|
||||||
|
return blk;
|
||||||
|
@@ -346,7 +347,7 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb,
|
||||||
|
/* check whether the inode bitmap block number is set */
|
||||||
|
blk = ext4_inode_bitmap(sb, desc);
|
||||||
|
offset = blk - group_first_block;
|
||||||
|
- if (offset < 0 || EXT4_B2C(sbi, offset) >= sb->s_blocksize ||
|
||||||
|
+ if (offset < 0 || EXT4_B2C(sbi, offset) >= max_bit ||
|
||||||
|
!ext4_test_bit(EXT4_B2C(sbi, offset), bh->b_data))
|
||||||
|
/* bad block bitmap */
|
||||||
|
return blk;
|
||||||
|
@@ -354,8 +355,8 @@ static ext4_fsblk_t ext4_valid_block_bitmap(struct super_block *sb,
|
||||||
|
/* check whether the inode table block number is set */
|
||||||
|
blk = ext4_inode_table(sb, desc);
|
||||||
|
offset = blk - group_first_block;
|
||||||
|
- if (offset < 0 || EXT4_B2C(sbi, offset) >= sb->s_blocksize ||
|
||||||
|
- EXT4_B2C(sbi, offset + sbi->s_itb_per_group) >= sb->s_blocksize)
|
||||||
|
+ if (offset < 0 || EXT4_B2C(sbi, offset) >= max_bit ||
|
||||||
|
+ EXT4_B2C(sbi, offset + sbi->s_itb_per_group) >= max_bit)
|
||||||
|
return blk;
|
||||||
|
next_zero_bit = ext4_find_next_zero_bit(bh->b_data,
|
||||||
|
EXT4_B2C(sbi, offset + sbi->s_itb_per_group),
|
|
@ -141,6 +141,8 @@ features/all/lockdown/arm64-add-kernel-config-option-to-lock-down-when.patch
|
||||||
debian/i386-686-pae-pci-set-pci-nobios-by-default.patch
|
debian/i386-686-pae-pci-set-pci-nobios-by-default.patch
|
||||||
bugfix/all/xfs-enhance-dinode-verifier.patch
|
bugfix/all/xfs-enhance-dinode-verifier.patch
|
||||||
bugfix/all/xfs-set-format-back-to-extents-if-xfs_bmap_extents_t.patch
|
bugfix/all/xfs-set-format-back-to-extents-if-xfs_bmap_extents_t.patch
|
||||||
|
bugfix/all/ext4-add-validity-checks-for-bitmap-block-numbers.patch
|
||||||
|
bugfix/all/ext4-fix-bitmap-position-validation.patch
|
||||||
|
|
||||||
# Fix exported symbol versions
|
# Fix exported symbol versions
|
||||||
bugfix/all/module-disable-matching-missing-version-crc.patch
|
bugfix/all/module-disable-matching-missing-version-crc.patch
|
||||||
|
|
Loading…
Reference in New Issue