From 2570f838da7ca82d586304d4669de49ced758bb6 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 10 Apr 2013 18:35:21 +0000 Subject: * ext/fiddle/closure.c (initialize): check mprotect's return value. If mprotect is failed because of PaX or something, its function call will cause SEGV. http://c5664.rubyci.org/~chkbuild/ruby-trunk/log/20130401T210301Z.diff.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ ext/fiddle/closure.c | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 582fec1707..1d7e032b1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Thu Apr 11 03:33:05 2013 NARUSE, Yui + + * ext/fiddle/closure.c (initialize): check mprotect's return value. + If mprotect is failed because of PaX or something, its function call + will cause SEGV. + http://c5664.rubyci.org/~chkbuild/ruby-trunk/log/20130401T210301Z.diff.html.gz + Wed Apr 10 17:39:13 2013 Tanaka Akira * ext/bigdecimal/bigdecimal.c (VpCtoV): Initialize a local variable diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c index fdb2233b22..d064f11991 100644 --- a/ext/fiddle/closure.c +++ b/ext/fiddle/closure.c @@ -228,7 +228,10 @@ initialize(int rbargc, VALUE argv[], VALUE self) #else result = ffi_prep_closure(pcl, cif, callback, (void *)self); cl->code = (void *)pcl; - mprotect(pcl, sizeof(pcl), PROT_READ | PROT_EXEC); + i = mprotect(pcl, sizeof(pcl), PROT_READ | PROT_EXEC); + if (i) { + rb_sys_fail("mprotect"); + } #endif if (FFI_OK != result) -- cgit v1.2.3