bcachefs: Fix pool->alloc NULL pointer dereference
PATCH 1/1 bcachefs: Fix pool->alloc NULL pointer dereference
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(+)
fs/bcachefs/chardev.c +3 -0
@@ -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 ;
Signature · 1 line
2.48.1
Quoted 15 lines · Alan Huang
btree_interior_update_poolhas not been initialized before the filesystem becomes read-write, thusmempool_allocinbch2_btree_update_startwill triggerpool->allocNULL pointer dereference inmempool_alloc_noprofReported-by [email protected]Signed-off-by Alan Huang <[email protected]>--- fs/bcachefs/chardev.c | 3 +++ 1 file changed, 3 insertions(+)fs/bcachefs/chardev.c +0
-0
fs/bcachefs/chardev.c static long bch2_ioctl_data(struct bch_fs *c, · line 383
Quoted 6 lines
fs/bcachefs/chardev.c +3
-0@@ -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 ; +
this isn't the right fix - we need to do a tryget and take a ref on c->writes
Quoted 6 lines
fs/bcachefs/chardev.c +0
-0if (!capable (CAP_SYS_ADMIN ))return -EPERM ;Signature · 1 line
2.48.1