Skip to content

Commit ef77858

Browse files
committed
Merge tag 'bcachefs-2025-04-10' of git://evilpiepirate.org/bcachefs
Pull bcachefs fixes from Kent Overstreet: "Mostly minor fixes. Eric Biggers' crypto API conversion is included because of long standing sporadic crashes - mostly, but not entirely syzbot - in the crypto API code when calling poly1305, which have been nigh impossible to reproduce and debug. His rework deletes the code where we've seen the crashes, so either it'll be a fix or we'll end up with backtraces we can debug. (Thanks Eric!)" * tag 'bcachefs-2025-04-10' of git://evilpiepirate.org/bcachefs: bcachefs: Use sort_nonatomic() instead of sort() bcachefs: Remove unnecessary softdep on xxhash bcachefs: use library APIs for ChaCha20 and Poly1305 bcachefs: Fix duplicate "ro,read_only" in opts at startup bcachefs: Fix UAF in bchfs_read() bcachefs: Use cpu_to_le16 for dirent lengths bcachefs: Fix type for parameter in journal_advance_devs_to_next_bucket bcachefs: Fix escape sequence in prt_printf
2 parents 0c7cae1 + 55fd97f commit ef77858

14 files changed

+96
-226
lines changed

fs/bcachefs/Kconfig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ config BCACHEFS_FS
1515
select ZLIB_INFLATE
1616
select ZSTD_COMPRESS
1717
select ZSTD_DECOMPRESS
18-
select CRYPTO
1918
select CRYPTO_LIB_SHA256
20-
select CRYPTO_CHACHA20
21-
select CRYPTO_POLY1305
19+
select CRYPTO_LIB_CHACHA
20+
select CRYPTO_LIB_POLY1305
2221
select KEYS
2322
select RAID6_PQ
2423
select XOR_BLOCKS

fs/bcachefs/bcachefs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,8 +981,8 @@ struct bch_fs {
981981
mempool_t compress_workspace[BCH_COMPRESSION_OPT_NR];
982982
size_t zstd_workspace_size;
983983

984-
struct crypto_sync_skcipher *chacha20;
985-
struct crypto_shash *poly1305;
984+
struct bch_key chacha20_key;
985+
bool chacha20_key_set;
986986

987987
atomic64_t key_version;
988988

fs/bcachefs/btree_journal_iter.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,6 @@ void bch2_btree_and_journal_iter_init_node_iter(struct btree_trans *trans,
644644
*/
645645
static int journal_sort_key_cmp(const void *_l, const void *_r)
646646
{
647-
cond_resched();
648-
649647
const struct journal_key *l = _l;
650648
const struct journal_key *r = _r;
651649

@@ -689,7 +687,8 @@ void bch2_journal_keys_put(struct bch_fs *c)
689687

690688
static void __journal_keys_sort(struct journal_keys *keys)
691689
{
692-
sort(keys->data, keys->nr, sizeof(keys->data[0]), journal_sort_key_cmp, NULL);
690+
sort_nonatomic(keys->data, keys->nr, sizeof(keys->data[0]),
691+
journal_sort_key_cmp, NULL);
693692

694693
cond_resched();
695694

fs/bcachefs/btree_node_scan.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static void try_read_btree_node(struct find_btree_nodes *f, struct bch_dev *ca,
183183
return;
184184

185185
if (bch2_csum_type_is_encryption(BSET_CSUM_TYPE(&bn->keys))) {
186-
if (!c->chacha20)
186+
if (!c->chacha20_key_set)
187187
return;
188188

189189
struct nonce nonce = btree_nonce(&bn->keys, 0);
@@ -398,7 +398,7 @@ int bch2_scan_for_btree_nodes(struct bch_fs *c)
398398
bch2_print_string_as_lines(KERN_INFO, buf.buf);
399399
}
400400

401-
sort(f->nodes.data, f->nodes.nr, sizeof(f->nodes.data[0]), found_btree_node_cmp_cookie, NULL);
401+
sort_nonatomic(f->nodes.data, f->nodes.nr, sizeof(f->nodes.data[0]), found_btree_node_cmp_cookie, NULL);
402402

403403
dst = 0;
404404
darray_for_each(f->nodes, i) {
@@ -418,7 +418,7 @@ int bch2_scan_for_btree_nodes(struct bch_fs *c)
418418
}
419419
f->nodes.nr = dst;
420420

421-
sort(f->nodes.data, f->nodes.nr, sizeof(f->nodes.data[0]), found_btree_node_cmp_pos, NULL);
421+
sort_nonatomic(f->nodes.data, f->nodes.nr, sizeof(f->nodes.data[0]), found_btree_node_cmp_pos, NULL);
422422

423423
if (0 && c->opts.verbose) {
424424
printbuf_reset(&buf);

fs/bcachefs/btree_write_buffer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,10 @@ static int bch2_btree_write_buffer_flush_locked(struct btree_trans *trans)
428428
*/
429429
trace_and_count(c, write_buffer_flush_slowpath, trans, slowpath, wb->flushing.keys.nr);
430430

431-
sort(wb->flushing.keys.data,
432-
wb->flushing.keys.nr,
433-
sizeof(wb->flushing.keys.data[0]),
434-
wb_key_seq_cmp, NULL);
431+
sort_nonatomic(wb->flushing.keys.data,
432+
wb->flushing.keys.nr,
433+
sizeof(wb->flushing.keys.data[0]),
434+
wb_key_seq_cmp, NULL);
435435

436436
darray_for_each(wb->flushing.keys, i) {
437437
if (!i->journal_seq)

0 commit comments

Comments
 (0)