]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.15-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 May 2023 04:04:17 +0000 (06:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 May 2023 04:04:17 +0000 (06:04 +0200)
added patches:
ext4-fix-warning-in-mb_find_extent.patch
locking-rwsem-add-__always_inline-annotation-to-__down_read_common-and-inlined-callers.patch

queue-5.15/ext4-fix-warning-in-mb_find_extent.patch [new file with mode: 0644]
queue-5.15/locking-rwsem-add-__always_inline-annotation-to-__down_read_common-and-inlined-callers.patch [new file with mode: 0644]
queue-5.15/series

diff --git a/queue-5.15/ext4-fix-warning-in-mb_find_extent.patch b/queue-5.15/ext4-fix-warning-in-mb_find_extent.patch
new file mode 100644 (file)
index 0000000..75115d7
--- /dev/null
@@ -0,0 +1,129 @@
+From fa08a7b61dff8a4df11ff1e84abfc214b487caf7 Mon Sep 17 00:00:00 2001
+From: Ye Bin <yebin10@huawei.com>
+Date: Mon, 16 Jan 2023 10:00:15 +0800
+Subject: ext4: fix WARNING in mb_find_extent
+
+From: Ye Bin <yebin10@huawei.com>
+
+commit fa08a7b61dff8a4df11ff1e84abfc214b487caf7 upstream.
+
+Syzbot found the following issue:
+
+EXT4-fs: Warning: mounting with data=journal disables delayed allocation, dioread_nolock, O_DIRECT and fast_commit support!
+EXT4-fs (loop0): orphan cleanup on readonly fs
+------------[ cut here ]------------
+WARNING: CPU: 1 PID: 5067 at fs/ext4/mballoc.c:1869 mb_find_extent+0x8a1/0xe30
+Modules linked in:
+CPU: 1 PID: 5067 Comm: syz-executor307 Not tainted 6.2.0-rc1-syzkaller #0
+Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
+RIP: 0010:mb_find_extent+0x8a1/0xe30 fs/ext4/mballoc.c:1869
+RSP: 0018:ffffc90003c9e098 EFLAGS: 00010293
+RAX: ffffffff82405731 RBX: 0000000000000041 RCX: ffff8880783457c0
+RDX: 0000000000000000 RSI: 0000000000000041 RDI: 0000000000000040
+RBP: 0000000000000040 R08: ffffffff82405723 R09: ffffed10053c9402
+R10: ffffed10053c9402 R11: 1ffff110053c9401 R12: 0000000000000000
+R13: ffffc90003c9e538 R14: dffffc0000000000 R15: ffffc90003c9e2cc
+FS:  0000555556665300(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
+CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
+CR2: 000056312f6796f8 CR3: 0000000022437000 CR4: 00000000003506e0
+DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
+DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
+Call Trace:
+ <TASK>
+ ext4_mb_complex_scan_group+0x353/0x1100 fs/ext4/mballoc.c:2307
+ ext4_mb_regular_allocator+0x1533/0x3860 fs/ext4/mballoc.c:2735
+ ext4_mb_new_blocks+0xddf/0x3db0 fs/ext4/mballoc.c:5605
+ ext4_ext_map_blocks+0x1868/0x6880 fs/ext4/extents.c:4286
+ ext4_map_blocks+0xa49/0x1cc0 fs/ext4/inode.c:651
+ ext4_getblk+0x1b9/0x770 fs/ext4/inode.c:864
+ ext4_bread+0x2a/0x170 fs/ext4/inode.c:920
+ ext4_quota_write+0x225/0x570 fs/ext4/super.c:7105
+ write_blk fs/quota/quota_tree.c:64 [inline]
+ get_free_dqblk+0x34a/0x6d0 fs/quota/quota_tree.c:130
+ do_insert_tree+0x26b/0x1aa0 fs/quota/quota_tree.c:340
+ do_insert_tree+0x722/0x1aa0 fs/quota/quota_tree.c:375
+ do_insert_tree+0x722/0x1aa0 fs/quota/quota_tree.c:375
+ do_insert_tree+0x722/0x1aa0 fs/quota/quota_tree.c:375
+ dq_insert_tree fs/quota/quota_tree.c:401 [inline]
+ qtree_write_dquot+0x3b6/0x530 fs/quota/quota_tree.c:420
+ v2_write_dquot+0x11b/0x190 fs/quota/quota_v2.c:358
+ dquot_acquire+0x348/0x670 fs/quota/dquot.c:444
+ ext4_acquire_dquot+0x2dc/0x400 fs/ext4/super.c:6740
+ dqget+0x999/0xdc0 fs/quota/dquot.c:914
+ __dquot_initialize+0x3d0/0xcf0 fs/quota/dquot.c:1492
+ ext4_process_orphan+0x57/0x2d0 fs/ext4/orphan.c:329
+ ext4_orphan_cleanup+0xb60/0x1340 fs/ext4/orphan.c:474
+ __ext4_fill_super fs/ext4/super.c:5516 [inline]
+ ext4_fill_super+0x81cd/0x8700 fs/ext4/super.c:5644
+ get_tree_bdev+0x400/0x620 fs/super.c:1282
+ vfs_get_tree+0x88/0x270 fs/super.c:1489
+ do_new_mount+0x289/0xad0 fs/namespace.c:3145
+ do_mount fs/namespace.c:3488 [inline]
+ __do_sys_mount fs/namespace.c:3697 [inline]
+ __se_sys_mount+0x2d3/0x3c0 fs/namespace.c:3674
+ do_syscall_x64 arch/x86/entry/common.c:50 [inline]
+ do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
+ entry_SYSCALL_64_after_hwframe+0x63/0xcd
+
+Add some debug information:
+mb_find_extent: mb_find_extent block=41, order=0 needed=64 next=0 ex=0/41/1@3735929054 64 64 7
+block_bitmap: ff 3f 0c 00 fc 01 00 00 d2 3d 00 00 00 00 00 00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
+
+Acctually, blocks per group is 64, but block bitmap indicate at least has
+128 blocks. Now, ext4_validate_block_bitmap() didn't check invalid block's
+bitmap if set.
+To resolve above issue, add check like fsck "Padding at end of block bitmap is
+not set".
+
+Cc: stable@kernel.org
+Reported-by: syzbot+68223fe9f6c95ad43bed@syzkaller.appspotmail.com
+Signed-off-by: Ye Bin <yebin10@huawei.com>
+Reviewed-by: Jan Kara <jack@suse.cz>
+Link: https://lore.kernel.org/r/20230116020015.1506120-1-yebin@huaweicloud.com
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/ext4/balloc.c |   25 +++++++++++++++++++++++++
+ 1 file changed, 25 insertions(+)
+
+--- a/fs/ext4/balloc.c
++++ b/fs/ext4/balloc.c
+@@ -303,6 +303,22 @@ struct ext4_group_desc * ext4_get_group_
+       return desc;
+ }
++static ext4_fsblk_t ext4_valid_block_bitmap_padding(struct super_block *sb,
++                                                  ext4_group_t block_group,
++                                                  struct buffer_head *bh)
++{
++      ext4_grpblk_t next_zero_bit;
++      unsigned long bitmap_size = sb->s_blocksize * 8;
++      unsigned int offset = num_clusters_in_group(sb, block_group);
++
++      if (bitmap_size <= offset)
++              return 0;
++
++      next_zero_bit = ext4_find_next_zero_bit(bh->b_data, bitmap_size, offset);
++
++      return (next_zero_bit < bitmap_size ? next_zero_bit : 0);
++}
++
+ /*
+  * Return the block number which was discovered to be invalid, or 0 if
+  * the block bitmap is valid.
+@@ -401,6 +417,15 @@ static int ext4_validate_block_bitmap(st
+                                       EXT4_GROUP_INFO_BBITMAP_CORRUPT);
+               return -EFSCORRUPTED;
+       }
++      blk = ext4_valid_block_bitmap_padding(sb, block_group, bh);
++      if (unlikely(blk != 0)) {
++              ext4_unlock_group(sb, block_group);
++              ext4_error(sb, "bg %u: block %llu: padding at end of block bitmap is not set",
++                         block_group, blk);
++              ext4_mark_group_bitmap_corrupted(sb, block_group,
++                                               EXT4_GROUP_INFO_BBITMAP_CORRUPT);
++              return -EFSCORRUPTED;
++      }
+       set_buffer_verified(bh);
+ verified:
+       ext4_unlock_group(sb, block_group);
diff --git a/queue-5.15/locking-rwsem-add-__always_inline-annotation-to-__down_read_common-and-inlined-callers.patch b/queue-5.15/locking-rwsem-add-__always_inline-annotation-to-__down_read_common-and-inlined-callers.patch
new file mode 100644 (file)
index 0000000..8803770
--- /dev/null
@@ -0,0 +1,64 @@
+From 92cc5d00a431e96e5a49c0b97e5ad4fa7536bd4b Mon Sep 17 00:00:00 2001
+From: John Stultz <jstultz@google.com>
+Date: Wed, 3 May 2023 02:33:51 +0000
+Subject: locking/rwsem: Add __always_inline annotation to __down_read_common() and inlined callers
+
+From: John Stultz <jstultz@google.com>
+
+commit 92cc5d00a431e96e5a49c0b97e5ad4fa7536bd4b upstream.
+
+Apparently despite it being marked inline, the compiler
+may not inline __down_read_common() which makes it difficult
+to identify the cause of lock contention, as the blocked
+function in traceevents will always be listed as
+__down_read_common().
+
+So this patch adds __always_inline annotation to the common
+function (as well as the inlined helper callers) to force it to
+be inlined so the blocking function will be listed (via Wchan)
+in traceevents.
+
+Fixes: c995e638ccbb ("locking/rwsem: Fold __down_{read,write}*()")
+Reported-by: Tim Murray <timmurray@google.com>
+Signed-off-by: John Stultz <jstultz@google.com>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Reviewed-by: Waiman Long <longman@redhat.com>
+Cc: stable@vger.kernel.org
+Link: https://lkml.kernel.org/r/20230503023351.2832796-1-jstultz@google.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ kernel/locking/rwsem.c |    8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+--- a/kernel/locking/rwsem.c
++++ b/kernel/locking/rwsem.c
+@@ -1221,7 +1221,7 @@ static struct rw_semaphore *rwsem_downgr
+ /*
+  * lock for reading
+  */
+-static inline int __down_read_common(struct rw_semaphore *sem, int state)
++static __always_inline int __down_read_common(struct rw_semaphore *sem, int state)
+ {
+       int ret = 0;
+       long count;
+@@ -1239,17 +1239,17 @@ out:
+       return ret;
+ }
+-static inline void __down_read(struct rw_semaphore *sem)
++static __always_inline void __down_read(struct rw_semaphore *sem)
+ {
+       __down_read_common(sem, TASK_UNINTERRUPTIBLE);
+ }
+-static inline int __down_read_interruptible(struct rw_semaphore *sem)
++static __always_inline int __down_read_interruptible(struct rw_semaphore *sem)
+ {
+       return __down_read_common(sem, TASK_INTERRUPTIBLE);
+ }
+-static inline int __down_read_killable(struct rw_semaphore *sem)
++static __always_inline int __down_read_killable(struct rw_semaphore *sem)
+ {
+       return __down_read_common(sem, TASK_KILLABLE);
+ }
index 79750c36473f8474b83345319534b7eb43f38172..d826634c52343a10e1605489562c7df0996493e6 100644 (file)
@@ -116,3 +116,5 @@ ksmbd-fix-kernel-oops-from-idr_remove.patch
 ksmbd-fix-racy-issue-while-destroying-session-on-mul.patch
 ksmbd-fix-deadlock-in-ksmbd_find_crypto_ctx.patch
 ksmbd-not-allow-guest-user-on-multichannel.patch
+locking-rwsem-add-__always_inline-annotation-to-__down_read_common-and-inlined-callers.patch
+ext4-fix-warning-in-mb_find_extent.patch