]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.10-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 7 Feb 2022 08:14:30 +0000 (09:14 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 7 Feb 2022 08:14:30 +0000 (09:14 +0100)
added patches:
edac-altera-fix-deferred-probing.patch
edac-xgene-fix-deferred-probing.patch
ext4-fix-error-handling-in-ext4_fc_record_modified_inode.patch
ext4-fix-error-handling-in-ext4_restore_inline_data.patch
ext4-fix-incorrect-type-issue-during-replay_del_range.patch
ext4-modify-the-logic-of-ext4_mb_new_blocks_simple.patch
ext4-prevent-used-blocks-from-being-allocated-during-fast-commit-replay.patch
perf-x86-intel-pt-fix-crash-with-stop-filters-in-single-range-mode.patch
x86-perf-default-set-freeze_on_smi-for-all.patch

queue-5.10/edac-altera-fix-deferred-probing.patch [new file with mode: 0644]
queue-5.10/edac-xgene-fix-deferred-probing.patch [new file with mode: 0644]
queue-5.10/ext4-fix-error-handling-in-ext4_fc_record_modified_inode.patch [new file with mode: 0644]
queue-5.10/ext4-fix-error-handling-in-ext4_restore_inline_data.patch [new file with mode: 0644]
queue-5.10/ext4-fix-incorrect-type-issue-during-replay_del_range.patch [new file with mode: 0644]
queue-5.10/ext4-modify-the-logic-of-ext4_mb_new_blocks_simple.patch [new file with mode: 0644]
queue-5.10/ext4-prevent-used-blocks-from-being-allocated-during-fast-commit-replay.patch [new file with mode: 0644]
queue-5.10/perf-x86-intel-pt-fix-crash-with-stop-filters-in-single-range-mode.patch [new file with mode: 0644]
queue-5.10/series
queue-5.10/x86-perf-default-set-freeze_on_smi-for-all.patch [new file with mode: 0644]

diff --git a/queue-5.10/edac-altera-fix-deferred-probing.patch b/queue-5.10/edac-altera-fix-deferred-probing.patch
new file mode 100644 (file)
index 0000000..8d39584
--- /dev/null
@@ -0,0 +1,39 @@
+From 279eb8575fdaa92c314a54c0d583c65e26229107 Mon Sep 17 00:00:00 2001
+From: Sergey Shtylyov <s.shtylyov@omp.ru>
+Date: Mon, 24 Jan 2022 21:55:02 +0300
+Subject: EDAC/altera: Fix deferred probing
+
+From: Sergey Shtylyov <s.shtylyov@omp.ru>
+
+commit 279eb8575fdaa92c314a54c0d583c65e26229107 upstream.
+
+The driver overrides the error codes returned by platform_get_irq() to
+-ENODEV for some strange reason, so if it returns -EPROBE_DEFER, the
+driver will fail the probe permanently instead of the deferred probing.
+Switch to propagating the proper error codes to platform driver code
+upwards.
+
+  [ bp: Massage commit message. ]
+
+Fixes: 71bcada88b0f ("edac: altera: Add Altera SDRAM EDAC support")
+Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
+Signed-off-by: Borislav Petkov <bp@suse.de>
+Acked-by: Dinh Nguyen <dinguyen@kernel.org>
+Cc: <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/20220124185503.6720-2-s.shtylyov@omp.ru
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/edac/altera_edac.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/edac/altera_edac.c
++++ b/drivers/edac/altera_edac.c
+@@ -349,7 +349,7 @@ static int altr_sdram_probe(struct platf
+       if (irq < 0) {
+               edac_printk(KERN_ERR, EDAC_MC,
+                           "No irq %d in DT\n", irq);
+-              return -ENODEV;
++              return irq;
+       }
+       /* Arria10 has a 2nd IRQ */
diff --git a/queue-5.10/edac-xgene-fix-deferred-probing.patch b/queue-5.10/edac-xgene-fix-deferred-probing.patch
new file mode 100644 (file)
index 0000000..8ad951b
--- /dev/null
@@ -0,0 +1,38 @@
+From dfd0dfb9a7cc04acf93435b440dd34c2ca7b4424 Mon Sep 17 00:00:00 2001
+From: Sergey Shtylyov <s.shtylyov@omp.ru>
+Date: Mon, 24 Jan 2022 21:55:03 +0300
+Subject: EDAC/xgene: Fix deferred probing
+
+From: Sergey Shtylyov <s.shtylyov@omp.ru>
+
+commit dfd0dfb9a7cc04acf93435b440dd34c2ca7b4424 upstream.
+
+The driver overrides error codes returned by platform_get_irq_optional()
+to -EINVAL for some strange reason, so if it returns -EPROBE_DEFER, the
+driver will fail the probe permanently instead of the deferred probing.
+Switch to propagating the proper error codes to platform driver code
+upwards.
+
+  [ bp: Massage commit message. ]
+
+Fixes: 0d4429301c4a ("EDAC: Add APM X-Gene SoC EDAC driver")
+Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
+Signed-off-by: Borislav Petkov <bp@suse.de>
+Cc: <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/20220124185503.6720-3-s.shtylyov@omp.ru
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/edac/xgene_edac.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/edac/xgene_edac.c
++++ b/drivers/edac/xgene_edac.c
+@@ -1919,7 +1919,7 @@ static int xgene_edac_probe(struct platf
+                       irq = platform_get_irq(pdev, i);
+                       if (irq < 0) {
+                               dev_err(&pdev->dev, "No IRQ resource\n");
+-                              rc = -EINVAL;
++                              rc = irq;
+                               goto out_err;
+                       }
+                       rc = devm_request_irq(&pdev->dev, irq,
diff --git a/queue-5.10/ext4-fix-error-handling-in-ext4_fc_record_modified_inode.patch b/queue-5.10/ext4-fix-error-handling-in-ext4_fc_record_modified_inode.patch
new file mode 100644 (file)
index 0000000..e178ede
--- /dev/null
@@ -0,0 +1,182 @@
+From cdce59a1549190b66f8e3fe465c2b2f714b98a94 Mon Sep 17 00:00:00 2001
+From: Ritesh Harjani <riteshh@linux.ibm.com>
+Date: Mon, 17 Jan 2022 17:41:49 +0530
+Subject: ext4: fix error handling in ext4_fc_record_modified_inode()
+
+From: Ritesh Harjani <riteshh@linux.ibm.com>
+
+commit cdce59a1549190b66f8e3fe465c2b2f714b98a94 upstream.
+
+Current code does not fully takes care of krealloc() error case, which
+could lead to silent memory corruption or a kernel bug.  This patch
+fixes that.
+
+Also it cleans up some duplicated error handling logic from various
+functions in fast_commit.c file.
+
+Reported-by: luo penghao <luo.penghao@zte.com.cn>
+Suggested-by: Lukas Czerner <lczerner@redhat.com>
+Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
+Reviewed-by: Jan Kara <jack@suse.cz>
+Link: https://lore.kernel.org/r/62e8b6a1cce9359682051deb736a3c0953c9d1e9.1642416995.git.riteshh@linux.ibm.com
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Cc: stable@kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/ext4/fast_commit.c |   64 ++++++++++++++++++++++----------------------------
+ 1 file changed, 29 insertions(+), 35 deletions(-)
+
+--- a/fs/ext4/fast_commit.c
++++ b/fs/ext4/fast_commit.c
+@@ -1388,14 +1388,15 @@ static int ext4_fc_record_modified_inode
+               if (state->fc_modified_inodes[i] == ino)
+                       return 0;
+       if (state->fc_modified_inodes_used == state->fc_modified_inodes_size) {
+-              state->fc_modified_inodes_size +=
+-                      EXT4_FC_REPLAY_REALLOC_INCREMENT;
+               state->fc_modified_inodes = krealloc(
+-                                      state->fc_modified_inodes, sizeof(int) *
+-                                      state->fc_modified_inodes_size,
+-                                      GFP_KERNEL);
++                              state->fc_modified_inodes,
++                              sizeof(int) * (state->fc_modified_inodes_size +
++                              EXT4_FC_REPLAY_REALLOC_INCREMENT),
++                              GFP_KERNEL);
+               if (!state->fc_modified_inodes)
+                       return -ENOMEM;
++              state->fc_modified_inodes_size +=
++                      EXT4_FC_REPLAY_REALLOC_INCREMENT;
+       }
+       state->fc_modified_inodes[state->fc_modified_inodes_used++] = ino;
+       return 0;
+@@ -1427,7 +1428,9 @@ static int ext4_fc_replay_inode(struct s
+       }
+       inode = NULL;
+-      ext4_fc_record_modified_inode(sb, ino);
++      ret = ext4_fc_record_modified_inode(sb, ino);
++      if (ret)
++              goto out;
+       raw_fc_inode = (struct ext4_inode *)
+               (val + offsetof(struct ext4_fc_inode, fc_raw_inode));
+@@ -1626,6 +1629,8 @@ static int ext4_fc_replay_add_range(stru
+       }
+       ret = ext4_fc_record_modified_inode(sb, inode->i_ino);
++      if (ret)
++              goto out;
+       start = le32_to_cpu(ex->ee_block);
+       start_pblk = ext4_ext_pblock(ex);
+@@ -1643,18 +1648,14 @@ static int ext4_fc_replay_add_range(stru
+               map.m_pblk = 0;
+               ret = ext4_map_blocks(NULL, inode, &map, 0);
+-              if (ret < 0) {
+-                      iput(inode);
+-                      return 0;
+-              }
++              if (ret < 0)
++                      goto out;
+               if (ret == 0) {
+                       /* Range is not mapped */
+                       path = ext4_find_extent(inode, cur, NULL, 0);
+-                      if (IS_ERR(path)) {
+-                              iput(inode);
+-                              return 0;
+-                      }
++                      if (IS_ERR(path))
++                              goto out;
+                       memset(&newex, 0, sizeof(newex));
+                       newex.ee_block = cpu_to_le32(cur);
+                       ext4_ext_store_pblock(
+@@ -1668,10 +1669,8 @@ static int ext4_fc_replay_add_range(stru
+                       up_write((&EXT4_I(inode)->i_data_sem));
+                       ext4_ext_drop_refs(path);
+                       kfree(path);
+-                      if (ret) {
+-                              iput(inode);
+-                              return 0;
+-                      }
++                      if (ret)
++                              goto out;
+                       goto next;
+               }
+@@ -1684,10 +1683,8 @@ static int ext4_fc_replay_add_range(stru
+                       ret = ext4_ext_replay_update_ex(inode, cur, map.m_len,
+                                       ext4_ext_is_unwritten(ex),
+                                       start_pblk + cur - start);
+-                      if (ret) {
+-                              iput(inode);
+-                              return 0;
+-                      }
++                      if (ret)
++                              goto out;
+                       /*
+                        * Mark the old blocks as free since they aren't used
+                        * anymore. We maintain an array of all the modified
+@@ -1707,10 +1704,8 @@ static int ext4_fc_replay_add_range(stru
+                       ext4_ext_is_unwritten(ex), map.m_pblk);
+               ret = ext4_ext_replay_update_ex(inode, cur, map.m_len,
+                                       ext4_ext_is_unwritten(ex), map.m_pblk);
+-              if (ret) {
+-                      iput(inode);
+-                      return 0;
+-              }
++              if (ret)
++                      goto out;
+               /*
+                * We may have split the extent tree while toggling the state.
+                * Try to shrink the extent tree now.
+@@ -1722,6 +1717,7 @@ next:
+       }
+       ext4_ext_replay_shrink_inode(inode, i_size_read(inode) >>
+                                       sb->s_blocksize_bits);
++out:
+       iput(inode);
+       return 0;
+ }
+@@ -1751,6 +1747,8 @@ ext4_fc_replay_del_range(struct super_bl
+       }
+       ret = ext4_fc_record_modified_inode(sb, inode->i_ino);
++      if (ret)
++              goto out;
+       jbd_debug(1, "DEL_RANGE, inode %ld, lblk %d, len %d\n",
+                       inode->i_ino, le32_to_cpu(lrange.fc_lblk),
+@@ -1760,10 +1758,8 @@ ext4_fc_replay_del_range(struct super_bl
+               map.m_len = remaining;
+               ret = ext4_map_blocks(NULL, inode, &map, 0);
+-              if (ret < 0) {
+-                      iput(inode);
+-                      return 0;
+-              }
++              if (ret < 0)
++                      goto out;
+               if (ret > 0) {
+                       remaining -= ret;
+                       cur += ret;
+@@ -1778,15 +1774,13 @@ ext4_fc_replay_del_range(struct super_bl
+       ret = ext4_ext_remove_space(inode, lrange.fc_lblk,
+                               lrange.fc_lblk + lrange.fc_len - 1);
+       up_write(&EXT4_I(inode)->i_data_sem);
+-      if (ret) {
+-              iput(inode);
+-              return 0;
+-      }
++      if (ret)
++              goto out;
+       ext4_ext_replay_shrink_inode(inode,
+               i_size_read(inode) >> sb->s_blocksize_bits);
+       ext4_mark_inode_dirty(NULL, inode);
++out:
+       iput(inode);
+-
+       return 0;
+ }
diff --git a/queue-5.10/ext4-fix-error-handling-in-ext4_restore_inline_data.patch b/queue-5.10/ext4-fix-error-handling-in-ext4_restore_inline_data.patch
new file mode 100644 (file)
index 0000000..b13319f
--- /dev/null
@@ -0,0 +1,60 @@
+From 897026aaa73eb2517dfea8d147f20ddb0b813044 Mon Sep 17 00:00:00 2001
+From: Ritesh Harjani <riteshh@linux.ibm.com>
+Date: Mon, 17 Jan 2022 17:41:47 +0530
+Subject: ext4: fix error handling in ext4_restore_inline_data()
+
+From: Ritesh Harjani <riteshh@linux.ibm.com>
+
+commit 897026aaa73eb2517dfea8d147f20ddb0b813044 upstream.
+
+While running "./check -I 200 generic/475" it sometimes gives below
+kernel BUG(). Ideally we should not call ext4_write_inline_data() if
+ext4_create_inline_data() has failed.
+
+<log snip>
+[73131.453234] kernel BUG at fs/ext4/inline.c:223!
+
+<code snip>
+ 212 static void ext4_write_inline_data(struct inode *inode, struct ext4_iloc *iloc,
+ 213                                    void *buffer, loff_t pos, unsigned int len)
+ 214 {
+<...>
+ 223         BUG_ON(!EXT4_I(inode)->i_inline_off);
+ 224         BUG_ON(pos + len > EXT4_I(inode)->i_inline_size);
+
+This patch handles the error and prints out a emergency msg saying potential
+data loss for the given inode (since we couldn't restore the original
+inline_data due to some previous error).
+
+[ 9571.070313] EXT4-fs (dm-0): error restoring inline_data for inode -- potential data loss! (inode 1703982, error -30)
+
+Reported-by: Eric Whitney <enwlinux@gmail.com>
+Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
+Reviewed-by: Jan Kara <jack@suse.cz>
+Link: https://lore.kernel.org/r/9f4cd7dfd54fa58ff27270881823d94ddf78dd07.1642416995.git.riteshh@linux.ibm.com
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Cc: stable@kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/ext4/inline.c |   10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+--- a/fs/ext4/inline.c
++++ b/fs/ext4/inline.c
+@@ -1120,7 +1120,15 @@ static void ext4_restore_inline_data(han
+                                    struct ext4_iloc *iloc,
+                                    void *buf, int inline_size)
+ {
+-      ext4_create_inline_data(handle, inode, inline_size);
++      int ret;
++
++      ret = ext4_create_inline_data(handle, inode, inline_size);
++      if (ret) {
++              ext4_msg(inode->i_sb, KERN_EMERG,
++                      "error restoring inline_data for inode -- potential data loss! (inode %lu, error %d)",
++                      inode->i_ino, ret);
++              return;
++      }
+       ext4_write_inline_data(inode, iloc, buf, 0, inline_size);
+       ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA);
+ }
diff --git a/queue-5.10/ext4-fix-incorrect-type-issue-during-replay_del_range.patch b/queue-5.10/ext4-fix-incorrect-type-issue-during-replay_del_range.patch
new file mode 100644 (file)
index 0000000..943878c
--- /dev/null
@@ -0,0 +1,37 @@
+From 8fca8a2b0a822f7936130af7299d2fd7f0a66714 Mon Sep 17 00:00:00 2001
+From: Xin Yin <yinxin.x@bytedance.com>
+Date: Wed, 26 Jan 2022 14:31:46 +0800
+Subject: ext4: fix incorrect type issue during replay_del_range
+
+From: Xin Yin <yinxin.x@bytedance.com>
+
+commit 8fca8a2b0a822f7936130af7299d2fd7f0a66714 upstream.
+
+should not use fast commit log data directly, add le32_to_cpu().
+
+Reported-by: kernel test robot <lkp@intel.com>
+Fixes: 0b5b5a62b945 ("ext4: use ext4_ext_remove_space() for fast commit replay delete range")
+Cc: stable@kernel.org
+Signed-off-by: Xin Yin <yinxin.x@bytedance.com>
+Reviewed-by: Ritesh Harjani <riteshh@linux.ibm.com>
+Link: https://lore.kernel.org/r/20220126063146.2302-1-yinxin.x@bytedance.com
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/ext4/fast_commit.c |    5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+--- a/fs/ext4/fast_commit.c
++++ b/fs/ext4/fast_commit.c
+@@ -1771,8 +1771,9 @@ ext4_fc_replay_del_range(struct super_bl
+       }
+       down_write(&EXT4_I(inode)->i_data_sem);
+-      ret = ext4_ext_remove_space(inode, lrange.fc_lblk,
+-                              lrange.fc_lblk + lrange.fc_len - 1);
++      ret = ext4_ext_remove_space(inode, le32_to_cpu(lrange.fc_lblk),
++                              le32_to_cpu(lrange.fc_lblk) +
++                              le32_to_cpu(lrange.fc_len) - 1);
+       up_write(&EXT4_I(inode)->i_data_sem);
+       if (ret)
+               goto out;
diff --git a/queue-5.10/ext4-modify-the-logic-of-ext4_mb_new_blocks_simple.patch b/queue-5.10/ext4-modify-the-logic-of-ext4_mb_new_blocks_simple.patch
new file mode 100644 (file)
index 0000000..826de3f
--- /dev/null
@@ -0,0 +1,74 @@
+From 31a074a0c62dc0d2bfb9b543142db4fe27f9e5eb Mon Sep 17 00:00:00 2001
+From: Xin Yin <yinxin.x@bytedance.com>
+Date: Mon, 10 Jan 2022 11:51:41 +0800
+Subject: ext4: modify the logic of ext4_mb_new_blocks_simple
+
+From: Xin Yin <yinxin.x@bytedance.com>
+
+commit 31a074a0c62dc0d2bfb9b543142db4fe27f9e5eb upstream.
+
+For now in ext4_mb_new_blocks_simple, if we found a block which
+should be excluded then will switch to next group, this may
+probably cause 'group' run out of range.
+
+Change to check next block in the same group when get a block should
+be excluded. Also change the search range to EXT4_CLUSTERS_PER_GROUP
+and add error checking.
+
+Signed-off-by: Xin Yin <yinxin.x@bytedance.com>
+Reviewed-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
+Link: https://lore.kernel.org/r/20220110035141.1980-3-yinxin.x@bytedance.com
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Cc: stable@kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/ext4/mballoc.c |   26 +++++++++++++++++---------
+ 1 file changed, 17 insertions(+), 9 deletions(-)
+
+--- a/fs/ext4/mballoc.c
++++ b/fs/ext4/mballoc.c
+@@ -5173,7 +5173,8 @@ static ext4_fsblk_t ext4_mb_new_blocks_s
+       struct super_block *sb = ar->inode->i_sb;
+       ext4_group_t group;
+       ext4_grpblk_t blkoff;
+-      int i = sb->s_blocksize;
++      ext4_grpblk_t max = EXT4_CLUSTERS_PER_GROUP(sb);
++      ext4_grpblk_t i = 0;
+       ext4_fsblk_t goal, block;
+       struct ext4_super_block *es = EXT4_SB(sb)->s_es;
+@@ -5195,19 +5196,26 @@ static ext4_fsblk_t ext4_mb_new_blocks_s
+               ext4_get_group_no_and_offset(sb,
+                       max(ext4_group_first_block_no(sb, group), goal),
+                       NULL, &blkoff);
+-              i = mb_find_next_zero_bit(bitmap_bh->b_data, sb->s_blocksize,
++              while (1) {
++                      i = mb_find_next_zero_bit(bitmap_bh->b_data, max,
+                                               blkoff);
++                      if (i >= max)
++                              break;
++                      if (ext4_fc_replay_check_excluded(sb,
++                              ext4_group_first_block_no(sb, group) + i)) {
++                              blkoff = i + 1;
++                      } else
++                              break;
++              }
+               brelse(bitmap_bh);
+-              if (i >= sb->s_blocksize)
+-                      continue;
+-              if (ext4_fc_replay_check_excluded(sb,
+-                      ext4_group_first_block_no(sb, group) + i))
+-                      continue;
+-              break;
++              if (i < max)
++                      break;
+       }
+-      if (group >= ext4_get_groups_count(sb) && i >= sb->s_blocksize)
++      if (group >= ext4_get_groups_count(sb) || i >= max) {
++              *errp = -ENOSPC;
+               return 0;
++      }
+       block = ext4_group_first_block_no(sb, group) + i;
+       ext4_mb_mark_bb(sb, block, 1, 1);
diff --git a/queue-5.10/ext4-prevent-used-blocks-from-being-allocated-during-fast-commit-replay.patch b/queue-5.10/ext4-prevent-used-blocks-from-being-allocated-during-fast-commit-replay.patch
new file mode 100644 (file)
index 0000000..54344b0
--- /dev/null
@@ -0,0 +1,107 @@
+From 599ea31d13617c5484c40cdf50d88301dc351cfc Mon Sep 17 00:00:00 2001
+From: Xin Yin <yinxin.x@bytedance.com>
+Date: Mon, 10 Jan 2022 11:51:40 +0800
+Subject: ext4: prevent used blocks from being allocated during fast commit replay
+
+From: Xin Yin <yinxin.x@bytedance.com>
+
+commit 599ea31d13617c5484c40cdf50d88301dc351cfc upstream.
+
+During fast commit replay procedure, we clear inode blocks bitmap in
+ext4_ext_clear_bb(), this may cause ext4_mb_new_blocks_simple() allocate
+blocks still in use.
+
+Make ext4_fc_record_regions() also record physical disk regions used by
+inodes during replay procedure. Then ext4_mb_new_blocks_simple() can
+excludes these blocks in use.
+
+Signed-off-by: Xin Yin <yinxin.x@bytedance.com>
+Link: https://lore.kernel.org/r/20220110035141.1980-2-yinxin.x@bytedance.com
+Signed-off-by: Theodore Ts'o <tytso@mit.edu>
+Cc: stable@kernel.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/ext4/ext4.h        |    3 +++
+ fs/ext4/extents.c     |    4 ++++
+ fs/ext4/fast_commit.c |   20 +++++++++++++++-----
+ 3 files changed, 22 insertions(+), 5 deletions(-)
+
+--- a/fs/ext4/ext4.h
++++ b/fs/ext4/ext4.h
+@@ -2779,6 +2779,9 @@ void ext4_fc_replay_cleanup(struct super
+ int ext4_fc_commit(journal_t *journal, tid_t commit_tid);
+ int __init ext4_fc_init_dentry_cache(void);
+ void ext4_fc_destroy_dentry_cache(void);
++int ext4_fc_record_regions(struct super_block *sb, int ino,
++                         ext4_lblk_t lblk, ext4_fsblk_t pblk,
++                         int len, int replay);
+ /* mballoc.c */
+ extern const struct seq_operations ext4_mb_seq_groups_ops;
+--- a/fs/ext4/extents.c
++++ b/fs/ext4/extents.c
+@@ -6088,11 +6088,15 @@ int ext4_ext_clear_bb(struct inode *inod
+                                       ext4_mb_mark_bb(inode->i_sb,
+                                                       path[j].p_block, 1, 0);
++                                      ext4_fc_record_regions(inode->i_sb, inode->i_ino,
++                                                      0, path[j].p_block, 1, 1);
+                               }
+                               ext4_ext_drop_refs(path);
+                               kfree(path);
+                       }
+                       ext4_mb_mark_bb(inode->i_sb, map.m_pblk, map.m_len, 0);
++                      ext4_fc_record_regions(inode->i_sb, inode->i_ino,
++                                      map.m_lblk, map.m_pblk, map.m_len, 1);
+               }
+               cur = cur + map.m_len;
+       }
+--- a/fs/ext4/fast_commit.c
++++ b/fs/ext4/fast_commit.c
+@@ -1558,16 +1558,23 @@ out:
+ }
+ /*
+- * Record physical disk regions which are in use as per fast commit area. Our
+- * simple replay phase allocator excludes these regions from allocation.
++ * Record physical disk regions which are in use as per fast commit area,
++ * and used by inodes during replay phase. Our simple replay phase
++ * allocator excludes these regions from allocation.
+  */
+-static int ext4_fc_record_regions(struct super_block *sb, int ino,
+-              ext4_lblk_t lblk, ext4_fsblk_t pblk, int len)
++int ext4_fc_record_regions(struct super_block *sb, int ino,
++              ext4_lblk_t lblk, ext4_fsblk_t pblk, int len, int replay)
+ {
+       struct ext4_fc_replay_state *state;
+       struct ext4_fc_alloc_region *region;
+       state = &EXT4_SB(sb)->s_fc_replay_state;
++      /*
++       * during replay phase, the fc_regions_valid may not same as
++       * fc_regions_used, update it when do new additions.
++       */
++      if (replay && state->fc_regions_used != state->fc_regions_valid)
++              state->fc_regions_used = state->fc_regions_valid;
+       if (state->fc_regions_used == state->fc_regions_size) {
+               state->fc_regions_size +=
+                       EXT4_FC_REPLAY_REALLOC_INCREMENT;
+@@ -1585,6 +1592,9 @@ static int ext4_fc_record_regions(struct
+       region->pblk = pblk;
+       region->len = len;
++      if (replay)
++              state->fc_regions_valid++;
++
+       return 0;
+ }
+@@ -1954,7 +1964,7 @@ static int ext4_fc_replay_scan(journal_t
+                       ret = ext4_fc_record_regions(sb,
+                               le32_to_cpu(ext.fc_ino),
+                               le32_to_cpu(ex->ee_block), ext4_ext_pblock(ex),
+-                              ext4_ext_get_actual_len(ex));
++                              ext4_ext_get_actual_len(ex), 0);
+                       if (ret < 0)
+                               break;
+                       ret = JBD2_FC_REPLAY_CONTINUE;
diff --git a/queue-5.10/perf-x86-intel-pt-fix-crash-with-stop-filters-in-single-range-mode.patch b/queue-5.10/perf-x86-intel-pt-fix-crash-with-stop-filters-in-single-range-mode.patch
new file mode 100644 (file)
index 0000000..cfd6889
--- /dev/null
@@ -0,0 +1,52 @@
+From 1d9093457b243061a9bba23543c38726e864a643 Mon Sep 17 00:00:00 2001
+From: Tristan Hume <tristan@thume.ca>
+Date: Thu, 27 Jan 2022 17:08:06 -0500
+Subject: perf/x86/intel/pt: Fix crash with stop filters in single-range mode
+
+From: Tristan Hume <tristan@thume.ca>
+
+commit 1d9093457b243061a9bba23543c38726e864a643 upstream.
+
+Add a check for !buf->single before calling pt_buffer_region_size in a
+place where a missing check can cause a kernel crash.
+
+Fixes a bug introduced by commit 670638477aed ("perf/x86/intel/pt:
+Opportunistically use single range output mode"), which added a
+support for PT single-range output mode. Since that commit if a PT
+stop filter range is hit while tracing, the kernel will crash because
+of a null pointer dereference in pt_handle_status due to calling
+pt_buffer_region_size without a ToPA configured.
+
+The commit which introduced single-range mode guarded almost all uses of
+the ToPA buffer variables with checks of the buf->single variable, but
+missed the case where tracing was stopped by the PT hardware, which
+happens when execution hits a configured stop filter.
+
+Tested that hitting a stop filter while PT recording successfully
+records a trace with this patch but crashes without this patch.
+
+Fixes: 670638477aed ("perf/x86/intel/pt: Opportunistically use single range output mode")
+Signed-off-by: Tristan Hume <tristan@thume.ca>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
+Cc: stable@kernel.org
+Link: https://lkml.kernel.org/r/20220127220806.73664-1-tristan@thume.ca
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/events/intel/pt.c |    5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+--- a/arch/x86/events/intel/pt.c
++++ b/arch/x86/events/intel/pt.c
+@@ -897,8 +897,9 @@ static void pt_handle_status(struct pt *
+                * means we are already losing data; need to let the decoder
+                * know.
+                */
+-              if (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries) ||
+-                  buf->output_off == pt_buffer_region_size(buf)) {
++              if (!buf->single &&
++                  (!intel_pt_validate_hw_cap(PT_CAP_topa_multiple_entries) ||
++                   buf->output_off == pt_buffer_region_size(buf))) {
+                       perf_aux_output_flag(&pt->handle,
+                                            PERF_AUX_FLAG_TRUNCATED);
+                       advance++;
index 5a2f67e59c2aa5dc7924518452ada3e1da1a8a69..84c49a548691d647a8ea7c59728c0702ce1cbd24 100644 (file)
@@ -60,3 +60,12 @@ rtc-cmos-evaluate-century-appropriate.patch
 revert-fbcon-disable-accelerated-scrolling.patch
 fbcon-add-option-to-enable-legacy-hardware-acceleration.patch
 perf-stat-fix-display-of-grouped-aliased-events.patch
+perf-x86-intel-pt-fix-crash-with-stop-filters-in-single-range-mode.patch
+x86-perf-default-set-freeze_on_smi-for-all.patch
+edac-altera-fix-deferred-probing.patch
+edac-xgene-fix-deferred-probing.patch
+ext4-prevent-used-blocks-from-being-allocated-during-fast-commit-replay.patch
+ext4-modify-the-logic-of-ext4_mb_new_blocks_simple.patch
+ext4-fix-error-handling-in-ext4_restore_inline_data.patch
+ext4-fix-error-handling-in-ext4_fc_record_modified_inode.patch
+ext4-fix-incorrect-type-issue-during-replay_del_range.patch
diff --git a/queue-5.10/x86-perf-default-set-freeze_on_smi-for-all.patch b/queue-5.10/x86-perf-default-set-freeze_on_smi-for-all.patch
new file mode 100644 (file)
index 0000000..0f1d29a
--- /dev/null
@@ -0,0 +1,58 @@
+From a01994f5e5c79d3a35e5e8cf4252c7f2147323c3 Mon Sep 17 00:00:00 2001
+From: Peter Zijlstra <peterz@infradead.org>
+Date: Thu, 27 Jan 2022 12:32:51 +0100
+Subject: x86/perf: Default set FREEZE_ON_SMI for all
+
+From: Peter Zijlstra <peterz@infradead.org>
+
+commit a01994f5e5c79d3a35e5e8cf4252c7f2147323c3 upstream.
+
+Kyle reported that rr[0] has started to malfunction on Comet Lake and
+later CPUs due to EFI starting to make use of CPL3 [1] and the PMU
+event filtering not distinguishing between regular CPL3 and SMM CPL3.
+
+Since this is a privilege violation, default disable SMM visibility
+where possible.
+
+Administrators wanting to observe SMM cycles can easily change this
+using the sysfs attribute while regular users don't have access to
+this file.
+
+[0] https://rr-project.org/
+
+[1] See the Intel white paper "Trustworthy SMM on the Intel vPro Platform"
+at https://bugzilla.kernel.org/attachment.cgi?id=300300, particularly the
+end of page 5.
+
+Reported-by: Kyle Huey <me@kylehuey.com>
+Suggested-by: Andrew Cooper <Andrew.Cooper3@citrix.com>
+Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
+Cc: stable@kernel.org
+Link: https://lkml.kernel.org/r/YfKChjX61OW4CkYm@hirez.programming.kicks-ass.net
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/events/intel/core.c |   13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+--- a/arch/x86/events/intel/core.c
++++ b/arch/x86/events/intel/core.c
+@@ -4353,6 +4353,19 @@ static __initconst const struct x86_pmu
+       .lbr_read               = intel_pmu_lbr_read_64,
+       .lbr_save               = intel_pmu_lbr_save,
+       .lbr_restore            = intel_pmu_lbr_restore,
++
++      /*
++       * SMM has access to all 4 rings and while traditionally SMM code only
++       * ran in CPL0, 2021-era firmware is starting to make use of CPL3 in SMM.
++       *
++       * Since the EVENTSEL.{USR,OS} CPL filtering makes no distinction
++       * between SMM or not, this results in what should be pure userspace
++       * counters including SMM data.
++       *
++       * This is a clear privilege issue, therefore globally disable
++       * counting SMM by default.
++       */
++      .attr_freeze_on_smi     = 1,
+ };
+ static __init void intel_clovertown_quirk(void)