bcachefs: Fix sb-downgrade validation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Kent Overstreet <kent.overstreet@xxxxxxxxx>

commit 9242a34b760648b722f4958749ad83ef7d0f7525 upstream.

Superblock downgrade entries are only two byte aligned, but section
sizes are 8 byte aligned, which means we have to be careful about
overrun checks; an entry that crosses the end of the section is allowed
(and ignored) as long as it has zero errors.

Signed-off-by: Kent Overstreet <kent.overstreet@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 fs/bcachefs/sb-downgrade.c |    8 ++++++++
 1 file changed, 8 insertions(+)

--- a/fs/bcachefs/sb-downgrade.c
+++ b/fs/bcachefs/sb-downgrade.c
@@ -146,6 +146,14 @@ static int bch2_sb_downgrade_validate(st
 	for (const struct bch_sb_field_downgrade_entry *i = e->entries;
 	     (void *) i	< vstruct_end(&e->field);
 	     i = downgrade_entry_next_c(i)) {
+		/*
+		 * Careful: sb_field_downgrade_entry is only 2 byte aligned, but
+		 * section sizes are 8 byte aligned - an empty entry spanning
+		 * the end of the section is allowed (and ignored):
+		 */
+		if ((void *) &i->errors[0] > vstruct_end(&e->field))
+			break;
+
 		if (BCH_VERSION_MAJOR(le16_to_cpu(i->version)) !=
 		    BCH_VERSION_MAJOR(le16_to_cpu(sb->version))) {
 			prt_printf(err, "downgrade entry with mismatched major version (%u != %u)",


Patches currently in stable-queue which might be from kent.overstreet@xxxxxxxxx are

queue-6.9/bcachefs-btree_gc-can-now-handle-unknown-btrees.patch
queue-6.9/bcachefs-fix-sb-downgrade-validation.patch
queue-6.9/bcachefs-fix-bch2_sb_downgrade_update.patch
queue-6.9/bcachefs-fix-sb_field_downgrade-validation.patch
queue-6.9/bcachefs-fix-setting-of-downgrade-recovery-passes-errors.patch




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux