diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-11-25 21:42:08 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-11-28 17:18:24 -0500 |
commit | d5bd37872a93e07ef3f9cbd4e2044ba4e17b5021 (patch) | |
tree | 384c3cf27f42ae8703eae10696a1e49ee4f3a2f7 /fs/bcachefs/journal_io.c | |
parent | bbc3a46065d08f9ab3412b1f26bbfa778c444833 (diff) | |
download | linux-stable-d5bd37872a93e07ef3f9cbd4e2044ba4e17b5021.tar.gz linux-stable-d5bd37872a93e07ef3f9cbd4e2044ba4e17b5021.tar.bz2 linux-stable-d5bd37872a93e07ef3f9cbd4e2044ba4e17b5021.zip |
bcachefs: Add missing validation for jset_entry_data_usage
Validation was completely missing for replicas entries in the journal
(not the superblock replicas section) - we can't have replicas entries
pointing to invalid devices.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/journal_io.c')
-rw-r--r-- | fs/bcachefs/journal_io.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/fs/bcachefs/journal_io.c b/fs/bcachefs/journal_io.c index 02e6484f9953..0f17fc5f8d68 100644 --- a/fs/bcachefs/journal_io.c +++ b/fs/bcachefs/journal_io.c @@ -547,6 +547,7 @@ static int journal_entry_data_usage_validate(struct bch_fs *c, struct jset_entry_data_usage *u = container_of(entry, struct jset_entry_data_usage, entry); unsigned bytes = jset_u64s(le16_to_cpu(entry->u64s)) * sizeof(u64); + struct printbuf err = PRINTBUF; int ret = 0; if (journal_entry_err_on(bytes < sizeof(*u) || @@ -555,10 +556,19 @@ static int journal_entry_data_usage_validate(struct bch_fs *c, journal_entry_data_usage_bad_size, "invalid journal entry usage: bad size")) { journal_entry_null_range(entry, vstruct_next(entry)); - return ret; + goto out; } + if (journal_entry_err_on(bch2_replicas_entry_validate(&u->r, c->disk_sb.sb, &err), + c, version, jset, entry, + journal_entry_data_usage_bad_size, + "invalid journal entry usage: %s", err.buf)) { + journal_entry_null_range(entry, vstruct_next(entry)); + goto out; + } +out: fsck_err: + printbuf_exit(&err); return ret; } |