summaryrefslogtreecommitdiff
path: root/error.c
diff options
context:
space:
mode:
authorAlan Wu <[email protected]>2024-12-19 12:28:21 -0500
committerGitHub <[email protected]>2024-12-19 12:28:21 -0500
commit5978f2f114a5a669a39cdc46c457a3ea8ee24056 (patch)
treecd2616b9f860b04b2b3165a7f81eafd9cc9a2684 /error.c
parentce849d565bf6aae8e0179fffb04eb1f665f17347 (diff)
Fix use-after-free in vm_ccs_free()
`struct rb_callcache *` point to an imemo object on the GC heap when pushed into `struct rb_class_cc_entries`, but by the time vm_ccs_free() runs, the entire GC page the imemo was on could already be deallocated. With the right conditions, vm_ccs_free() wrote to freed memory. rb_objspace_garbage_object_p() by itself is not enough to determine liveness. I conjectured this situation to be possible in <https://github.com/ruby/ruby/pull/11995> using hints from crashes in the wild. With c37bdfa5311be0aa8503b995299fb9547cede0a6 ("Make asan_poison_object poison the whole slot"), the in-tree test suite now recreates this scenario[^1][^2][^3]. Use rb_gc_pointer_to_heap_p(). Other uses of rb_objspace_garbage_object_p() could be making the same mistake, but correcting them might introduce serious performance regressions, so leave them alone for now. [^1]: http://ci.rvm.jp/results/trunk_asan@ruby-sp1/5477412 [^2]: http://ci.rvm.jp/results/trunk_asan@ruby-sp1/5477445 [^3]: http://ci.rvm.jp/results/trunk_asan@ruby-sp1/5477448
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/12401 Merged-By: XrXr
Diffstat (limited to 'error.c')
0 files changed, 0 insertions, 0 deletions