btree_interior_update_pool has not been initialized before the
filesystem becomes read-write, thus mempool_alloc in bch2_btree_update_start
will trigger pool->alloc NULL pointer dereference in mempool_alloc_noprof

Reported-by: [email protected]
Signed-off-by: Alan Huang <[email protected]>
---
 fs/bcachefs/chardev.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/bcachefs/chardev.c b/fs/bcachefs/chardev.c
index fde3c2380e28..ec8d0719a543 100644
--- a/fs/bcachefs/chardev.c
+++ b/fs/bcachefs/chardev.c
@@ -378,6 +378,9 @@ static long bch2_ioctl_data(struct bch_fs *c,
        struct bch_data_ctx *ctx;
        int ret;
 
+       if (!test_bit(BCH_FS_rw, &c->flags))
+               return -EINVAL;
+
        if (!capable(CAP_SYS_ADMIN))
                return -EPERM;
 
-- 
2.48.1


Reply via email to