bcachefs: Fix sb_field_downgrade validation
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 6 May 2024 13:16:33 +0000 (09:16 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 9 May 2024 20:23:36 +0000 (16:23 -0400)
commit692aa7a54b2b28d59f24b3bf8250837805484b99
treef98b9bea93eb2e46ce274b25bb273e4017f2f17e
parenta5c3e265d3b61ab661df4f259a97b57840cb041e
bcachefs: Fix sb_field_downgrade validation

- bch2_sb_downgrade_validate() wasn't checking for a downgrade entry
  extending past the end of the superblock section

- for_each_downgrade_entry() is used in to_text() and needs to work on
  malformed input; it also was missing a check for a field extending
  past the end of the section

Reported-by: syzbot+e49ccab73449180bc9be@syzkaller.appspotmail.com
Fixes: 84f1638795da ("bcachefs: bch_sb_field_downgrade")
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/sb-downgrade.c