]> Git Repo - linux.git/commitdiff
bcachefs: Fix UAF in __promote_alloc() error path
authorKent Overstreet <[email protected]>
Wed, 6 Nov 2024 21:40:08 +0000 (16:40 -0500)
committerKent Overstreet <[email protected]>
Thu, 7 Nov 2024 21:48:21 +0000 (16:48 -0500)
If we error in data_update_init() after adding to the rhashtable of
outstanding promotes, kfree_rcu() is required.

Reported-by: Reed Riley <[email protected]>
Signed-off-by: Kent Overstreet <[email protected]>
fs/bcachefs/io_read.c

index ac6a6fcc2bb8fd679c14d4d383c787fea2017ad5..b3b934a87c6de1962d07e93ac2ff9843729edaee 100644 (file)
@@ -262,7 +262,8 @@ err:
                bio_free_pages(&(*rbio)->bio);
        kfree(*rbio);
        *rbio = NULL;
-       kfree(op);
+       /* We may have added to the rhashtable and thus need rcu freeing: */
+       kfree_rcu(op, rcu);
        bch2_write_ref_put(c, BCH_WRITE_REF_promote);
        return ERR_PTR(ret);
 }
This page took 0.046563 seconds and 4 git commands to generate.