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

ruby-changes:70619

From: U.Nakamura <ko1@a...>
Date: Mon, 27 Dec 2021 16:39:23 +0900 (JST)
Subject: [ruby-changes:70619] 9790f54bff (master): Call FlushInstrucitonCache() when PROT_EXEC is specified to mprotect

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

From 9790f54bff387b57579dc6f588bc29735eeae85b Mon Sep 17 00:00:00 2001
From: "U.Nakamura" <usa@r...>
Date: Mon, 27 Dec 2021 16:38:29 +0900
Subject: Call FlushInstrucitonCache() when PROT_EXEC is specified to mprotect

---
 include/ruby/win32.h | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/include/ruby/win32.h b/include/ruby/win32.h
index 287ac34270b..ac8d94f7787 100644
--- a/include/ruby/win32.h
+++ b/include/ruby/win32.h
@@ -812,8 +812,19 @@ extern int rb_w32_munmap(void *, size_t); https://github.com/ruby/ruby/blob/trunk/include/ruby/win32.h#L812
 extern int rb_w32_mprotect(void *, size_t, int);
 
 #define mmap(a, l, p, f, d, o) rb_w32_mmap(a, l, p, f, d, o)
-#define munmap(a, l) rb_w32_munmap(a. l)
-#define mprotect(a, l, p) 0
+#define munmap(a, l) rb_w32_munmap(a, l)
+
+static inline int
+mprotect(void *addr, size_t len, int prot)
+{
+    if (prot | PROT_EXEC) {
+        if (!FlushInstructionCache(GetCurrentProcess(), addr, len)) {
+            errno = rb_w32_map_errno(GetLastError());
+            return -1;
+        }
+    }
+    return 0;
+}
 
 #if defined(__cplusplus)
 #if 0
-- 
cgit v1.2.1


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

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