All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs-progs: mkfs: extent-tree-v2 related fixes
@ 2022-10-07 12:02 Qu Wenruo
  2022-10-07 12:03 ` [PATCH 1/2] btrfs-progs: mkfs: fix a crash when enabling extent-tree-v2 Qu Wenruo
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Qu Wenruo @ 2022-10-07 12:02 UTC (permalink / raw)
  To: linux-btrfs

Although recently we still have some uncertainty around the on-disk
format for extent-tree-v2, related to how to determine the number
of global roots, most of the on-disk format is fixed.

And even with the uncertain part involved, mkfs.btrfs should not crash
for extent-tree-v2 feature (hidden behind the experimental builds).

There are two bugs involved:

- A crash caused by incorrectly set chunk_objectid for block group item
  As extent-tree-v2 feature reuse that member to indicate which extent
  tree a block group belongs to.

  But the regular fs uses a fixed 256 for that chunk_objectid, and no
  extent-tree-v2 btrfs would have that many global roots.

  This leads to btrfs_extent_root() to return NULL, and cause later
  segfault.

  Fix it by properly setting chunk_objectid.
  This is a regression caused by 1430b41427b5 ("btrfs-progs: separate
  block group tree from extent tree v2").

- A stack-over-flow caused by too long feature string
  With extent-tree-v2 enabled, we have at least 84 bytes long feature
  string (unified features, including compat_ro features likle fst).

  This is beyond the hard-coded 64 bytes limit.

  Fix it by introducing a new macro to indicate a minimal safe buf size,
  and a sanity check to make sure that macro is really large enough.

Qu Wenruo (2):
  btrfs-progs: mkfs: fix a crash when enabling extent-tree-v2
  btrfs-progs: mkfs: fix a stack over-flow when features string are too
    long

 common/fsfeatures.c | 26 ++++++++++++++++++++++++++
 common/fsfeatures.h |  7 +++++++
 convert/main.c      |  3 ++-
 mkfs/common.c       | 14 ++++++++++++--
 mkfs/main.c         |  3 ++-
 5 files changed, 49 insertions(+), 4 deletions(-)

-- 
2.37.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-10-10 14:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-07 12:02 [PATCH 0/2] btrfs-progs: mkfs: extent-tree-v2 related fixes Qu Wenruo
2022-10-07 12:03 ` [PATCH 1/2] btrfs-progs: mkfs: fix a crash when enabling extent-tree-v2 Qu Wenruo
2022-10-08 11:51   ` Anand Jain
2022-10-07 12:03 ` [PATCH 2/2] btrfs-progs: mkfs: fix a stack over-flow when features string are too long Qu Wenruo
2022-10-08 11:52   ` Anand Jain
2022-10-10 14:34 ` [PATCH 0/2] btrfs-progs: mkfs: extent-tree-v2 related fixes David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.