[前][次][番号順一覧][スレッド一覧]

ruby-changes:63179

From: Aaron <ko1@a...>
Date: Tue, 29 Sep 2020 00:20:46 +0900 (JST)
Subject: [ruby-changes:63179] b9488accf9 (master): Fix ASAN support when invalidating CCs

https://git.ruby-lang.org/ruby.git/commit/?id=b9488accf9

From b9488accf9e2cbf5f7c47b42b3eb23469f0aa58d Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Fri, 25 Sep 2020 15:01:23 -0700
Subject: 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

diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c
index 074dfbd..d35bd80 100644
--- a/ext/objspace/objspace.c
+++ b/ext/objspace/objspace.c
@@ -59,7 +59,7 @@ total_i(void *vstart, void *vend, size_t stride, void *ptr) https://github.com/ruby/ruby/blob/trunk/ext/objspace/objspace.c#L59
     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) https://github.com/ruby/ruby/blob/trunk/ext/objspace/objspace.c#L77
 	    }
 	}
 
-        if (ptr) {
+        if (poisoned) {
             asan_poison_object(v);
         }
     }
diff --git a/vm.c b/vm.c
index 076bbbe..1b8b548 100644
--- a/vm.c
+++ b/vm.c
@@ -25,6 +25,7 @@ https://github.com/ruby/ruby/blob/trunk/vm.c#L25
 #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"
diff --git a/vm_method.c b/vm_method.c
index de48dc6..47ad040 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -240,6 +240,8 @@ invalidate_all_cc(void *vstart, void *vend, size_t stride, void *data) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L240
 {
     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) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L251
                 RCLASS_CC_TBL(v) = NULL;
             }
         }
+        if (ptr) {
+            asan_poison_object(v);
+        }
     }
     return 0; // continue to iteration
 }
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]