Project

General

Profile

Actions

Bug #8978

closed

Fiddle possibly misuses mprotect

Added by mame (Yusuke Endoh) about 11 years ago. Updated almost 11 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 2.1.0dev (2013-10-02 trunk 43121) [x86_64-linux]
[ruby-core:57599]

Description

Hello Aaron,

Coverity Scan found a possible bug in "initialize" function of ext/fiddle/closure.c:

result = ffi_prep_closure(pcl, cif, callback, (void *)self);
...
i = mprotect(pcl, sizeof(pcl), PROT_READ | PROT_EXEC)

I don't understand the code completely, but the size of the pointer does not seem to make sense.
Perhaps, "sizeof(pcl)" should be "sizeof(*pcl)".

The same applies to dealloc:

munmap(cls->pc1, sizeof(cls->pc1));

BTW, ffi_prep_closure seems deprecated.
We should use ffi_prep_closure_loc instead when it is available.

--
Yusuke Endoh

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0