1

So basically I am trying to re-implement a memory protection technique, with the description like this:

  • A 256M segment is reserved for application code and
  • A 512M segment is reserved for some special data (can't be modified during runtime)
  • ...
  • %fs register is used to access the 512M memory of special data.

I am thinking to leverage some segmentation based protection on 32bit x86, however, I am trapped in the first step, how to reserve some memory for the special data mentioned above ?

So basically what i am trying to do is very similar with Google's Native Client, I quote some thing for its wiki.

The x86-32 implementation of Native Client is notable for its novel sandboxing method which makes use of the x86 architecture's rarely used segmentation facility.

Native Client sets up x86 segments to restrict the memory range that the sandboxed code can access.

Could anyone give me some help on this issue ?

  • 1
    In Virtual Memory Operating Systems memory protection is implemented by the OS, which application code has no control over. Unless you are writing some emulator or a virtual machine you cannot guarantee that memory will always be available at some specific address. Even the VirtualAlloc will not reserve memory at any adress. – 0xec Jul 13 '14 at 3:51
  • @ExtremeCoders, I modified the question, I made something wrong before. anyway, there should be some methods, thinking of Google's NaCI paper – lllllllllllll Jul 13 '14 at 13:44
  • Google's NaCl implementation is complex and uses many techniques. See this related qs on SO. This pdf analyzes the NaCl architecture. – 0xec Jul 13 '14 at 18:22
  • There are certain limitations, but you should have a look at the Windows API, and specifically functions such as VirtualProtect(). Some methods for virtual memory management are also used for anti-debugging purposes, e.g. using VirtualProtect() and ZeroMemory() an application may strip its PE header. – JamalS Jul 18 '14 at 12:08
1

If this is for Linux then take a look at http://linux.die.net/man/2/arch_prctl, specifically at the ARCH_SET_FS option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.