linux/fs/ext4
Ritesh Harjani bfdc502a4a ext4: fix ext4_mb_mark_bb() with flex_bg with fast_commit
In case of flex_bg feature (which is by default enabled), extents for
any given inode might span across blocks from two different block group.
ext4_mb_mark_bb() only reads the buffer_head of block bitmap once for the
starting block group, but it fails to read it again when the extent length
boundary overflows to another block group. Then in this below loop it
accesses memory beyond the block group bitmap buffer_head and results
into a data abort.

	for (i = 0; i < clen; i++)
		if (!mb_test_bit(blkoff + i, bitmap_bh->b_data) == !state)
			already++;

This patch adds this functionality for checking block group boundary in
ext4_mb_mark_bb() and update the buffer_head(bitmap_bh) for every different
block group.

w/o this patch, I was easily able to hit a data access abort using Power platform.

<...>
[   74.327662] EXT4-fs error (device loop3): ext4_mb_generate_buddy:1141: group 11, block bitmap and bg descriptor inconsistent: 21248 vs 23294 free clusters
[   74.533214] EXT4-fs (loop3): shut down requested (2)
[   74.536705] Aborting journal on device loop3-8.
[   74.702705] BUG: Unable to handle kernel data access on read at 0xc00000005e980000
[   74.703727] Faulting instruction address: 0xc0000000007bffb8
cpu 0xd: Vector: 300 (Data Access) at [c000000015db7060]
    pc: c0000000007bffb8: ext4_mb_mark_bb+0x198/0x5a0
    lr: c0000000007bfeec: ext4_mb_mark_bb+0xcc/0x5a0
    sp: c000000015db7300
   msr: 800000000280b033
   dar: c00000005e980000
 dsisr: 40000000
  current = 0xc000000027af6880
  paca    = 0xc00000003ffd5200   irqmask: 0x03   irq_happened: 0x01
    pid   = 5167, comm = mount
