Slashdot Mirror


Exec Shield for the Linux Kernel

DarkOx writes "There is a new patch from Ingo Molnar which can prevent overflow attacks. The scoop from KernelTrap is as follows: Ingo Molnar has announced a new kernel-based security feature for Linux/x86 called 'Exec Shield'. He describes the patch, which is against the 2.4.20-rc1 kernel, as: 'The exec-shield feature provides protection against stack, buffer or function pointer overflows, and against other types of exploits that rely on overwriting data structures and/or putting code into those structures. The patch also makes it harder to pass in and execute the so-called 'shell-code' of exploits. The patch works transparently, ie. no application recompilation is necessary.'"

42 of 264 comments (clear)

  1. grsec ? by destiney · · Score: 5, Interesting


    Sounds like much of the same security that's been available from grsecurity.net for quite a while now.

    1. Re:grsec ? by groomed · · Score: 3, Informative

      I'm not familiar with grsec, but from a brief glance at the grsec site I don't see how they are alike. grsec appears to be an ACL based security model, whereas exec-shield just makes it a lot harder for the CPU to execute code that was never meant to be executed (from the owner of the machine's point of view...).

    2. Re:grsec ? by cras · · Score: 4, Informative

      Yes, grsecurity includes equilevant protection to this. It uses PAX kernel patch for this. It has existed for years, and Ingo really should have mentioned that in his announcement, assuming he even knew about it?

      Difference is that PAX uses some weird x86 kludges to do this and it causes slight speed difference (max. 10% IIRC), but I think that's a very small penalty for very good protection against buffer overflows. It also reduces the maximum memory available to process by .. was it 1-2GB, but there's not many processes that really need that much. And Ingo's patch seems to limit at least number of executable pages even more so.

    3. Re:grsec ? by Anonymous Coward · · Score: 3, Informative

      > The segmentation part of grsecurity still allows an exploit to return to a shared library addresses

      Wrong, address randomization prevents that (in a probabilistic sense). Nor does Exec Shield prevent it (hint: i386 is little endian).

      > The Exec Shield also tries to limit the size of
      > the code segment much more than the
      > segmentation-based solution in grsecurity
      > - resulting in a much smaller area of attack.

      You don't have many clues what you're talking about, do you? ;-) SEGMEXEC in PaX/grsec *completely* separates code from data, absolutely not true for Exec Shield. Studying the docs at http://pageexec.virtualave.net/docs/ or at least taking a look at /proc//maps would be useful...

      As for the paging based solution: it's not the default, so no wonder not many people are using it ;-). And they don't need to since SEGMEXEC does all and without the performance impact.

      > [Exec Shield] probably gets more [coverage]
      > than the segmentation based PaX method

      Completely false, see above.

  2. Yes, but does it... by Anonymous Coward · · Score: 3, Funny

    prevent people from logging into X as root and screwing up their system.

    A cure for stupidity is a many-splendored thing - Publius Julius Caesar on the day before the ides of March ## B.C.

  3. WOW! by benna · · Score: 4, Interesting

    Two stories today with reasons to switch to linux. First IE dies with simple HTML (But really is it any surprise that this is possible) and now a sweet knewe patch for linux. Could it be any better?

    --
    "It is not how things are in the world that is mystical, but that it exists." -Ludwig Wittgenstein
    1. Re:WOW! by geddes · · Score: 4, Funny
      Two stories today with reasons to switch to linux
      You don't browse here often do you?
  4. Ingo's announcement by steveha · · Score: 3, Informative

    http://people.redhat.com/mingo/exec-shield/ANNOUNC E-exec-shield
    _____________________________________________

    [Announcement] "Exec Shield", new Linux security feature

    We are pleased to announce the first publically available source code
    release of a new kernel-based security feature called the "Exec Shield",
    for Linux/x86. The kernel patch (against 2.4.21-rc1, released under the
    GPL/OSL) can be downloaded from:

    http://redhat.com/~mingo/exec-shield/

    The exec-shield feature provides protection against stack, buffer or
    function pointer overflows, and against other types of exploits that rely
    on overwriting data structures and/or putting code into those structures.
    The patch also makes it harder to pass in and execute the so-called
    'shell-code' of exploits. The patch works transparently, ie. no
    application recompilation is necessary.

    Background:
    -----------

    It is commonly known that x86 pagetables do not support the so-called
    executable bit in the pagetable entries - PROT_EXEC and PROT_READ are
    merged into a single 'read or execute' flag. This means that even if an
    application marks a certain memory area non-executable (by not providing
    the PROT_EXEC flag upon mapping it) under x86, that area is still
    executable, if the area is PROT_READ.

    Furthermore, the x86 ELF ABI marks the process stack executable, which
    requires that the stack is marked executable even on CPUs that support an
    executable bit in the pagetables.

    This problem has been addressed in the past by various kernel patches,
    such as Solar Designer's excellent "non-exec stack patch". These patches
    mostly operate by using the x86 segmentation feature to set the code
    segment 'limit' value to a certain fixed value that points right below the
    stack frame. The exec-shield tries to cover as much virtual memory via the
    code segment limit as possible - not just the stack.

    Implementation:
    ---------------

    The exec-shield feature works via the kernel transparently tracking
    executable mappings an application specifies, and maintains a 'maximum
    executable address' value. This is called the 'exec-limit'. The scheduler
    uses the exec-limit to update the code segment descriptor upon each
    context-switch. Since each process (or thread) in the system can have a
    different exec-limit, the scheduler sets the user code segment dynamically
    so that always the correct code-segment limit is used.

    the kernel caches the user segment descriptor value, so the overhead in
    the context-switch path is a very cheap, unconditional 6-byte write to the
    GDT, costing 2-3 cycles at most.

    Furthermore, the kernel also remaps all PROT_EXEC mappings to the
    so-called ASCII-armor area, which on x86 is the addresses 0-16MB. These
    addresses are special because they cannot be jumped to via ASCII-based
    overflows. E.g. if a buggy application can be overflown via a long URL:

    http://somehost/buggy.app?realyloooooooooooooooooo oong.123489719875

    then only ASCII (ie. value 1-255) characters can be used by attackers. If
    all executable addresses are in the ASCII-armor, then no attack URL can be
    used to jump into the executable code - ie. the attack cannot be
    successful. (because no URL string can contain the \0 character.) E.g. the
    recent sendmail remote root attack was an ASCII-based overflow as well.

    With the exec-shield activated, and the 'cat' binary relinked into the the
    ASCII-armor, the following layout is created:

    $ ./cat-lowaddr /proc/self/maps
    00101000-00116000 r-xp 00000000 03:01 319365 /lib/ld-2.3.2.so
    00116000-00117000 rw-p 00014000 03:01 319365 /lib/ld-2.3.2.so
    00117000-0024a000 r-xp 00000000 03:01 319439 /lib/libc-2.3.2.so
    0024a000-00

    --
    lf(1): it's like ls(1) but sorts filenames by extension, tersely
  5. Re:Great! [Scott] by wass · · Score: 5, Insightful
    In addition, we can now write sloppy code and just tell people to install this patch first!

    Well, yes and no. Think about the analogy of this to driving. Cars today have a number of safety features, including seat belts, air-bags, anti-lock breaks, etc. Do we drive less safely because of them? More importantly, should we not include these devices in cars to increase driving safety?

    I believe it was Chris Rock joking about this in one of his sketches. He claimed that airbags are NOT going to make someone drive safely. He said something like "What you need is a giant spike coming out of the steering wheel. That'll make someone drive safe!".

    --

    make world, not war

  6. Re:Great! by groomed · · Score: 4, Informative
    Nah. From the announce:

    the patch was designed to be as efficient as possible. There's a very minimal (couple of cycles) tracking overhead for every PROT_MMAP system-call, plus there's the 2-3 cycles cost per context-switch.

  7. This is good. by dracocat · · Score: 5, Interesting

    While of course all of our software should be correct, using the Operating System to make software more robust is almost always a good thing.

    Assuming their claims of extremely low over-head are true, why would we not want this?

    In fact, a lot of security issues could be stopped before they ever happen if we look more closely at the Operating System instead of all the software! Think how much easier it would be to work on isolating software and protecting the system from itself than trying to make every single app ever written secure. Yes, focusing attention to the Operating System for vulerabilites is a good step--even though we can't ignore our applications.

    1. Re:This is good. by RealUlli · · Score: 4, Insightful
      Very true. It's one of the odd curiosities I've always seen between security issues for Linux and Windows. Linux has the exploits published against applications, and Windows has them published against the OS when an application is exploited.

      Well, as long as MS keeps claiming IE, IIS etc. are part of the operating system and can not be separated, exploits against those parts should be filed against the OS. In Linux, when an application gets exploited, well you don't have to run that application, you don't even have to install it, it *is* separable from the OS! Especially as there are alternatives to (almost) everything...

      Regards, Ulli

      --
      Simple things should be simple, complex things should be possible.
    2. Re:This is good. by karlm · · Score: 4, Insightful
      I have to wonder if this will move the Linux kernal closer to the level of the Windows Kernal [READ, EASE OF USE - NOT SECURITY] for overall marketability to individuals.

      Umm... do you have some vague notion of what the kernel is? First of all, it isn't spelled with an "a". Secondly, ease of use of a kernel is a very messed up concept and I'm not even sure what it means. The kernel isn't easy or hard to use any more than winsock.dll is easy or hard to use. Very few programmers interact with the kernel except through libraries, so "easy of use" (whatever you mean by that) is much more important in the low-level libraris than the kernel. How does this affect marketability to individuals? Both POSIX and Win32 APIs are available on both systems. Are you referring to clean kernel interfaces, clean kernel implementation, availablility of the source for better understanding, or some other metric?

      Kernel: That word... you keep using it. I do not think it means what you think it means.

      I think you're thinking about UI. The GUI, the shell, the command line, the layout of the directories, etc. are all very very far removed from the kernel. In theory you could run explorer (the Win32 shell, not IE) on top of WINE, along with all of the Win32 programs and the user would have identical ease of use as Windows. 99.99% of users couldn't tell it wasn't the NT kernel and couldn't show evidence of it being Linux even if told (without watching the boot sequence). Asking about "ease of use" of a kernel is like asking about the top speed of your house. Neither question makes much sense unless you further define your strange thinking. You could guess that the person is asking how fast a house would be going when it hit the ground if dropped from 60,000 feet up (terminal velociy) just like you could assume a person is talking about how clean a kernel's APIs are. However, the usual sense of ease of use as realated to marketing to individuals is ease of use of the UI. I can only make educated guesses as to what strange thoughts are going through your head. For all I know, you filled hard drive platters up with both kernels and are attempting to use the platters to cut 440 stainless bar stock and are referring to the different metal cutting characteristics of kernel-filled HD platters. Please clarify exactly how you think the ease of use of the NT and Linux kerenls differ.

      --
      Copyright Violation:"theft, piracy"::Anti-Trust Violation:"thermonuclear price terrorism"<-Overly dramatic language.
  8. Uh Oh... by Cylix · · Score: 5, Funny

    You do realise this kind of advancement would not be possible with out assistance from highly successful companies like SC...

    Hrm...

    "Shit, spaceballs, there goes the planet" --apes

    --
    "You should always go to other people's funerals; otherwise, they won't come to yours." -- Yogi Berra
  9. Re:Yeah... by damiam · · Score: 4, Funny

    You're forgetting XBill.

    --
    It's hard to be religious when certain people are never incinerated by bolts of lightning.
  10. "read or execute" flag? by steveha · · Score: 4, Insightful

    I'm trying to understand this fully, but I don't have all the background to do so.

    From the announcement:

    It is commonly known that x86 pagetables do not support the so-called executable bit in the pagetable entries - PROT_EXEC and PROT_READ are merged into a single 'read or execute' flag. This means that even if an application marks a certain memory area non-executable (by not providing the PROT_EXEC flag upon mapping it) under x86, that area is still executable, if the area is PROT_READ.

    Is this limitation in the x86 processor MMU, or in the Linux kernel?

    Is anyone working to fix this limitation? (E.g. AMD fixing it in 64-bit mode on the Opteron, or someone reworking the Linux kernel)

    Furthermore, the x86 ELF ABI marks the process stack executable, which requires that the stack is marked executable even on CPUs that support an executable bit in the pagetables.

    Does this statement imply that some x86 processors do the right thing with PROT_EXEC?

    If Linus is willing to create a new ELF standard, could this problem be fixed? Would it be worth the pain of a new incompatible ELF standard? Are there any other problems that can only be fixed with a new version of ELF, so we can fix them together?

    It would be sort of cool to get a new ELF standard, so that Linus can call the new kernel "3.0"! :-)

    steveha

    --
    lf(1): it's like ls(1) but sorts filenames by extension, tersely
    1. Re:"read or execute" flag? by Anonymous Coward · · Score: 5, Informative

      The limitation is with most x86 processors. The new AMD x86-64 architecture does not suffer from this problem, and I believe linux on it defaults to nonexecutable stack (at least that's what was said on the LKML).

    2. Re:"read or execute" flag? by mark-t · · Score: 4, Informative
      Is this a limitation of the x86? No, not really.

      The problem is the way that people use x86's paging mechanism. Each page can, in fact, be distinctly assigned to being either code or data, but because each page requires a distinct entry in the page table, if each process had to have separate code and data pages, then it would stand to double the number of page table entries.

      So why did they do it this way, if it was so simple to avoid? Back in the early 90's, when Linux was first written, it was highly desirable (with protected mode code in general) to minimize distinct page table entries in the x86 because page tables could take up so much space. So protected mode programs (and operating systems) were typically designed so that the code and data segment descriptors could end up mapping to the same pages in the x86's paging mechanism to reduce overall page count.

      Indeed, if the x86 had not allowed a page to be both writeable and executable, then this would never have been an issue. Although it would have had the memory overhead in the page table entries that I described earlier, since we wouldn't have even had a choice in the matter, we would have just had to settle for what we got (although back then the design would have likely been criticized as being wasteful of memory).

    3. Re:"read or execute" flag? by HidingMyName · · Score: 4, Insightful

      Read or execute may only be a problem because when we want to allow stack access with read/write permissions, we wind up granting execute/write permissions. I think OpenBSD is working on getting rid of having both write and execute permissions on the same memory region. However, Linux may not be able to follow suit due to the use of trampoline functions (as described here). How OpenBSD plans to get around this, I'm not sure, it is possible that I have a faulty memory regarding OpenBSD's avoidance of write/execute in the kernel.

    4. Re:"read or execute" flag? by IkeTo · · Score: 5, Informative

      This means that even if an application marks a certain memory area non-executable (by not providing the PROT_EXEC flag upon mapping it) under x86, that area is still executable, if the area is PROT_READ.

      Does this statement imply that some x86 processors do the right thing with PROT_EXEC?

      No. The x86 page table has 12 bits per page table entry for storing page information. It contains a bit for R/W (read/write) which you can force a page read-only; and it contains a bit U/S (user/supervisor) which you can force a page usable only by the kernel. There is nothing which says "this page must not be executed as code". So Linux kernel actually has an interface that only some hardware provides. I don't think now it still has spare bit to give for executable bit.

      Furthermore, the x86 ELF ABI marks the process stack executable, which requires that the stack is marked executable even on CPUs that support an executable bit in the pagetables.

      Does this statement imply that some x86 processors do the right thing with PROT_EXEC?

      It is not about "do the right thing". The processor simply has no such bit, so there is no new "right thing" for it to do---it is already doing the right thing. The processor assumes that segmentation is used to enforce execute permission, so that each library code should be allocated a segment and inter-segment jumps and calls should be used to access them. In such way only read-only code segments are executable. Linux simply decided at the very beginning not to employ this facility.

      If Linus is willing to create a new ELF standard, could this problem be fixed?
      ELF is not designed by Linus. And even if ELF is changed so that stack is not assumed executable by default (which probably break some programs that rely on executable stack), all computers from 386 to P4 will not benefit from it.
  11. Saturday night /. Session by Anonymous Coward · · Score: 5, Funny


    Another saturday night spent on /. When I look back, this is what I'll remember.

  12. easier on x86-64 by ceswiedler · · Score: 5, Informative

    Someone on lkml asked:

    Slightly off-topic, but does anybody know whether IA64 or x86-64 allow you to make the stack non-executable in the same way you can on SPARC?

    and hpa replied to this:

    x86-64 definitely does, and it's the default on Linux/x86-64.

    Up to now, x86 chips have not been able to separate Read from Execute privileges for memory segments, which makes it hard to make stacks non-executable. This is excellent news for anyone looking forward to AMD's x86-64 chips...it keeps looking like they've done the Right Things.

  13. Just one problem with it... by Fefe · · Score: 4, Insightful

    The page says they are mapping all the code in the lower 16 MB of the address space. And they keep the first MB unmapped for NULL pointer protection.

    That leaves us with only 15 MB of space for code!

    Are they really trying to say that they have not hit that limit yet? No program on earth has more than 15 MB code?! I can hardly believe that.

    I was going to cite Emacs on this one, but Emacs is an interpreter, so the actual interpreter code might be small enough. Mhh. What about Mozilla?

    Heck, what about WINE?! ;) They are emulating Windoze, you can't be serious about those 15 MB! That'll hardly contain GDI.DLL!

    1. Re:Just one problem with it... by i_am_nitrogen · · Score: 4, Informative

      It only says the code is mapped to the bottom 15MB. Each program has its own address space. It still exists in any part of physical memory it wants to, but the beginning virtuial address is put in the lower 16MB instead of the current default, which I believe relocates programs to 0x08048000 or something like that.

  14. Possible Problem by Sunlighter · · Score: 5, Interesting

    I've written a few pieces of code which take advantage of the executability of the stack and the heap. For example if you want to write a just-in-time compiler for some language, an easy way to do it is allocate an area on the heap, let the JIT compiler write the appropriate x86 machine code into that area, and then typecast the area pointer to a function pointer and execute it.

    With this patch, that won't work...

    --
    Sunlit World Scheme. Weird and different.
    1. Re:Possible Problem by Soko · · Score: 4, Informative

      Would a memcopy from the heap into executeable space be a fix?

      Perhaps even better would be to have your own "private" heap in userland. That would protect the OS, and you get to use your trick still.

      I'm not a coder by trade, so I can't really critisize what you're doing. I do understand operating systems and memory allocation therein though, so my admittedly uninformed opinion is that you're employing a somewhat dangerous hack here. The heap was not intended to hold executeable programs - you'd be broken on x86-64 as well. Using what amounts to a design flaw in a program isn't what I would be willing to call "good design". Might be better to come up with a different method - Ingo Molnar seems to think you do at any rate.

      Soko

      --
      "Depression is merely anger without enthusiasm." - Anonymous
  15. Potentially Stupid Question by Farley+Mullet · · Score: 3, Interesting

    (As I'm sure you can tell) I don't claim to know much about any of this at all, but I did read the kerneltrap post, for what it was worth, and as a non-x86 user, I have a few questions. Ingo's patch is only for x86; is equivalent protection for other architectures possible, or even necessary? To what extent are buffer-overflow exploits architecture specific?

    Sorry if I'm missing something simple here.

    1. Re:Potentially Stupid Question by DarkMan · · Score: 4, Interesting

      Yes you could do this for other hardware plaforms.

      However ... most other CPU's have had the ability to use writable but not executable and executable but not writable heaps for a while. x86 does not. This is why you get a whole bundle of problems with it, as buffer overruns write code in the heap, then get it executed. The patch is an atempt to mitigate the adverse effects of that hardware weakness.

      It's not perfect (nor is the better hardware solution). However, it will make many exploits an order of magnitude more complex, making writing and utilising them a much more complex task.

      The part about locating code inside the ASCII armour is, however, zero overhead, and will, I think, get wrapped into mainline on all archtectures (although possbily not till 2.7)

  16. openwall patch by wotevah · · Score: 3, Informative
    This feature looks similar to what the openwall patch does since the 2.0 kernels ( http://www.openwall.com/linux/ ).

    Quoting from the README: Non-executable user stack area.

    Most buffer overflow exploits are based on overwriting a function's return address on the stack to point to some arbitrary code, which is also put onto the stack. If the stack area is non-executable, buffer overflow vulnerabilities become harder to exploit.

    Another way to exploit a buffer overflow is to point the return address to a function in libc, usually system(). This patch also changes the default address that shared libraries are mmap()'ed at to make it always contain a zero byte. This makes it impossible to specify any more data (parameters to the function, or more copies of the return address when filling with a pattern), -- in many exploits that have to do with ASCIIZ strings.

    However, note that this patch is by no means a complete solution, it just adds an extra layer of security. Many buffer overflow vulnerabilities will remain exploitable a more complicated way, and some will even remain unaffected by the patch. The reason for using such a patch is to protect against some of the buffer overflow vulnerabilities that are yet unknown.

  17. Someone has to say it... by Anonymous Coward · · Score: 5, Funny

    My name is Igno Molnar
    You kill -9 my ppid
    prepare to die!

  18. Typo in post by localghost · · Score: 4, Informative

    It's against the 2.4.21-rc1 kernel, not 2.4.20-rc1.

  19. Let me explain this to you.. by cculianu · · Score: 5, Informative
    Why would you ever need to recompile an application to take advantage of a kernel patch? I could see the need to recompile libraries or statically compiled applications, but it seems logical to me that a kernel patch should only require you to patch the programs that use the kernel source code: the kernel (maybe some modules too, but I don't think that's the case here).

    While it is true that in general even HUGE changes to the kernel rarely need an application recompile, and are transparent, sometimes this is not the case.

    Consider the following:

    • Some applications interact with the kernel's address space and/or filesystem format/implementation, consider programs like e2fsck, modprobe/insmod, mke2fs, mkreiserfs, et al. These programs need to know about any changes to the kernel's implementation of loadable kernel modules, filesystems, etc.
    • Occasionally the kernel adds functionality. Consider the Xfree86 DRM infrastructure. That was new and required application support.
    • Consider that the kernel once didn't support ELF binaries. A.out was the norm. When the kernel started supporting the ELF format, the compiler tools needed to be changed.

    Actually, even this patch is not entirely transparent. In order to best benefit from the ASCII-armor area, you will notice that in the readme text file they actually gave a patch to binutils to make executables try and use a lower address for their program text. Executables (unlike shared libraries) aren't relocatable and thus need to be re-linked in order to use a different (lower) address...

  20. Will work fine ... by DarkMan · · Score: 4, Informative

    ... assuming that the stack memory is marked as executable in the binary - which will have the net effect of turning off the Exec-shield.

    In other words, ELF format has flags to indicate if the stack should be readable and/or executable. If your doing that sort of thing, make sure that the flag is set, and you'll have no problems [0].

    It your doing those sort of tricks, your probably being very careful with what goes where, and buffer lengths and such. The problems come in when people don't realise that there could be a problem, and don't audit the buffer handling code properly.

    So, don't worry, just use the ELF flags.

    [0] Well, you could set the feature to ignore what the binary says, and implement the security anyway. But that's not a good idea, and very much not default.

  21. Non-executable stacks are part of the solution by larryjoe · · Score: 5, Interesting
    Reading the announcement for Exec Shield, I can see that the author is aware of the work of Solar Designer, who released the first non-execuable stack solution many years ago. However, I don't see any mention of PaX, which extends the the Openwall solution to other memory regions.

    It should also be pointed out that while most buffer overflow exploits do indeed simultaneously overwrite the return address and inject the shellcode onto the stack, a certain class of buffer overflow exploits called return-into-libc attacks do not require executable stacks and are not too difficult to construct. These attacks overwrite the return address with the starting address for one of the libc exec*() functions. At the same time, the parameters for executing /bin/sh are pushed onto the stack. The execution of the corresponding return instruction then causes the exec*() function to execute /bin/sh. See this paper for a more detailed analysis of some buffer overflow solutions.

    I think that it's interesting that in the past few weeks, several solutions for buffer overflows have been announced (e.g., the OpenBSD announcements). Each of these solutions are good solutions, but they heavily borrow from earlier solutions. Unfortunately, the previous work has often not been properly acknowledged. Since the masses are generally not aware of the current state of the art, these supposedly new solutions are given more credit than due. Still, I suppose it's a good thing if general awareness of the buffer overflow problem is raised, even if the pioneers of the technology do not receive their due credit.

    Tim Tsai

  22. Call me stupid, but this makes no sense to me. by Theovon · · Score: 4, Interesting

    Maybe I'm missing something really simple, but here's my understanding:

    1) x86 stack grows from high addresses to lower ones, allowing for a string allocated on the stack to overflow such that it overwrites the return address.

    2) x86 is little-endian which means that the return address (in this case, on the stack) starts with the low byte and stops with the high byte.

    3) In C programs, strings are null-terminated.

    The ASCII shield relies on ASCII not being able to represent certain addresses, namely 0x00000000 to 0x0100ffff.

    Well, here's what I don't get. Assuming all three above, there are five possibilities we can generate for overwriting an address:

    1) All four address bytes are overwritten by ASCII characters generating an address greater than 0x01010101.

    2) The first three bytes are overwritten by ASCII characters, and the last one is overwritten by the null terminator. This results in an address between 0x00010101 and 0x00ffffff. This certainly looks like an address within the 16M "armor"

    3-5) For (3), we only overwrite three of the address bytes, the first two being ASCII, and the last being NUL, resulting in an address something like 0x??00AAAA, where AAAA is greater than 0x0101. This would require that the attacker know what the upper byte of the address is, which is possible. (4) and (5) represent similar situations.

    As far as I can see, this 16M protected region doesn't exist. WHAT AM I MISSING?

    Thank you.

  23. Windows by thalakan · · Score: 5, Informative

    I've been screwing around with mprotect() and friends lately to write a exploit delivery system that can't be read by memory inspection tools on the target machine. While checking to see if similar techniques are possible on Windows, I found that the default addresses for PE/i386 executables' stack and text sections are all below 0x00ffffff. .text begins at 0x00400000, for example, and the stack is located below it.

    So it looks like Microsoft beat Ingo to it :) I was wondering for the longest time why they chose those mappings by default until I saw this article today.

    --
    -- thalakan
  24. Re:Great! [Scott] by Slowping · · Score: 4, Interesting

    Economically speaking, it's true. Though I will admit I have no hard numbers to give you.

    People have a marginal value for driving dangerously, which is balanced by the marginal cost of that action. Where the two meet (marginal cost -vs- marginal value curve), is how people behave (or drive in this case).

    In comes a safety feature. That safety feature reduces the marginal cost of driving dangerously. Thus, the driver is able to "afford" more dangerous driving. ie the equilibrium point where marginal value and marginal cost meets has shifted higher towards dangerous driving.

    Thus, in economics theory, the driver will drive more dangerously with additional safety features.

    The opposite effect, in the original poster's example, of having a spike come out greatly increases the marginal cost. Thus, the "affordable" point shifts far down towards much safer driving.

    Of course... this is fundamental microeconomics, and I'm no expert in economics.

    --
    (\(\
    (^.^)
    (")")
    *beware the cute-bunny virus
  25. Er... to expand a little bit... by mark-t · · Score: 4, Informative
    I realized after I had clicked submit that I had forgotten to point out how it all comes together.

    If and when different pages are used for code and data, since both already use different segment descriptors, the code and data have their own completely isolated address spaces, so trying to invoke a buffer overflow that would cause a "return" to some point in the user-supplied data would actually simply cause a return to the corresponding point in the code page, which is, of course, not actually modified by the application. At best, a buffer overflow could cause a branch to a particular section of the existing program, but would not permit the execution of arbitrary code since in the ideal case, even the kernel code resides in an address space that is invisible to any running application. The most probable upshot of trying to "return" in this fashion would be a segmentation fault, which should result in no more than the application simply terminating with a core dump.

  26. Re:Microsoft by The+Bungi · · Score: 4, Insightful
    Actually, Windows 2000 and up already have this kind of thing built in. Instead of showing all the h^xx0rz here how l337 you are for trying to mouth off about how Microsoft should "innovate", you might want to show up at one of Mark Russinovich's conferences one of these days. Perhaps you'll learn something useful. And you'll figure out just who "innovated" this (and no, it's not Microsoft).

    Hope that helps!

  27. Not slow. by 0x0d0a · · Score: 4, Interesting

    No. The patch lets the exec-shield be toggled off, and adds no more than 2-3 cycles per context switch. On a current x86 box running a vanilla 2.4 kernel, the maximum number of context switches per second is 100. That's a maximum of 300 cycles a second consumed. The oldest machine I've used running Linux was a 486/66 that a friend had. One of these can do at least 66 million cycles a second. On this elderly 486, there will be slowdown of less than a thousandth of a percent. Given that almost all major Linux applications are written in C, the security payoff is probably worth it. I value efficiency a lot, and even so the elimination of the largest security issue in Linux for less than a thousandth of a percent of the CPU time seems like a pretty good trade.

    1. Re:Not slow. by paulbd · · Score: 4, Informative

      sorry, but the number of context switches is not limited by the HZ setting. thats the maximum number that would occur if there were no blocked threads and no interrupts (except the system timer) causing threads to become runnable.

      my system runs audio software that is generally powered by the audio interface interrupt, which occurs at about 1kHz. every single one of those interrupts generally leads to about 4 context switches in the typical case. thats about 4000 context switches per second.

  28. Trampolines by Vlad_the_Inhaler · · Score: 3, Insightful

    My 'day job' is programming on a mainframe. This is how they go about handling this.

    16 'segments' (call them what you will) can be based (pointed to) at any one time, each by one base-register.
    B0 points to code
    B1 points to the stack
    B2-B15 point to data segments.
    If you want to point B0 to another executable segment, you have to execute CALL, GOTO or RTN (return :-). A code segment does not have to be read-only, but normally is. The only other 'trampolining' permitted is by using the EXecute instruction which allows you to execute one instruction in any segment. Executing (for example) a Jump instruction would be of little use to a cracker because the target address would automatically be in the segment referenced by B0.

    Yes, we can have buffer-overflows, but 'all' that happens is that other data is overwritten. This will usually cause the program to abort. It is even possible to organise things so that every routine has it's own discrete data-segments. If a routine then starts accessing data outside of the routine, it gets the equivalent of a Segfault. Obviously parameters/arguments are excepted from this, although there would also be a Segfault if a routine went outside it's caller's data-area.
    Actually, the hardware allows a caller to restrict a subroutine's access to only the n bytes it actually passed over as an argument. The HLL implementations do not enforce this setting in any of the languages I use.

    Segment attributes are from Owner-Read, Owner-Write, Owner-Execute, Other-Read, Other-W and Other-X. Segments also have a Sharing-Level which is: Activity, Program, Application and Exec/System. Exec/System is normally combined with Other-Access: None, Application is normally combined with Read+Execute.

    How much damage is caused each year because the 32-bit I386 architecture cannot supply a reasonable security framework at a reasonable overhead? If the AMD 64-bit processors are capable of fixing this mess, then the GLIBC maintainers could start looking at (optionally?) allowing a safer implementation by separating Code and Data. If this incurs memory-overhead, server farms should be migrating to 64-bit processors anyway by the time such a feature became available. They could also always compile the libraries without that feature.

    --
    Mielipiteet omiani - Opinions personal, facts suspect.