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)