aboutsummaryrefslogtreecommitdiff
path: root/lib/crypto/mpi/mpi-mod.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-06-22 22:02:09 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2024-06-23 00:57:21 -0400
commitde611ab6fc5ed0d68dd46319b9913353e3b459e9 (patch)
treee2578031174805e2c275dda00eb154242ab2e2fe /lib/crypto/mpi/mpi-mod.c
parent06efa5f30c28eaf237247ca8c4cb46eb62cb6bd9 (diff)
bcachefs: Fix race between trans_put() and btree_transactions_read()
debug.c was using closure_get() on a different thread's closure where the we don't know if the object being refcounted is alive. We keep btree_trans objects on a list so they can be printed by debug code, and because it is cost prohibitive to touch the btree_trans list every time we allocate and free btree_trans objects, cached objects are also on this list. However, we do not want the debug code to see cached but not in use btree_trans objects - critically because the btree_paths array will have been freed (if it was reallocated). closure_get() is also incorrect to use when that get may race with it hitting zero, i.e. we must already have a ref on the object or know the ref can't currently hit 0 for other reasons (as used in the cycle detector). to fix this, use the previously introduced closure_get_not_zero(), closure_return_sync(), and closure_init_stack_release(); the debug code now can only take a ref on a trans object if it's alive and in use. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'lib/crypto/mpi/mpi-mod.c')
0 files changed, 0 insertions, 0 deletions