Issue 47132 - C++ UNO Bridges: Use executable memory for generated proxy code
Summary: C++ UNO Bridges: Use executable memory for generated proxy code
Status: CLOSED FIXED
Alias: None
Product: udk
Classification: Code
Component: code (show other issues)
Version: 680m92
Hardware: All All
: P3 Trivial (vote)
Target Milestone: OOo 2.0.3
Assignee: matthias.huetsch
QA Contact: issues@udk
URL:
Keywords: oooqa
: 52428 61537 64754 (view as issue list)
Depends on: 23172 57764
Blocks:
  Show dependency tree
 
Reported: 2005-04-11 09:12 UTC by Stephan Bergmann
Modified: 2008-05-16 03:31 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
our current linux specific patch (3.32 KB, patch)
2006-01-27 09:30 UTC, caolanm
no flags Details | Diff
what we shipped as solution (9.17 KB, patch)
2006-03-20 10:01 UTC, caolanm
no flags Details | Diff
Testcase demonstrating allocation of executable memory via rtl_arena_* functionality (2.60 KB, text/plain)
2006-04-18 17:46 UTC, matthias.huetsch
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description Stephan Bergmann 2005-04-11 09:12:58 UTC
In bridges::cpp_uno::shared::VtableFactory::createBlock/flushCode, use
executable memory for the code snippets (and thus for the vtables also, although
this would not be necessary), and then generally use non-executable memory for
the heap.  (See, for example flushCode for msvc_win32_intel.)  Some new function
like rtl_allocateMemory(size, alloc_flags) is necessary in sal.
Comment 1 Stephan Bergmann 2005-04-11 09:13:36 UTC
accepted
Comment 2 Stephan Bergmann 2005-08-16 13:55:37 UTC
*** Issue 52428 has been marked as a duplicate of this issue. ***
Comment 3 Stephan Bergmann 2005-08-16 13:56:51 UTC
See duplicate issue 52428 for additional information.
Comment 4 caolanm 2006-01-26 08:56:32 UTC
A useful resource for the kind of things that'll fail/warn on e.g. future RHEL-5

http://people.redhat.com/drepper/selinux-mem.html
Comment 5 caolanm 2006-01-26 09:29:23 UTC
A useful resource for the kind of things that'll fail/warn on e.g. future RHEL-5

http://people.redhat.com/drepper/selinux-mem.html
Comment 6 caolanm 2006-01-27 09:30:32 UTC
Created attachment 33612 [details]
our current linux specific patch
Comment 7 Stephan Bergmann 2006-02-13 13:43:47 UTC
*** Issue 61537 has been marked as a duplicate of this issue. ***
Comment 8 Stephan Bergmann 2006-02-13 13:47:29 UTC
retargeted
Comment 9 caolanm 2006-03-20 10:01:16 UTC
Created attachment 35062 [details]
what we shipped as solution
Comment 10 Stephan Bergmann 2006-03-20 12:12:32 UTC
As discussed in the thread at
<http://www.openoffice.org/servlets/ReadMsg?list=dev&msgNo=16366>, postponed
until MHU offers appropriate functionality from rtl/alloc.h.
Comment 11 Stephan Bergmann 2006-04-07 08:14:25 UTC
@mhu:  Do you have an appropriate issue I can make this one dependent on?
Comment 12 matthias.huetsch 2006-04-07 09:40:56 UTC
Hi Stephan,

you can add this issue to cws_src680_mhu12 (also intended to be integrated into
OOo 2.0.3), and make it dependent on the issues that are registered for that cws
(mainly #i23172# and #i57764# me thinks).

Hope that helps,
Matthias
Comment 13 Stephan Bergmann 2006-04-07 10:00:10 UTC
@mhu:  Note that I am on vacation Apr 22 -- May 7, so can only adapt the bridges
code to any new rtl/alloc functionality before then.
Comment 14 matthias.huetsch 2006-04-18 17:46:47 UTC
Created attachment 35786 [details]
Testcase demonstrating allocation of executable memory via rtl_arena_* functionality
Comment 15 matthias.huetsch 2006-04-18 18:19:55 UTC
mhu->sb: The proposed (testcase) implementation might not look as simple as
possible, but in fact it is.

This is so, b/c it clearly separates concerns: one piece of code (the "my_*"
functions) provides executable memory (and returns it to the system), while the
other piece of code (the "rtl_arena_*" functions) manages this memory, and
allows to allocate and free it in user defined chunks (quanta).
Comment 16 Stephan Bergmann 2006-04-19 13:58:31 UTC
For regression testing, use testtools/source/bridgetest/ (see
<http://udk.openoffice.org/common/man/draft/tests.html>).
Comment 17 Stephan Bergmann 2006-04-19 14:18:29 UTC
... but see issue 63543 for current problems of testtools/source/bridgetest/.
Comment 18 Stephan Bergmann 2006-04-19 14:40:19 UTC
... for which the easiest workaround is to build testtools, then remove all
lines from "begin re-declaration of ambiguous base interfaces" to "end
re-declaration of ambiguous base interfaces" from
testtools/<platform>/inc/test/testtools/bridgetest/XMultiBase6.hdl, and re-build
testtools.
Comment 19 Stephan Bergmann 2006-04-19 14:42:02 UTC
@cmc:  If you would like to verify that the changes on CWS mhu12 indeed fix the
executable memory problem on SELinux, that would be great.
Comment 20 Stephan Bergmann 2006-04-21 12:18:04 UTC
@mhu:  As discussed, please take care of this issue while I am on vacation.

re-open issue and reassign to mhu@openoffice.org
Comment 21 Stephan Bergmann 2006-04-21 12:18:15 UTC
reassign to mhu@openoffice.org
Comment 22 Stephan Bergmann 2006-04-21 12:18:20 UTC
reset resolution to FIXED
Comment 23 matthias.huetsch 2006-04-28 13:01:45 UTC
This has now been verified (in a slightly modified revision, see below) on an
Athlon 64 system, running Fedora Core 5 with SELinux enabled (Sun internal: of-1).

The initial change in /bridges/source/cpp_uno/shared/vtablefactory.cxx had to be
adapted again, similiar to what cmc proposed recently: an mmap (PROT_READ |
PROT_WRITE | PROT_EXEC) will fail with "allow_execmem = false". Anon memory
needs to be mmap()'d w/o PROT_EXEC, and lateron mprotected() to become executable.

The apparently most clean solution (memory protection wise) is in cmc's 2nd
patch (of Mar 20): allocate writeable memory, assemble the code snippets, then
mprotect() to PROT_READ+PROT_EXEC.

But, even that may fail when "allow_execmod = false" which would let the
mprotect() call fail as well (though I haven't tested this myself).

Anyway, the fix is verified to work under "allow_execmem = false" => verified.
Comment 24 kpalagin 2007-04-15 11:37:55 UTC
*** Issue 64754 has been marked as a duplicate of this issue. ***
Comment 25 ace_dent 2008-05-16 03:31:42 UTC
This Issue is 'Verified' and not updated in 1yr+, so Closing.
A Closed Issue is a Happy Issue (TM).

Regards,
Andrew
 
Cleaning-up and Closing old Issues as part of:
~ The Grand Bug Squash, pre v3 ~