1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fix ASAN support when invalidating CCs

Again, this code is walking the heap.  Empty slots can be poisoned, so
we need to unpoison before checking the type
This commit is contained in:
Aaron Patterson 2020-09-25 15:01:23 -07:00 committed by Aaron Patterson
parent b328b83026
commit b9488accf9
Notes: git 2020-09-29 00:21:00 +09:00
3 changed files with 8 additions and 2 deletions

View file

@ -59,7 +59,7 @@ total_i(void *vstart, void *vend, size_t stride, void *ptr)
struct total_data *data = (struct total_data *)ptr;
for (v = (VALUE)vstart; v != (VALUE)vend; v += stride) {
void *ptr = asan_poisoned_object_p(v);
void *poisoned = asan_poisoned_object_p(v);
asan_unpoison_object(v, false);
if (RBASIC(v)->flags) {
@ -77,7 +77,7 @@ total_i(void *vstart, void *vend, size_t stride, void *ptr)
}
}
if (ptr) {
if (poisoned) {
asan_poison_object(v);
}
}

1
vm.c
View file

@ -25,6 +25,7 @@
#include "internal/re.h"
#include "internal/symbol.h"
#include "internal/vm.h"
#include "internal/sanitizers.h"
#include "iseq.h"
#include "mjit.h"
#include "ruby/st.h"

View file

@ -240,6 +240,8 @@ invalidate_all_cc(void *vstart, void *vend, size_t stride, void *data)
{
VALUE v = (VALUE)vstart;
for (; v != (VALUE)vend; v += stride) {
void *ptr = asan_poisoned_object_p(v);
asan_unpoison_object(v, false);
if (RBASIC(v)->flags) { // liveness check
if (RB_TYPE_P(v, T_CLASS) ||
RB_TYPE_P(v, T_ICLASS)) {
@ -249,6 +251,9 @@ invalidate_all_cc(void *vstart, void *vend, size_t stride, void *data)
RCLASS_CC_TBL(v) = NULL;
}
}
if (ptr) {
asan_poison_object(v);
}
}
return 0; // continue to iteration
}