<...>
enter ? for help
[c000000015db7380] c000000000782708 ext4_ext_clear_bb+0x378/0x410
[c000000015db7400] c000000000813f14 ext4_fc_replay+0x1794/0x2000
[c000000015db7580] c000000000833f7c do_one_pass+0xe9c/0x12a0
[c000000015db7710] c000000000834504 jbd2_journal_recover+0x184/0x2d0
[c000000015db77c0] c000000000841398 jbd2_journal_load+0x188/0x4a0
[c000000015db7880] c000000000804de8 ext4_fill_super+0x2638/0x3e10
[c000000015db7a40] c0000000005f8404 get_tree_bdev+0x2b4/0x350
[c000000015db7ae0] c0000000007ef058 ext4_get_tree+0x28/0x40
[c000000015db7b00] c0000000005f6344 vfs_get_tree+0x44/0x100
[c000000015db7b70] c00000000063c408 path_mount+0xdd8/0xe70
[c000000015db7c40] c00000000063c8f0 sys_mount+0x450/0x550
[c000000015db7d50] c000000000035770 system_call_exception+0x4a0/0x4e0
[c000000015db7e10] c00000000000c74c system_call_common+0xec/0x250

Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/2609bc8f66fc15870616ee416a18a3d392a209c4.1644992609.git.riteshh@linux.ibm.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
2022-02-25 21:34:56 -05:00
..
.kunitconfig ext4: add .kunitconfig fragment to enable ext4-specific tests 2021-02-11 23:16:30 -05:00
acl.c fs/ext4: fix comments mentioning i_mutex 2022-02-03 10:57:53 -05:00
acl.h vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
balloc.c ext4: flush background discard kwork when retry allocation 2021-08-30 23:35:53 -04:00
bitmap.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
block_validity.c ext4: standardize error message in ext4_protect_reserved_inode() 2020-12-17 13:30:55 -05:00
dir.c ext4: remove unnecessary 'offset' assignment 2022-01-10 13:25:56 -05:00
ext4_extents.h ext4: fix sparse warnings 2021-08-30 23:36:50 -04:00
ext4_jbd2.c ext4: fix null-ptr-deref in '__ext4_journal_ensure_credits' 2022-01-10 13:25:55 -05:00
ext4_jbd2.h fs/ext4: fix comments mentioning i_mutex 2022-02-03 10:57:53 -05:00
ext4.h Various bug fixes for ext4 fast commit and inline data handling. Also 2022-02-06 10:34:45 -08:00
extents_status.c ext4: correct the cache_nr in tracepoint ext4_es_shrink_exit 2021-06-22 21:34:17 -04:00
extents_status.h ext4: fix extent_status trace points 2020-01-25 02:03:03 -05:00
extents.c Various bug fixes for ext4 fast commit and inline data handling. Also 2022-02-06 10:34:45 -08:00
fast_commit.c ext4: fix incorrect type issue during replay_del_range 2022-02-03 10:57:53 -05:00
fast_commit.h ext4: simplify updating of fast commit stats 2021-12-23 18:13:25 -05:00
file.c ext4: use ext4_journal_start/stop for fast commit transactions 2021-12-23 18:13:25 -05:00
fsmap.c treewide: Change list_sort to use const pointers 2021-04-08 16:04:22 -07:00
fsmap.h ext4: fsmap: fix the block/inode bitmap comment 2021-06-24 09:48:29 -04:00
fsync.c block: use an on-stack bio in blkdev_issue_flush 2021-01-27 09:51:48 -07:00
hash.c unicode: clean up the Kconfig symbol confusion 2022-01-20 19:57:24 -05:00
ialloc.c ext4: Support for checksumming from journal triggers 2021-08-30 23:36:50 -04:00
indirect.c fs/ext4: fix comments mentioning i_mutex 2022-02-03 10:57:53 -05:00
inline.c Various bug fixes for ext4 fast commit and inline data handling. Also 2022-02-06 10:34:45 -08:00
inode-test.c fs: ext4: Modify inode-test.c to use KUnit parameterized testing feature 2020-12-02 16:07:25 -07:00
inode.c Various bug fixes for ext4 fast commit and inline data handling. Also 2022-02-06 10:34:45 -08:00
ioctl.c ext4: fast commit may not fallback for ineligible commit 2022-02-03 10:56:39 -05:00
Kconfig ext: EXT4_KUNIT_TESTS should depend on EXT4_FS instead of selecting it 2021-02-11 23:12:59 -05:00
Makefile ext4: Move orphan inode handling into a separate file 2021-08-30 23:36:51 -04:00
mballoc.c ext4: fix ext4_mb_mark_bb() with flex_bg with fast_commit 2022-02-25 21:34:56 -05:00
mballoc.h ext4: fix various seppling typos 2021-04-09 23:14:59 -04:00
migrate.c fs/ext4: fix comments mentioning i_mutex 2022-02-03 10:57:53 -05:00
mmp.c ext4: fix potential uninitialized access to retval in kmmpd 2021-07-23 07:31:29 -04:00
move_extent.c ext4: remove redundant o_start statement 2022-01-10 13:25:56 -05:00
namei.c Various bug fixes for ext4 fast commit and inline data handling. Also 2022-02-06 10:34:45 -08:00
orphan.c fs/ext4: fix comments mentioning i_mutex 2022-02-03 10:57:53 -05:00
page-io.c mm: introduce memalloc_retry_wait() 2022-01-15 16:30:29 +02:00
readpage.c mm: remove cleancache 2022-01-22 08:33:38 +02:00
resize.c ext4: implement support for get/set fs label 2022-01-10 13:25:55 -05:00
super.c ext4: fix remount with 'abort' option 2022-02-25 21:27:20 -05:00
symlink.c ext4: report correct st_size for encrypted symlinks 2021-07-25 20:01:06 -07:00
sysfs.c unicode: clean up the Kconfig symbol confusion 2022-01-20 19:57:24 -05:00
truncate.h ext4: Convert to use mapping->invalidate_lock 2021-07-13 14:29:00 +02:00
verity.c New features for ext4 this cycle include support for encrypted 2021-04-30 15:35:30 -07:00
xattr_hurd.c acl: handle idmapped mounts 2021-01-24 14:27:17 +01:00
xattr_security.c acl: handle idmapped mounts 2021-01-24 14:27:17 +01:00
xattr_trusted.c acl: handle idmapped mounts 2021-01-24 14:27:17 +01:00
xattr_user.c acl: handle idmapped mounts 2021-01-24 14:27:17 +01:00
xattr.c ext4: fast commit may not fallback for ineligible commit 2022-02-03 10:56:39 -05:00
xattr.h ext4: remove duplicate definition of ext4_xattr_ibody_inline_set() 2021-06-24 10:09:39 -04:00