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.'"

69 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 destiney · · Score: 2, Informative


      All I can say is try it. There's a lot more to it than just an ACL. In fact I don't even use the ACL, I use all the _other_ security enhancements it offers.

    3. 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.

    4. 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.

    5. Re:grsec ? by hjhornbeck · · Score: 2, Informative

      The stack/executable bits are there, it's just not that obvious in the feature list. Here's a sample from the news page:

      grsecurity 1.9.9f has been released. Changes include RANDEXEC for alpha, sparc, sparc64, and parisc. It also includes KERNEXEC for i386, which implements non-executable and read-only KERNEL pages. To use the feature, you must build a monolithic kernel (that is, CONFIG_MODULES = n). KERNEXEC also makes the IDT, GDT, and syscall table read-only. In addition, stack/mmap randomization has been added for PowerPC, multiple administrators are allowed in the ACL system, and a fix for the ptrace patch discussed on LKML has been included.
      HJ Hornbeck
  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 Anonymous Coward · · Score: 2, Informative

      The problem exists in all x86-32 processors, and always has. AMD's Opteron x86-64 does have the ability to mark such code as non-executable while readable, but only in x86-64 mode. 32-bit applications will still suffer.

      While I applaud the effort made for this product, I still believe that the only way to completely shield ourselves from such attacks is to enforce it in hardware.

    3. 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).

    4. 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.

    5. 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
    2. Re:Possible Problem by dvdeug · · Score: 2, Insightful

      you're employing a somewhat dangerous hack here.

      Dynamically writing code is not a dangerous hack. The more correct way of solving this problem is for people not to use unchecked arrays that can overflow - C, C++ and a few other really low level languages about the only languages that have unchecked arrays as a standard data type. Most of these problems don't show up in programs written in other languages.

    3. Re:Possible Problem by InodoroPereyra · · Score: 2, Insightful
      Sunlighter says:

      I've written a few pieces of code which take advantage of the executability of the stack and the heap. [...] With this patch, that won't work...

      Fear not my friend :-) . Please read the announcement from Ingo:

      Applications that need to rely on gcc trampolines will have to use the per-binary ELF flag to make the stack executable again.

      [...]

      There is a new boot-time kernel command line option called exec-shield=,
      which has 4 values. Each value represents a different level of security:

      exec-shield=0 - always-disabled
      exec-shield=1 - default disabled, except binaries that enable it
      exec-shield=2 - default enabled, except binaries that disable it
      exec-shield=3 - always-enabled

      the current patch defaults to 'exec-shield=2'

      You will just need to flag your binaries ...

    4. Re:Possible Problem by sgifford · · Score: 2, Interesting

      Instead of allocating from the heap with malloc, just create an anonymous memory map using mmap, setting PROT_EXEC to allow execution. Something like:

      m = mmap(NULL,
      1000000,
      PROT_READ|PROT_WRITE|PROT_EXEC,
      MAP_PRIVATE|MAP_ANON,
      -1,
      0);

      will allocate 1000000 bytes of memory which can contain executable code on Linux and BSD. On some other Unices you have to use /dev/zero, but the technique is pretty much the same.

  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. Re:Yeah... by DataPath · · Score: 2, Interesting

    Its surprising what you can find out there if you look. Just last month, I was pointed to an installer+binary for running Serious Sam: The First Encounter under Linux. Plays like a dream.

    --
    Inconceivable!
  18. Executable stack protection, very nice, but... by CoolVibe · · Score: 2, Insightful
    what about local attacks using the global offset table or return-into-libc function pointer overwriting attacks? With those you can put executable code somewhere else and use another trampoline instead of a return address.

    Sure, this will nullify most remotely exploitable vulnerabilities, but what about local ones that are vulnerable in the manners I just described?

    1. Re:Executable stack protection, very nice, but... by rabidcow · · Score: 2, Insightful

      Well apparently it deals with that as well, by moving system libraries to an "ASCII-armor" area from 0x00000000-0x00ffffff. This is supposed to be safe since ASCIIZ strings can't contain 0s. ...but I think there's a flaw with that, ASCIIz strings will always contain *one* 0, the terminating one. Since x86 stores addresses as little endian, the high byte in the address will be the last byte in memory. If you arrange for the terminating NULL to be at the last byte of the return address, you can jump to that "ASCII armor" area, since the string will overwrite the lower bytes.

      I dunno if I'm understanding their intention correctly tho.

  19. Re:Great! [Scott] by corporatemutantninja · · Score: 2, Funny

    I stopped wearing a seatbelt as soon as I got a car with an airbag. And now that I have a car with EIGHT (count 'em) airbags and ABS brakes I drive like Mario Andretti. Only without all the cologne.

    --
    Actually, I was trying to be Insightful, not Funny.
  20. Someone has to say it... by Anonymous Coward · · Score: 5, Funny

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

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

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

  22. 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...

  23. 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.

  24. Re:Yeah... by oaf357 · · Score: 2, Funny

    I hate to boast but I have a "Moving to Linux" project in the works to create the functionality of Windows in Linux. It doesn't mean that Linux will be as easy as Windows but I'm just trying to "create functionality" and document it.

  25. as a non-programing network admin by Indy1 · · Score: 2, Interesting

    is this a patch i should have installed on my various linux servers? I understand any new code should be tested on a development server before being moved to production, but assuming this patch doesnt cause any problems, is it something thats worth the time and effort to help reduce buffer overflows ?

    --
    Lawyers, MBA's, RIAA? A jedi fears not these things!
  26. Re:Transparent? Why Not? by l2718 · · Score: 2, Interesting

    There are two reasons why this kind of patch would require recompilation.

    One (implied in the linux-kernel post) is that it would be nice to fix the ELF format and remove the assumption that the stack can contains executable code. Also, changing the way the program is laid out in memory affects security (see the "ASCII Armour" bit). A priori you might think that recompilation (producing a new binary) would be required for that.

    The second is self-modifying code. Some application (the post mentions XFree86) want to have parts of the binary decided upon at runtime (mostly for optimization purposes). For that to work you need to know which parts of the memory are accessible both for writing (as data) and execution (as code). If the rules for that change (which is the point of patches like this one), you'll have to do even more than recompile -- such software will have to be fixed!

    Getting X to work without recompilation (in fact, without patching) was a real issue -- read the explanation of the "X-workaround" hack.

    hope this helps,
    Lior

  27. 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

  28. Re:The name is taken ... by shaitand · · Score: 2, Informative

    This is exec shield not executive shield, and the exec part most likely (I'm too lazy to look) implies execution rather than executive. Exec shield is a straight forward enough name I'm sure someone has used it for something somewhere before, but it's not a rip of executive shield by norton for christ sake.

  29. Re:Yeah... by dWhisper · · Score: 2, Interesting

    I have looked at WineX, the problem with it is that it takes individual upgrades for specific games. It's just me, but I'd rather see native support for the individual titles than getting emulated support for the titles, which adds an unnecesary proccessing layer to the system. I know I'm getting flamed for up above, but I support Linux.

    I want Linux to succeed more than anything, because I love some of the things that it does. KDE and Gnome both blow away Windows from the level of usefullness and power, and the control and security of Linux are awesome. But the programs I use the most, Bryce 5, Photoshop, and MS Office, are Windows only, and the competing applications are just not up to where they are.

    Blender has a learning curve steeper than everest, and I'd have to program my own lab plugins to do the work I do now. Gimp is a good program, but 6 years of work with Photoshop have made me dependant. And Office is still the best of Microsofts programming.

    I may do the switch soon though, because I'm taking up PHP coding for web application deployment and programming. So we'll see.

  30. 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.

    1. Re:Call me stupid, but this makes no sense to me. by tijsvd · · Score: 2, Informative
      The exec*() and system() calls need parameters, which need to follow the return address. Since the return address is necessarily the last part of the attack, it is not possible to write these parameters.

      So unless spawn_shell(void) exists, the armoring is quite effective.

  31. 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
  32. 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
  33. 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.

  34. 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!

  35. Re:Great! [Scott] by fireman+sam · · Score: 2, Informative

    Excatly true, and in some parts of Australia, there are laws prohibiting the use of full role cages and racing harnesses because they make a vehicle safer at high speed, thus enticing the driver to drive at a higher speed.

    --
    it is only after a long journey that you know the strength of the horse.
  36. Re:Great! by kinema · · Score: 2, Interesting
    In addition, we can now write sloppy code and just tell people to install this patch first!

    Protected/virtual address spaces help avoid a plethra of security/stability issues. Does this mean in your opinion that such virtual addressing encourages sloppy programming?

    --adam

  37. Not exactly surprising... by pr0ntab · · Score: 2, Interesting

    If you use linux with BIG_MEM (3GB/1GB split) enabled in the kernel, your .text segment is allocated starting at 0x00010000. I forget why but there was some simplicity to using the 1GB/1GB split otherwise on linux (.text starting at 0x80000000, kernel mem at 0xc0000000). Windows uses a default 2GB/2GB split, so it makes sense it would start at 0x0. I don't think they were thinking about ASCII armor when they made that decision in the NT 3.x days.

    --
    Fuck Beta. Fuck Dice
  38. Hmm.. you might be right! Someone tell INGO! by cculianu · · Score: 2, Interesting

    You know.. you may be right.. consider this little program. It is a series of characters in an array.. the characters are 0x01,0x01,0x01,0x00 (as was your case (2)). When you print this out as an int, you get 65793. This is certainly less than 16 million.

    #include <stdio.h>
    #include <string.h>

    int main(void)
    {
    char arr[sizeof(int)] = { 0x01, 0x01, 0x01, 0x00 };

    printf("%d\n", *((int *)arr));
    return 0;
    }

    So I don't get what Ingo means when he says that this region is somehow ASCII-shielded... because you are right.. on the x86 the high order byte is last, not first (as was the assumption in Ingo Molnar's little readme).

    What GIVES??! Anyone? What am *I* missing?

  39. Re:Yeah... by hetta · · Score: 2, Insightful

    You're forgetting XBill.
    XBill is actually very pro-M$.
    Because no matter what you do, sooner or later you end up with winbows on every machine on the screen.

    It should be changed so that you can actually win the game. No more Bills to swat at level 10, or at 1000 points, or whatever.

  40. 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.

  41. Re:Great! [Scott] by Narcissus · · Score: 2, Insightful

    Except in the US where they are designed to work without seatbelts. Well, kind of. The propulsion used is much stronger in an attempt to help those that don't wear their seatbelts (one of those "we can't force them to wear their seatbelts: they're Americans, they're free, but let's tack on some copyright changes" things).

    The problem is, then, that air bags in the US actually become more dangerous when seatbelts are used, but there is no evidence to suggest that they help those that don't wear them any more...

  42. 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.
  43. ASCII-Armor area by 42forty-two42 · · Score: 2, Interesting

    What happens if an executable maps in more than 16mb of shared libraries? Will one of these libraries get mapped to NULL? Or will it forgoe security for actually working?

  44. Is it possible this is a negative? by MarkSwanson · · Score: 2, Insightful

    It would seem to me that it's clear this patch is much more than just a non-executable stack patch. I think an important point is that while it isn't perfect, if this becomes a standard part of Linux then we can stand on the shoulders of this and tackle the next set of problems. Eventually we may get there.
    If we wait until a perfect patch presents itself we will never get there. F.E. using this patch will bring to light all applications that require gcc trampolines. With time, perhaps all of the trampoline code will be replaced - several articles have been written on how to live without trampolines, perhaps this would be the push needed to change.

    --
    Schedule your world with ScheduleWorld.com http://www.ScheduleWorld.com/ (Java Web Startable)
  45. mmap placement without kernel patch by jreiser · · Score: 2, Informative
    Application builders can get some of the protection even on systems that do not use the kernel patch. tub lets you control mmap(0,...) so that you can put ld-linux.so.2, libc.so.6, and other shared libraries into the ASCII Armor area.

    This would be a good time for TASK_UNMAPPED_BASE to become an inherited parameter controlled by setrlimit/getrlimit. It would also be a good time to get a binary structure interface to /proc/self/maps, much like VirtualQuery in Win32.

  46. probably not completely transparent by g4dget · · Score: 2, Insightful
    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.

    Programs compiled for the x86 architecture may well assume that they don't have to set the executable bit on pages because the hardware doesn't support it anyway. Whether such programs are "correct" or not, this patch may break applications.

    1. Re:probably not completely transparent by jjb · · Score: 2, Insightful

      We'll see if it breaks applications. Even if it doesn't, the fear of it breaking apps will probably stop many people from activating it if it's optional.

      Tons of Solaris sysadmins still don't set the non-executable stack, even though it doesn't seem to break any major applications outside of certain debugger functionality... They're just too afraid that they'll break an app and lose their jobs. And that's rough, because nonexecutable stack defeats a fair number of buffer overflows on that platform...