]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.7-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 24 Mar 2024 13:51:24 +0000 (14:51 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 24 Mar 2024 13:51:24 +0000 (14:51 +0100)
added patches:
bcachefs-check-for-failure-to-downgrade.patch
bcachefs-fix-btree_iter_filter_snapshots-on-inodes-btree.patch
bcachefs-fix-build-on-parisc-by-avoiding-__multi3.patch
bcachefs-fix-simulateously-upgrading-downgrading.patch
bcachefs-install-fd-later-to-avoid-race-with-close.patch

queue-6.7/bcachefs-check-for-failure-to-downgrade.patch [new file with mode: 0644]
queue-6.7/bcachefs-fix-btree_iter_filter_snapshots-on-inodes-btree.patch [new file with mode: 0644]
queue-6.7/bcachefs-fix-build-on-parisc-by-avoiding-__multi3.patch [new file with mode: 0644]
queue-6.7/bcachefs-fix-simulateously-upgrading-downgrading.patch [new file with mode: 0644]
queue-6.7/bcachefs-install-fd-later-to-avoid-race-with-close.patch [new file with mode: 0644]
queue-6.7/series

diff --git a/queue-6.7/bcachefs-check-for-failure-to-downgrade.patch b/queue-6.7/bcachefs-check-for-failure-to-downgrade.patch
new file mode 100644 (file)
index 0000000..44ae3ed
--- /dev/null
@@ -0,0 +1,52 @@
+From e50786c7bbb73fb754564802882c7b52511716ed Mon Sep 17 00:00:00 2001
+From: Kent Overstreet <kent.overstreet@linux.dev>
+Date: Fri, 22 Dec 2023 21:58:43 -0500
+Subject: bcachefs: check for failure to downgrade
+
+From: Kent Overstreet <kent.overstreet@linux.dev>
+
+commit 447c1c01051251853e851bd77f26546488cbc7b7 upstream.
+
+With the upcoming member seq patch, it's now critical that we don't ever
+write to a superblock that hasn't been version downgraded - failure to
+update member seq fields will cause split brain detection to fire
+erroniously.
+
+Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/bcachefs/errcode.h  |    1 +
+ fs/bcachefs/super-io.c |   12 ++++++++++++
+ 2 files changed, 13 insertions(+)
+
+--- a/fs/bcachefs/errcode.h
++++ b/fs/bcachefs/errcode.h
+@@ -224,6 +224,7 @@
+       x(BCH_ERR_invalid,              invalid_bkey)                           \
+       x(BCH_ERR_operation_blocked,    nocow_lock_blocked)                     \
+       x(EIO,                          btree_node_read_err)                    \
++      x(EIO,                          sb_not_downgraded)                      \
+       x(BCH_ERR_btree_node_read_err,  btree_node_read_err_fixable)            \
+       x(BCH_ERR_btree_node_read_err,  btree_node_read_err_want_retry)         \
+       x(BCH_ERR_btree_node_read_err,  btree_node_read_err_must_retry)         \
+--- a/fs/bcachefs/super-io.c
++++ b/fs/bcachefs/super-io.c
+@@ -966,6 +966,18 @@ int bch2_write_super(struct bch_fs *c)
+       if (!BCH_SB_INITIALIZED(c->disk_sb.sb))
+               goto out;
++      if (le16_to_cpu(c->disk_sb.sb->version) > bcachefs_metadata_version_current) {
++              struct printbuf buf = PRINTBUF;
++              prt_printf(&buf, "attempting to write superblock that wasn't version downgraded (");
++              bch2_version_to_text(&buf, le16_to_cpu(c->disk_sb.sb->version));
++              prt_str(&buf, " > ");
++              bch2_version_to_text(&buf, bcachefs_metadata_version_current);
++              prt_str(&buf, ")");
++              bch2_fs_fatal_error(c, "%s", buf.buf);
++              printbuf_exit(&buf);
++              return -BCH_ERR_sb_not_downgraded;
++      }
++
+       for_each_online_member(ca, c, i) {
+               __set_bit(ca->dev_idx, sb_written.d);
+               ca->sb_write_error = 0;
diff --git a/queue-6.7/bcachefs-fix-btree_iter_filter_snapshots-on-inodes-btree.patch b/queue-6.7/bcachefs-fix-btree_iter_filter_snapshots-on-inodes-btree.patch
new file mode 100644 (file)
index 0000000..5db966f
--- /dev/null
@@ -0,0 +1,39 @@
+From 560ceb6a4d9e3bea57c29f5f3a7a1d671dfc7983 Mon Sep 17 00:00:00 2001
+From: Kent Overstreet <kent.overstreet@linux.dev>
+Date: Sat, 24 Feb 2024 19:14:36 -0500
+Subject: bcachefs: Fix BTREE_ITER_FILTER_SNAPSHOTS on inodes btree
+
+From: Kent Overstreet <kent.overstreet@linux.dev>
+
+commit 204f45140faa0772d2ca1b3de96d1c0fb3db8e77 upstream.
+
+If we're in FILTER_SNAPSHOTS mode and we start scanning a range of the
+keyspace where no keys are visible in the current snapshot, we have a
+problem - we'll scan for a very long time before scanning terminates.
+
+Awhile back, this was fixed for most cases with peek_upto() (and
+assertions that enforce that it's being used).
+
+But the fix missed the fact that the inodes btree is different - every
+key offset is in a different snapshot tree, not just the inode field.
+
+Fixes:
+Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/bcachefs/btree_iter.c |    4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+--- a/fs/bcachefs/btree_iter.c
++++ b/fs/bcachefs/btree_iter.c
+@@ -2094,7 +2094,9 @@ struct bkey_s_c bch2_btree_iter_peek_upt
+                * isn't monotonically increasing before FILTER_SNAPSHOTS, and
+                * that's what we check against in extents mode:
+                */
+-              if (k.k->p.inode > end.inode)
++              if (unlikely(!(iter->flags & BTREE_ITER_IS_EXTENTS)
++                           ? bkey_gt(k.k->p, end)
++                           : k.k->p.inode > end.inode))
+                       goto end;
+               if (iter->update_path &&
diff --git a/queue-6.7/bcachefs-fix-build-on-parisc-by-avoiding-__multi3.patch b/queue-6.7/bcachefs-fix-build-on-parisc-by-avoiding-__multi3.patch
new file mode 100644 (file)
index 0000000..aff118e
--- /dev/null
@@ -0,0 +1,41 @@
+From 457e1c3a398411789e04264486769a42cff4cf30 Mon Sep 17 00:00:00 2001
+From: Helge Deller <deller@kernel.org>
+Date: Sun, 28 Jan 2024 09:53:55 +0100
+Subject: bcachefs: Fix build on parisc by avoiding __multi3()
+
+From: Helge Deller <deller@kernel.org>
+
+commit eba38cc7578bef94865341c73608bdf49193a51d upstream.
+
+The gcc compiler on paric does support the __int128 type, although the
+architecture does not have native 128-bit support.
+
+The effect is, that the bcachefs u128_square() function will pull in the
+libgcc __multi3() helper, which breaks the kernel build when bcachefs is
+built as module since this function isn't currently exported in
+arch/parisc/kernel/parisc_ksyms.c.
+The build failure can be seen in the latest debian kernel build at:
+https://buildd.debian.org/status/fetch.php?pkg=linux&arch=hppa&ver=6.7.1-1%7Eexp1&stamp=1706132569&raw=0
+
+We prefer to not export that symbol, so fall back to the optional 64-bit
+implementation provided by bcachefs and thus avoid usage of __multi3().
+
+Signed-off-by: Helge Deller <deller@gmx.de>
+Cc: Kent Overstreet <kent.overstreet@linux.dev>
+Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/bcachefs/mean_and_variance.h |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/fs/bcachefs/mean_and_variance.h
++++ b/fs/bcachefs/mean_and_variance.h
+@@ -14,7 +14,7 @@
+  * type
+  */
+-#ifdef __SIZEOF_INT128__
++#if defined(__SIZEOF_INT128__) && defined(__KERNEL__) && !defined(CONFIG_PARISC)
+ typedef struct {
+       unsigned __int128 v;
diff --git a/queue-6.7/bcachefs-fix-simulateously-upgrading-downgrading.patch b/queue-6.7/bcachefs-fix-simulateously-upgrading-downgrading.patch
new file mode 100644 (file)
index 0000000..ddaf7be
--- /dev/null
@@ -0,0 +1,43 @@
+From 2d9720d70a26032492ad3a82765cdfaaf4bd038d Mon Sep 17 00:00:00 2001
+From: Kent Overstreet <kent.overstreet@linux.dev>
+Date: Fri, 5 Jan 2024 19:04:42 -0500
+Subject: bcachefs: fix simulateously upgrading & downgrading
+
+From: Kent Overstreet <kent.overstreet@linux.dev>
+
+commit e7999235e6c437b99fad03d8301a4341be0d2bb5 upstream.
+
+Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/bcachefs/super-io.c |   15 ++++++++++++---
+ 1 file changed, 12 insertions(+), 3 deletions(-)
+
+--- a/fs/bcachefs/super-io.c
++++ b/fs/bcachefs/super-io.c
+@@ -1085,13 +1085,22 @@ bool bch2_check_version_downgrade(struct
+       /*
+        * Downgrade, if superblock is at a higher version than currently
+        * supported:
++       *
++       * c->sb will be checked before we write the superblock, so update it as
++       * well:
+        */
+-      if (BCH_SB_VERSION_UPGRADE_COMPLETE(c->disk_sb.sb) > bcachefs_metadata_version_current)
++      if (BCH_SB_VERSION_UPGRADE_COMPLETE(c->disk_sb.sb) > bcachefs_metadata_version_current) {
+               SET_BCH_SB_VERSION_UPGRADE_COMPLETE(c->disk_sb.sb, bcachefs_metadata_version_current);
+-      if (c->sb.version > bcachefs_metadata_version_current)
++              c->sb.version_upgrade_complete = bcachefs_metadata_version_current;
++      }
++      if (c->sb.version > bcachefs_metadata_version_current) {
+               c->disk_sb.sb->version = cpu_to_le16(bcachefs_metadata_version_current);
+-      if (c->sb.version_min > bcachefs_metadata_version_current)
++              c->sb.version = bcachefs_metadata_version_current;
++      }
++      if (c->sb.version_min > bcachefs_metadata_version_current) {
+               c->disk_sb.sb->version_min = cpu_to_le16(bcachefs_metadata_version_current);
++              c->sb.version_min = bcachefs_metadata_version_current;
++      }
+       c->disk_sb.sb->compat[0] &= cpu_to_le64((1ULL << BCH_COMPAT_NR) - 1);
+       return ret;
+ }
diff --git a/queue-6.7/bcachefs-install-fd-later-to-avoid-race-with-close.patch b/queue-6.7/bcachefs-install-fd-later-to-avoid-race-with-close.patch
new file mode 100644 (file)
index 0000000..fa42474
--- /dev/null
@@ -0,0 +1,41 @@
+From 41db2999d156130e58fbf79dc73f8b986a445a58 Mon Sep 17 00:00:00 2001
+From: Mathias Krause <minipli@grsecurity.net>
+Date: Sun, 4 Feb 2024 08:51:52 +0100
+Subject: bcachefs: install fd later to avoid race with close
+
+From: Mathias Krause <minipli@grsecurity.net>
+
+commit dd839f31d7cd5e04f4111a219024268c6f6973f0 upstream.
+
+Calling fd_install() makes a file reachable for userland, including the
+possibility to close the file descriptor, which leads to calling its
+'release' hook. If that happens before the code had a chance to bump the
+reference of the newly created task struct, the release callback will
+call put_task_struct() too early, leading to the premature destruction
+of the kernel thread.
+
+Avoid that race by calling fd_install() later, after all the setup is
+done.
+
+Fixes: 1c6fdbd8f246 ("bcachefs: Initial commit")
+Signed-off-by: Mathias Krause <minipli@grsecurity.net>
+Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ fs/bcachefs/chardev.c |    3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+--- a/fs/bcachefs/chardev.c
++++ b/fs/bcachefs/chardev.c
+@@ -392,10 +392,9 @@ static long bch2_ioctl_data(struct bch_f
+               goto err;
+       }
+-      fd_install(fd, file);
+-
+       get_task_struct(ctx->thread);
+       wake_up_process(ctx->thread);
++      fd_install(fd, file);
+       return fd;
+ err:
index 2915bda4e898272a40f312bc2cb1da89d6b8b6ae..57fe8610a8ae3e9f812b6ef23bd7b147f43e57a8 100644 (file)
@@ -626,3 +626,8 @@ perf-x86-amd-core-avoid-register-reset-when-cpu-is-d.patch
 afs-revert-afs-hide-silly-rename-files-from-userspac.patch
 nfs-fix-panic-when-nfs4_ff_layout_prepare_ds-fails.patch
 io_uring-net-correct-the-type-of-variable.patch
+bcachefs-fix-build-on-parisc-by-avoiding-__multi3.patch
+bcachefs-install-fd-later-to-avoid-race-with-close.patch
+bcachefs-check-for-failure-to-downgrade.patch
+bcachefs-fix-simulateously-upgrading-downgrading.patch
+bcachefs-fix-btree_iter_filter_snapshots-on-inodes-btree.patch