Skip to content

Commit 8440da9

Browse files
author
Kent Overstreet
committed
bcachefs: Fix UAF in __promote_alloc() error path
If we error in data_update_init() after adding to the rhashtable of outstanding promotes, kfree_rcu() is required. Reported-by: Reed Riley <reed@riley.engineer> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent f9f0a53 commit 8440da9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/bcachefs/io_read.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ static struct promote_op *__promote_alloc(struct btree_trans *trans,
262262
bio_free_pages(&(*rbio)->bio);
263263
kfree(*rbio);
264264
*rbio = NULL;
265-
kfree(op);
265+
/* We may have added to the rhashtable and thus need rcu freeing: */
266+
kfree_rcu(op, rcu);
266267
bch2_write_ref_put(c, BCH_WRITE_REF_promote);
267268
return ERR_PTR(ret);
268269
}

0 commit comments

Comments
 (0)