Heap Protection Mechanism
An anonymous reader writes "There's an article by Jason Miller on innovation in Unix that talks about OpenBSD's new heap protection mechanism as a major boon for security. Sounds like OpenBSD is going to be the first to support this new security method."
now unix will be more secure than all... well, again.
other OS have had heap protection mechanisms, even one from Microsoft.
Let's hope it's not as broken as Microsoft's attempt in SP2.
But why did it take so long to implement?
Kudos to the OpenBSD folks for being at the cutting edge, in terms of implementations of these security features. Where they lead, surely others will follow and we'll be seeing this feature become commonplace. As their focus is security, its understandable that they lead more incentives in these areas than more mainstream Linux distributions.
Business Voyeur
When the application is finished with the memory, it sends a FAX to the local electronics recycling facility who sends out a tech to remove the DIMMs and melt them down into whatever.
Using this method of heap memory allocation (I call it "ACAlloc" for "Anonymous Coward Alloc" has been 100% effective and I have NEVER had a heap overflow exploit in any of my code.
Yes, it's slow, but I am secure.
Ok, we start out with 'protection', then we move to 'a heap' of protection, most assuredly to be followed by 'a whole heap' of protection. I can only see this spiral continuing until Bill Gates himself gets up on stage at CES in an Elvis suit promising 'a hunka- hunka- burnin protection'. *SHUDDER* Time to take a cold shower.
-Charlie
"And if we have to sacrifice a little usability on the way there, then so be it."
Nice dream , meanwhile in the real world both users and most coders
(if they dare to admit it) will NOT sacrfice usability or ease of
coding for security measures that (in their minds) are nothing to
do with their application. Unless that is they're forced to either
by company policy or restrictions in the OS. If there are restrictions
in the OS then IT tech leads might start to ask "well, I can do this in
OS A , why won't OS B let me do it? I'll use OS A". Not an ideal situation
but when all that matters is delivery times and saving $$$ then its what
will happen. Security , as ever , will come a poor second.
OpenBSD's "My Heap":
Lookin' at my heap, heap
You can look but you can't touch it.
If you touch it, I'ma start some drama.
You don't want no drama.
[...]
My heap, my heap, my heap, my heap.
Ok, the article is light on technical details, but it seems that they are using guard pages. Guard pages aren't exactly shiny new. Efence has been using them since a long long time.
Could this technology be implemented in the Microsoft Windows systems to be more secure than Linux?
igor
As BSD is my other favorite OS (I tend to use XP for desktops and FreeBSD for servers), I'm glad to know that they've finally caught up with Microsoft in this important area.
Best Buy can have you arrested
Ok, I've posted hastily, thus creating a bit of an half-assed post. They use more techniques (random address allocation, immediate free-to-kernel), still not revolutionary, but indeed worth mentioning. My bad.
Is it really true that the standard GNU/Linux heap implementation holds onto pages like this when it becomes fragmented? That sounds really primitive to me.
The upcoming GCC 4.1 release will include a stack protector. Basically it's a reimplementation of the old propolice patch.
Hopefully mainstream distros that have been wary of propolice will start using this new feature. And perhaps glibc malloc will borrow a few tricks from this new openbsd malloc too.
"innovation in Unix that talks about OpenBSD's new heap protection mechanism as a major boon for security.", surely you mean "innovation in *BSD " ?
When taking a look at some of the features of my favorite Unix environment you'll notice that among the security features its also possible to shield processes from each other and control the amount of memory they use (near the bottom, the so called "buffer overflow attack"). If you wish to study this in more detail you can check out the documentation on resource control which explains you the issue in more detail. For the impatient; controlling physical memory and such is explained in chapter 10
Sorry but I can't conclude that this is something new in the world of Unix.
I hope i dont ever find out how to get memory usage on openbsd, sure as hell ain't "free"...
DEP from Microsoft is only enabled by default on some system binaries. Here is how to enable it for everything: http://www.microsoft.com/technet/security/prodtech /windowsxp/depcnfxp.mspx
My CPU doesn't support DEP in hardware, so I imagine the software-based method of doing this will create quite a speed hit. Anybody have any experience with turning on DEP for all programs?
OSes can put Intron between Exon (useful DNA -- useful stuff on the heap) to
detect badly behaving apps!
In other words, so-called "Junk DNA" may actually have a use...
HEAP PROTECTION
What they restrict here, is extremely shitty programming. What's the point of allowing accessing memory areas out-of-bounds? Fewer crashes, because the system does not notice them? This is a very bad idea. If you don't know how to handle arrays and you don't know any other means to restrict yourself from doing something stupid, OpenBSD shows the best way to do it (as last instance).
From the kerneltrap.org post:
He explains that for over a decade efforts have been made to find and fix buffer overflows, and more recently bugs have been found in which software is reading before the start of a buffer, or beyond the end of the buffer.
The solution that the kerneltrap.org refers to against buffer overflows is to:
My opinion is that #1 will slow software down, although it will make it indeed more secure. #2 will make it more difficult to exploit buffer overflows, since the space between two allocated heap blocks will be random (and thus the attacker may not know where to overwrite data).
Unless I haven't understood well, these solutions will not offer any real solution to the buffer overflow problem. For example, stack-based exploits can still be used for attacks. The solution shown does not mention usage of the NX bit (which is i86 specific). It is a purely software solution that can be applied to all BSD-supported architectures.
Since all the problems relating to buffers (overflow and underflow) that have costed billions of dollars to the IT industly is the result of using C, doesn't anyone think that it is time to stop using C? there are C-compatible languages that allow bit manipulation but don't allow buffer overflows; e.g. Cyclone.
Actually, for OpenBSD, it will work. And has.
The reason is very simple: There will always be some applications where the security of the system is a paramount point. Where it does have to do with the application. OpenBSD caters directly to those people, and those applications.
Now, you are right, this means OpenBSD is likely to never get as large a following as Linux or even FreeBSD, but they honestly don't care. They are making a system that fits their goals, and security is among the top goals.
This actually allows security to spread: Once these changes are on a 'major' system, applications start to be ported to work with them, which means the changes can be ported to other systems.
OpenBSD is a security testing ground. If it's features get in your way, you use a different system. This won't be the first time that advice will have been applicable.
'Sensible' is a curse word.
So it seems, we are birds of a feather.
Wanted: Clever sig, top $ paid, all offers considered.
I understand the sentiment, but ... consider the influence of laws like Sarbanes-Oxley. When CxOs go to jail because of their developers' bad code ... security might become more important.
Languages like Lisp, Haskell, Scheme and ML allow you to avoid buffer and heap overflows (assuming the language implementation is correct).
It is therefore, in my opinion, less optimal (from a security perspective) to use something like "C" for a complicated app like sendmail, web server or secure shell daemon (sshd) than it is to use a language like "C".
http://www.thebricktestament.com/the_law/when_to_
I'm surprised that modern heaps still put writable data segments adjacent to executable code segments. Self-modifying code is rare enough that all code should be in read-only (except by privileged processes, like the kernel which sets it up and tears it down) segments, except when a process has privilege to write to its own code segment. Then its code segment should be a data segment, with other security features applied (that are too expensive to apply to every code segment). Generally then, segments are either writeable or executable. Data segments could still get overwritten, which could put unsafe values in unexpected variables (like "write to that file" instead of this file). But at least those insecure operations are limited to the operations programmed into the code, not arbitrary new code inserted into executables by buffer overflows.
After decades of these problems, and known techniques already applied in Computer Science, its surprising that we're only now seeing these techniques deployed in popular OS'es like OpenBSD. Hopefully the open nature of OpenBSD and other OSS OS'es will see them tested for winning strategies quickly, and widely adopted.
--
make install -not war
I thought that pax was a tar lookalike that nobody uses.
This presentation (by Theo de Raadt) gives a good overview of the security features in OpenBSD (beyond what's already outlined on the OpenBSD security page). It covers W^X, random stack displacements, random canaries to detect stack smashing, random library base addresses, random addresses for mmap and malloc operations, guard pages, privilege revocation, and privilege separation. One thing it doesn't cover is systrace.
Please correct me if I got my facts wrong.
I call my heap protection mechanism "bumpers" : p
I'll turn into a supernova and burn up everything. Well I'll turn into a black little hole and you'll turn into string.
Um. What Theo means is that incorrectly written programs will fail to work. So, Linux will let you access a free()'d buffer, but OpenBSD will not. Since more programs get tested on Linux than on OpenBSD, the bug is never manifested and no one cares.
So, let's say your favorite software package is one of those programs. You won't be able to use it until someone comes up with a patch that fixes the allocation bugs.
Correctly written programs are unaffected. If you never access what hasn't been allocated, and don't touch what you've told the libc you want freed, you are fine. Can't say that about Linux.
But Linus doesn't like specs so it got dropped !
In case you wanted to read the Kerneltrap article mentioned but not linked http://kerneltrap.org/node/5584
Gates may pull off a skinny Elvis, but for good ole fat Elvis... "Monkeyboy" Balmer got that all sewn up!
Posted Anonymous to preserve lame hope of a career at Microsoft. *wink*
Let's hope Sony will bring it to the PSP, so it'll be safe from those dangerous .tif images attacks....
What you are talking about is the no-execute page protection. Unix has had this for most of it's existence. Until the last few years it didn't work very well on Intel systems due to hardware limitations (if you can read a page it is executable). The workaround involves using segmentation but it was very ugly. Recent processor updates have included the ability to set a no-execute bit which works even if the page is readable. Both OpenBSD and Windows (and Linux) support this already.
The _heap_ protection is additional. There are various attacks based on malloc()ed memory overflows which are thrwarted by use of non-readable memory barriers and better protection of the internal malloc datastructures. The no-execute stuff isn't really related, though I believe OpenBSD already disallows execution of malloc()ed memory by default.
I wonder of all these creative heap protection mechanisms (GCC 4.1, NX, etc) will largely remove the need for managed code (ie Java and C#). If you can write in C++ and not worry about double-free()s that pretty neat. Maybe even a "disruptive technology".
For real security, don't use C. I've advocated this many times before, and have recently written a new essay about how better programming languages can lead to better software. Although this essay isn't entirely focused on security, it does demonstrate that some of the most common security bugs simply cannot occur using, in this case, Common Lisp instead of C.
Please correct me if I got my facts wrong.
Yep. After all, the goal of the OpenBSD project is not simply to be the most secure operating system ever. The goal is to provide the best security, along with a number of other goals, such as running Unix software, achieving good performance, and providing a good (according tho the stated goals even "the best") development platform.
Please correct me if I got my facts wrong.
ALL buffer and heap overflows in individual programs are the fault of bad programming, not bad programming languages. If a programmer is not competent enough to test their code, and then blame the programming language when there is a problem, should not be coding. It is simply irresponsible.
You forgot to add Java to your list of programming languages which goes out of its way to assist in preventing and avoiding both buffer and heap overflows/errors (i.e. bounds checking and similiar technology).
It may be a legitimate invention - it is cited as prior art in an ATT patent. This is also the first known example of a prior Open Source publication causing a patent filer to cite. ATT also removed a claim from the patent that my work invalidated. Just search for "Perens" in the U.S. patent database to find the patent.
We don't run it on production programs because of its overhead. To do this sort of protection exhaustively, it requires minimum two pages of the address space per allocation: one dead page between allocations and one page allocated as actual memory. This is a high overhead of page table entries, translation lookaside buffers, and completely destroys locality-of-reference in your application. Thus, expect slower programs and more disk-rattling as applications page heavily. If you are to allocate and release memory through mmap, you get a high system call overhead too, and probably a TLB flush with every allocation and free.
Yes, it makes it more difficult to inject a virus. Removing page-execute permission does most of that at a much lower cost - it will prevent injection of executable code but not interpreter scripts.
I don't think the BSD allocator will reveal more software bugs unless the programmers have not tested with Electric Fence.
Bruce
Bruce Perens.
For real security, don't use C.
I am rewriting Linux in Visual Basic 6.0.
I am going to call the distro VBLinux.
Who is "not giving back?"
Feel free to download all of their source code before complaining.
If you don't like it, don't use it, even though I'm sure you too benefited from some security fixes that originated with OpenBSD.
fast as fast can be. you'll never catch me.
I'd be interested to know what the performance impact of this is - exactly what counts as "too much of a slowdown".
Application heap allocation has "traditionally" been fairly inexpensive unless the heap has to be grown (update a couple of free block pointers/sizes) and the cost of growing the heap (which requires extending the virtual address space and therefore fiddling with page tables which would on a typical CPU require a mode change) is mitigated by allocating more virtual address space than is immediately needed.
If free space is always unmapped then each block allocation will require an alteration to the page tables, as will each unallocation. Not to mention that could cause the page-translation hardware to operate sub-optimally since the range of addresses comprising the working set will constantly change.
If most allocations are significantly less than a page size, then the performance impact may be minimal since whole pages will rarely become free, but if allocations typically exceed a page size, that would no longer be true. If the result is that some applications simply implement their own heap management to avoid the overhead, then you've simply increased the number of places that bugs can occur.
I like Lisp and ML, really. But the issue of automatic memory management is (or should be) orthogonal to the choice of language. There could be better languages than C with manual memory management. In fact, IMHO the world could use just such a language, as "managed" languages aren't appropriate for everything.
Given good libraries, a mail daemon or web server isn't a problem in C. But while I used to like C, I'd prefer to use Java, or better - Lisp, today, because it's tedious to write all that support code in C that the others have built-in. A C with better syntax and abstraction facilities, and more extensive and non-braindead standard libraries could do a great job for me.
Although you can blame the programmer for writing a faulty application, I don't think that is relevant.
You are a taxi driver. Your job is to deliver people from point A to point B, safely and quickly.
You can choose from two cars.
Car A is such that if you make an error when driving, it will do something bad -- perhaps even blow up, killing the passengers. Furthermore, a driver can accidentally drive the car into an obstacle, ruining everything.
Car B is the same as the first, except there's nothing the driver can do to make the car blow up. If the driver purposefully tries to drive the car into a wall, it stops before it hits the wall.
It seems like you want to pick car A, and say that anyone who drives car A badly, is at fault.
I'm saying just pick car B, there will be far fewer accidents, and there is no reason to point your finger at the "bad driver".
If a driver is given the choice between the two, and picks car A, and makes a mistake, it would seem that he has been grossly negligent. He could have chosen the safe option, but he chose the unsafe one, and the passengers got killed. So I think we agree the programmer has been terribly irresponsible.
http://www.thebricktestament.com/the_law/when_to_
All languages allow you to avoid buffer and heap overflows if the language implementation is correct. Buffer and heap overflows are programming errors, not problems with a language. Some languages just have better facilities to force well-behaved code. You can add Java and C# to your list there by the way.
I don't understand how you'll do a language like ML or lisp without automatic storage management.
The problem has to do with returning closures with bound variables -- the nice thing about having a GC is that they will get freed, eventually.
If you do manual memory management, will you manage this yourself (for closures)? Or will you ban closures? If you are banning closures, you've lost one of the key benefits of using Lisp or ML --- you just got rid of lambda (in its most general form), and you'll just have supercombinators (functions without bound variables), like in "C". Or will you rely on some static analysis to find things that can be freed automatically? These are all pretty tough -- just using GC is probably the way to go.
http://www.thebricktestament.com/the_law/when_to_
Languages like Lisp, Haskell, Scheme and ML allow you to avoid buffer and heap overflows (assuming the language implementation is correct).
It is therefore, in my opinion, less optimal (from a security perspective) to use something like "C" for a complicated app like sendmail, web server or secure shell daemon (sshd) than it is to use a language like "C".
The problem is for one reason (or randomness) or another, no mainstream daemons or operating systems or client applications are written in Lisp, Haskell, Scheme, or ML. Plenty are written in C, C++, and Objective C, and I have yet to of heard of a rewrite into another language in order to alleviate the security risks because of the current language.
I cannot explain why the other languages are not used. I have not used any of them personally, but somebody should be able to shed light on the subject.
I agree, and I'd go one step further to say that we're starting to get into a situation where programmers are learning and using languages (such as Java) that don't allow this particular kind of sloppy coding. The problem is that many of these programmers aren't even aware of the concept of a buffer overflow, let alone how to actively detect or prevent it.
I happen to be a fan of Java, but I get very concerned when I hear folks suggest that we can solve all our security woes by simply using these "safe" programming languages. We can't totally ignore the fact that coders need to understand these issues, whether the programming language (or operating system) protects them or not. It's rather like suggesting that drivers don't need to learn to drive safely any more, since we all have seat belts and air bags.
Didn't Bruce Perens use a similar method of page protection to implement Electric Fence?
http://perens.com/FreeSoftware/ElectricFence/
If this is the case, it's great that such a feature should go into an OS by default. I personally love anything that gives me confidence in the implementation of any applications I write, especially as this type of technique makes debugging much easier.
-- Mike
I like your analogy. I'd change it so that the two cars are:
:)
- Car A is such that if the taxi driver makes an error, the car explodes, killing everyone in it instantly.
- Car "C" is such that the taxi driver is a serial killer who picks up passengers, hunts down, tortures, and kills their immediate families, and then slowly, painfully kills the passengers.
Neither is particularly desirable, but I'd still take car A.
There are 0x40000000 types of people: those who understand 32-bit IEEE 754 floating point, and those who don't.
Languages like Lisp, Haskell, Scheme and ML allow you to avoid buffer and heap overflows (assuming the language implementation is correct).
C allows you to avoid buffer and heap overflows. C++ does too, it provides even more tools.
Would a programmer incapable of writing code without buffer overflows be capable of writing complex client-server apps in those languages?
Now what I'd like to see is thread-protected heaps. Where malloc()d memory is accessible only to the thread that created it. Yes, some mechanism would have to be created where a thread could delegate access to it's heap, I suppose. There are times where I'd want to start a series of threads from a message dispatcher, and allow the children to only access the parent's message queue, and not allow the parent access to the child's message queue (Yes, I understand there are better mechanisms for this like pipes, but it's a simple example).
Some platforms just don't support the fork() mechanism, and I'd like one more tool to help make threaded system design a little more robust.
Legacy code. Conservatism. Efficiency (among implementations of equivalent algorithms, the one coded in lower-level language will 99% jf the time be faster/lighter on memory).
All well and good. But suppose that car B, with all it's other advantages, is limited to a top speed of 45mph and can't go onto the freeways while car A has no problem with freeways. Most of your customers will want to go places where the fastest way there involves taking a freeway. As a taxi driver, which do you choose? For me it'd be easy: car B isn't an option because it doesn't meet minimum requirements, so car A's the only choice I have.
I ran into this situation when having to choose between Java and C++ for a program. The absolute requirement was consistent high performance (on the order of 500 transactions/second). It would've been easier to write this program in Java, frankly, and it'd've been theoretically able to meet the performance criteria. But. Yes, there's always a but. In this case it was the garbage collection. At random unpredictable and uncontrollable intervals the whole program would stop dead while the JVM did garbage collection. We tried multiple JVMs, we tried every option we could think of, we called in the vendors and had their techs try their hand at the problem. No joy. In C++ we had to manage memory ourselves and take care to avoid leaks, but at least we could at the same time slice deallocation up so it was a steady small overhead we could manage and account for in the performance budget.
``Not only do they tend to lack explicitly separate data and code''
Where do you get that idea from? True, you can store functions in variables and pass them as arguments, but that doesn't mean that you don't know what's code and what's data anymore. The function body is code, the pointer to that body is data.
``but they more-or-less depend on the ability to construct functions dynamically, as data, and then invoke them as code.''
They don't really depend on that. It's a possibility, but most often functions constructed at run time will use code that is already known at compile time (and thus would already have been generated). In the cases where you really construct new code at run-time, you'll have to do some trickery; but you still don't need to have any part of memory be both writable (data) and executably (code) at the same time.
Also, arguably, Scheme doesn't need this kind of protection, because the sort of bugs that this heap protection scheme protects against simply aren't possible in Scheme programs. C and C++ are actually among the few languages in popular use that suffer from these vulnerabilities. See also my essay about the subject. Although the examples it gives use C and Common Lisp, they are almost equally applicable if you substitute C++ and Scheme.
Please correct me if I got my facts wrong.
Yeah, just like nobody used any of those other security projects from OpenBSD, like OpenSSH...jeez, what do we expect, people to start taking advantage of security measures? (oh yeah, read all the AC replies, they're far more eloquent than I.)
When you look at the state of the world, how can you not become a radical, liberal anarchist?
http://pax.grsecurity.net/
Protection Against eXecution.
and integrate it with something decent like http://www.rsbac.org/
OpenBSD focuses on security, and this latest addition is not just a security measure slapped on to just another Unix clone. The developers encourage an environment of secure design as the top priority. Many other operating systems choose to focus on performance or a great desktop experience.
It almost seems like a tit for tat as OpenBSD leads the OSS community into adopting bloatware in the name of "security" in response to noise from Redmond about how they justify bloat in the name of "security" (much like the White House justifies... er...). Meanwhile, the astute /.er will recognize the spector of Andy Grove is steadily pushing all we rates closer to the edge of buying more and faster processors. Surely, there must be at least ONE Intel employee working with OpenBSD to solve this 'security issue'. Kurzweil was wrong!
nuff said
Memory protection between threads?
Good idea, let's call it "processes"
I have a Hardened Gentoo Linux system (http://www.gentoo.org/proj/en/hardened/primer.xml ) that already incorporates similar technologies. It uses the PaX kernel patch for randomly arranging the memory layout of applications. It also compiles in stack smashing protection into every program.
Here's something from guys who do lots of transactions in a safe language -- perhaps you've heard of Orbitz? If you'll notice, they manage memory so that they avoid GCs whenever possible.
My original point was more about things like sshd -- there's just not a good reason for that to be written in an unsafe language. It defeats the whole purpose of your "secure" shell if a buffer/heap overflow allows someone to compromise your whole box.
Normally the code that needs optimizing is a small part -- you make that go fast and you can achieve your goals.
http://www.thebricktestament.com/the_law/when_to_
And updated it in Service Pack 2.
There was a big story on slashdot on how it had been worked around by programs that wanted to still be malicious.
MS' support works by just checksumming the structures between blocks. If the checksum doesn't match, someone has overwritten the structure. This can be worked around if you wish to be nasty.
Sounds like BSD is putting unwriteable pages between blocks in the heap. This is impractical and/or stupid. It means you have to waste the remainder of a page (real memory) and the next page (only address space) for each block you wish to protect. In addition, unless the block is a near multiple of your page size (4K) you have to decide whether to butt it up against a block behind it (to detect overruns) or in front of it (to detect underruns).
You can beat both of these limitations by making portions of pages unwriteable instead of the whole thing. This requires making the page unwriteable in hardware and then on every write to that page, bounds checking the pointer and either doing the write at privileged level (where it will succeed) or failing, depending on the result you want. This is terribly slow, it will destroy throughput.
All in all, I think I like MS' solution the best, in terms of practicality.
Either way, it must come as a huge shock to hardcore slashdotters to hear MS beat them to a security feature. I'm sure they'll manage to block this out of their minds and return to the party line in short order.
http://lkml.org/lkml/2005/8/20/95
Key word search "Heap-o-Protect"...
The NSA: The only part of the US government that actually listens.
They're willing to break things in order to improve security. That's commendable, and I can't see myself using anything else for the firewall, but I simply cannot do without some software and some of it is binary-only. Does it break for me? I don't know, but from what Theo has said breakage isn't uncommon for large applications. I haven't checked because Java is poorly supported for unrelated reasons, and this rules out OpenBSD without me having to validate all my other software.
Also, the OpenBSD crowd is very quick to say that performance should be good enough for most purposes, but that's a copout. They have no idea what any particular person needs to do. The double-halt bug is a good example of how this is an issue. If they don't pay enough attention to performance to catch such a major issue quickly, they aren't going to be catching up to Linux or FreeBSD anytime soon.
I rarely criticize things I don't care about.
Electric Fence for Linux and Xcode's Gaurd Malloc library do this. You could do it in production if you really wanted to but *why*? There is a heavy performance hit and an attacker can avoid (albiet not easily) the gaurd pages anyway.
Eventually, thanks to processor virtualization each application will run in a dedicated VM with an OS instance dedicated to it. Not sure if this will cause a slowdown and memory hogging.. but I think we're moving towards that given the reduction in RAM prices and the quest for improved security and reliability. Like it or not.
I'm not talking of something like Lisp, just C with more syntax for abstraction mechanisms, like real closures, maybe a type system that wouldn't get in the way with tuples and higher-order functions (or no type system).
Basically closures can be managed like objects, and the non-GCed C dialects use objects/structs routinely.
I've never had a big problem with freeing memory in C. Of course making closures more convenient will mean that there's more memory to manage. But something like unwind-protect in Lisp, or Region-Based memory management could make this really manageable, IMHO.
Of course for many problems, a language with GC like Lisp is more appropriate. You have to choose when to use it, and when to use the lower-level language. For stuff like file systems or databases or OS kernels, I think a more powerful language than C would result in more sanity, less duplicated features (that look different, because the abstraction level is too low) and more stability and performance.
whats the performance hit of immediately free'ing everything instead of sticking the free'd memory into bins? Of having to get the memory from the machine everytime with no caching bins/etc? How many wasted pages of memory are there for so called guard pages?
It's not so much that they are cutting edge, its more that other OS's will sacrifice some security for speed and tell the programmers 'program correctly!'.
or at least thats my take.
You gotta remember, the project doesn't do it for outsiders, what they do is for themselves. They want security and are willing to pay performance and ease of use to get it, it's like a mantra for them, never take the path of least resistance.
If this looses like 5 or 10 percent of it's performance on my machines I won't mind, it's another layer of protection and I like having it and am fine with the cost, faster hardware isn't that expensive. If something I run crashes, I will report to the people that wrote it, telling them that I found a problem that was found by OpenBSD's malloc, maybe they'll even devote an old test box to checking for bugs on it.
If OpenBSD was trying to be a Linux distribution then we'd not have most of the good stuff that makes OpenBSD unique.
I'm sick of following my dreams - I'm just going to ask them where they're going and hook up with them later.
Microsoft should have handled broken apps like SysV did with null pointer derefence. Make the default policy to do immediate free. But provide a flag, settable by application, that can disable immediate free for that app only. Require the users to add a registry entry to work around the broken app. Be sure to name the registry key something that makes it clear to an end user that the app is broken, and the OS is just working around the problem.
You're totally right, dude.
Let me know when you release your Haskell version of Sendmail, and I'll switch over immediately.
Big apps still work after this change. And we've had native Java for a while now.
I'm re-writing it in Perl and Java.
We OpenBSD users *already* sacrifice heaps of usability.
I --force it on my team and they live with it.
CPU is cheap, downtime is expensive and usually really annoying.
There are places where the networks are not touching,and there are places where they are-Boeing's Lori Gunter
It is official; NetCraft has confirmed: OpenBSD 3.7 has been hacked by a rogue internet group less than 24 hours after release.
"We can't believe how easy this one was to crack. There are 3 exploits you can do over the internet right out of the box, and I think we're going to find more," said ZeroC00L, a leader of the X0r h@X0rs. The group claims responsibility for demonstrating exploits in the past 5 OpenBSD releases.
"I think the main reason that people think OpenBSD is 'secure' is because Theo [de Raadt, leader of the OpenBSD 'project'] says it is. The truth is about the opposite; we can't find a single exploit in the latest RedHat, but OpenBSD is OpenSwissCheese. All that crap legacy code from fucking Berkeley hippies, you know."
Theo de Raadt has apparently refused to comment.
It is now very clear that everone wants it. You allocate a segment, tell it exactly how many bytes long it needs to be, and any overrun or underrun causes an MMU exception. No sentinels to check, no waiting for an overrun to reach a page boundary.
Just something to think about, even though it's not portable to other archs. i386 can still do it. Does x86-64 have it?
As copyright owner of this comment, I authorize everyone to defeat any technological measure which limits access to it.
When program X exits, does it's deallocated heap memory become available to a lucky program who asks for some space and gets given the same address? Does does the OS overwrite it before passing it on to the next program or is this the task of the writer of program X?
Methinks you doth misseth the point:
<quote>
Some platforms just don't support the fork() mechanism...
</end-quote>
And multitasking with processes sucks when fork() is not available. 90% of OSes treat processes as threads these days (if they support threading, that is) and provide memory protection to processes. Why cannot they do the same on a threadly basis? Hmm?
Threads aren't the end-all be-all of multi-processing, but they sure are useful.
Perhaps there aren't other popular counterexamples, but there's at least that one. I do remember the old Winterp XLISP-based window package - one of my friends used it for fast prototyping, and found that the prototypes usually had better performance than the evenual production code, as well as often having more features...
Bill Stewart
New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
I don't think OpenBSD breaks things in the name of security. I think OpenBSD allows things that are already broken to crash rather than being compromised. And this is why I do use OpenBSD - it's a lot easier to restart a program than clean up a compromised machine.
I am TheRaven on Soylent News
It always surprises me when something like this gets modded up on /.
This I believe is one of the key differences between programmers and computer scientists. I would simply love to see something with the complexity of sshd or sendmail written in Haskell, Lisp, Scheme, or whatever the current interpreted language is en vogue. Seriously, show me the code! Benchmark some enterprise-level (as in, used in businesses, not the buzzword) non-trivial app (like the aforementioned) written in C/C++ compared to it's interpreted counterpart. I would be incredibly surprised if Apache, Mozilla, Word, whatever would run with anywhere near the speed or responsiveness.
Your opinion (which you are of course entitled to) ignores things like Operating Systems, embedded devices, and even the runtimes/interpreters/virtual machines themselves. And then who is going to maintain this code? Haskell and friends don't have anywhere near the mindshare that C/C++/Java have. You're right.. in theory, using C is terrible, but in reality the other options are worse for different reasons.
Bill
This indicates to me that you have a memory leak in your application.
I helped write a telephony server in Java, which had to be both long-running and fast. Anytime the JVM paused, it was always due to a memory leak. When we first encountered it, we weren't sure what it was either because the symptom was that we were dropping telephone calls due to unhandled events (the events would get to the queue, but the event loop wouldn't handle them due to gc kicking in, and then the ISUP timers would expire causing a missed call). We originally thought the problem was with the event loop, and we steadily improved it. However, one day, we finally ran out of memory after hours of processing calls (nobody was around to witness the pauses, though). It turns out, nobody (including me) had bothered to look at the memory size for the application (typical Java myopia), which was steadily growing as the application ran. We immediately ran the basic Java heap analysis tools and found out that we were misusing the heap something fierce. We were able to reproduce the problem quickly by limiting the heap size, and we noticed the JVM pausing as the gc struggled to free up some memory. After that, we ordered OptimizeIt, and I spent a lot of time tracking down exactly which objects weren't being deallocated properly.
Before we checked for leaks, our server would run for days until it eventually ran out of memory. After we found all the leaks, our server would run forever with the minimum allowed heap size, and we never had any gc pauses after that.
Show me on the doll where his noodly appendage touched you.
That has been known to happen. I don't think so in this case, but I'll will admit I was overly flip about it.
The issue is that memory protection is nice, but in some OS's (like NT and OS/X) launching a new process is more expenisve than launching a new thread.
But Isn't one of the things that makes threads cheaper than processes on these systems the fact that you don't have to set up as much VM stuff when launching a new thread? If so wouldn't threads become more expensive?
I can't read what's in front of me. Apologies.
It's certainly nothing I'd want enabled on a system wide basis. I mean, the simple process of walking a bitmap or list of thread handles could increase the time required to touch/access a page O(1), which would suck in a system of lots of threads (I've only seen one design that actually was better off with 600 threads than 60 threads with 10 WFMO/select() handles per).
:-/ AFAIK, it's the only commonly available OS at the moment without one. Java doesn't quite have that feature either, and with Java, the usefulness of such a feature (thread protected memory) is open to debate.
I guess what I want is a fast fork() on WIN32.
C is still my favorite practical programming language. It's lightweight, elegant, terse, does exactly what you tell it, doesn't hide the machine from you, and people should stop using it for significant projects because too many people can't use it safely 100% of the time. Not only do they shoot themselves in the foot, but they're getting blood all over the floor and other people are slipping on it.
All of these mechanisms are providing steel-toed boots so that usually when you shoot yourself in the foot, the bullets ricochet harmlessly, making enough noise to wake you up, though sometimes the bullet goes through and nails your boot to the floor, but in neither case did you hit the target you actually wanted. It's there to reduce collateral damage, and to make programs crash loudly enough that you can debug them.
Bill Stewart
New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
Rob Pike (or maybe Ken Thompson} once gave a Plan 9 talk where he said that threads are for operating systems that can't do fork() very well...
Bill Stewart
New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
The solution is 0% effective because 386 used SIMMS not DIMMS. :P
If someone is passing you on the right, you are an asshole for driving in the wrong lane.
I made a plugin to http://fidolook.org/ in Borland Delphi.
To make DLL tiny i removed most of Borland RTL, including their heap manager - and replaced it with WinAPI calls. And it crashed. It appeared that the host app freed buffer before using it. And WinAPI (indeed there are 3 APIs, i can't remember which certain was used) wiped out at least the very beginning of the buffer. It was somewhen around Win2k sp2 if i remember right.
"it's a lot easier to restart a program than clean up a compromised machine."
That depends on what it is. If it crashes in such a way that the program isn't usable, then OpenBSD simply isn't an option.
I rarely criticize things I don't care about.
But it's not 5-10% is it? It's orders of magnitude for some things. They haven't even fixed the double-halt bug in STABLE that cuts I/O performance in half in some cases.
Gimme a break... hlt hlt was fixed in both OpenBSD 3.7 and 3.6 stable branches.
But it's not 5-10% is it? It's orders of magnitude for some things.
Yet users will take a hit by running a virus scanner without complaint because they're used to the slowdown.
No, no memory leak, it just did a lot of object creation and destruction, which meant a lot of garbage to be cleaned up when the GC finally triggered. We thought it might be a leak, but heap analysis showed nothing was allocated after GC that shouldn't have been. A typical GC pass would free up about 1gig of memory, which was about right for the amount of object creation that'd been done. The behavior's the big strength of garbage-collected systems, and their big weakness (depending on how your program works).
Ah, sorry. Didn't make the errata page.
I rarely criticize things I don't care about.
"Yet users will take a hit by running a virus scanner without complaint because they're used to the slowdown."
Sure. Windows users.
I rarely criticize things I don't care about.
Yup, most users.
Just pointing out that unless a performance difference is glaring and sudden people tend not to mind or even notice. And I've seen crap Unix software and drivers too that users accepted as normal.
"Just pointing out that unless a performance difference is glaring and sudden people tend not to mind or even notice. And I've seen crap Unix software and drivers too that users accepted as normal."
That depends on what you're doing. If it were an across-the-board 10% I probably wouldn't care, but it's not.
Linux 2.6 kernels are absoloutely outstanding at responsiveness, the only comparable experience I've had was with BeOS. It's pretty easy to tell whether or not (for example) your music skips under high load. Frankly, I've gotten used to being able to throw almost anything at my UP Linux machine without GUI or music being impacted perceptibly. Provided I'm not swapping, I haven't seen a slowdown under any load.
Nothing else out there at the moment seems to be able to do it. Windows can't do it, Mac can't do it, FreeBSD can't do it (even with ULE...), and OpenBSD certainly can't do it (my SSH sessions to my OpenBSD box get laggy when it's under high load).
I rarely criticize things I don't care about.
But what is new about this method exactly? From what I read the guardpages are not truly guardpages, but more of a side product of having gaps in the addresses. And whats new about immediately free'ing memory and returning it? Isn't that the way things were originally done until everyone realized just how poor on performance it was?
This is kinda MS innovation at play here.
In Soviet Russia the insensitive clod is YOU!
http://postmaster.cryp.to/
Wow, who knew :)
Although I'd probably describe it as an MTA construction kit rather than a drop-in sendmail replacement.
TFA doesn't explain what will be done very well. And what it says is consistent with the first of the two explanations I gave. "Guard pages". Perhaps they are unreadable as well as unwriteable? That refinement doesn't change the problems with either of my two methods.
Could you explain perhaps how I am wrong here? I'm thirsty for information.
http://lkml.org/lkml/2005/8/20/95
Check out libumem -- much more powerful than this and has been around in Solaris for years (granted, the manpage should be better to reveal the powerful features -- but a quick look at the source at opensolaris.org reveals how to use the most advanced features).
I have a hardened penis.
1.4 was unsupported when I gave up on OpenBSD as my dev workstation. That's spiffy, it'll help to have that available on the OpenBSD machine. Thanks.
I rarely criticize things I don't care about.
I haven't checked because Java is poorly supported for unrelated reasons, and this rules out OpenBSD without me having to validate all my other software.
Actually, I have Eclipse running and I started JBoss right from the installation the other day. JRE1.5 is in 3.8 so I wouldn't say OpenBSD has poor support for Java.
Is it as fast as it can be? Probably not, but then again, Java on Windows isn't blazingly fast either...
I think that you know it, but COW can sometimes be a loss: if you happen to copy the content of the memory, doing it a page at a time instead of all the page at once may incurr a loss.
So COW can be a big win if no copy occurs, a small win if some copy occur but also a small loss if many copy occur.
um, surely all os's should do this:
1. prog calls malloc (or equivalent)
2. os hands memory to prog
3. prog tries to read or write out of the range it was given
4. BANG!
seems a bit bloody simple to me.
unless it's something to do with the bios/hardware just dumbly doing what it's asked by the code. which is just as stupid as a prog requesting a handle to the File System and magically getting read/write access to every file everywhere instead of just it's local folder and "c:/my documents"
If you don't risk failure you don't risk success.
You can't write a high-performing JIT compiler with pages using memory that's not writable and executable at the same time. The dynamic nature of Java necessitates continual patching of the generated code for a number of reasons. Even if there were no page-boundary problem (ie. making one page unexecutable could affect any number of methods) and no threading problem (ie. making a page unexecutable would affect every thread executing code on that page) it would still be infeasible to do all those extra system calls every time the generated code needs modifying.
Patrick Doyle
I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
Patrick Doyle
I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
What is the point in using a garbage collected language if you can still get memory leaks? If I have to run my programs through valgrind or the like to find leaks, why don't I just write them in C++ to start with?
I know there are other advantages to Java, C++ has some large ones too, and if you use the STL and RAII like you should, you end up simulating the advantages of java. (Plus you don't have to worry about the JVM license)
You can't have memory leaks in the classical sense (i.e you cannot allocate memory directly in Java). We were actually talking about object leaks, which you can also have in C++, Perl, Python, Ruby, and pretty much any other language that has objects. The problem illustrated above has to do with figuring out exactly how long your objects should live. In a program that is long-lived and processes a lot of data very quickly, it's very important to break your references as soon as possible or dilligently reuse objects, because you will run out of memory fast. Regardless of the language, the heap analysis software is used in this case to pinpoint which objects can be deallocated sooner and references that were never broken.
I know there are other advantages to Java, C++ has some large ones too, and if you use the STL and RAII like you should, you end up simulating the advantages of java.
As far as resource (e.g. socket handle) leaks go, you'd be better off in C++, because there is no way for Java to do RAII (i.e. no explicit destructors). Java does have container classes, iterators, and parametric types, however. In C++ you will also need Boost, OpenSSL, and Xerces to simulate the rest of Java's standard API.
(Plus you don't have to worry about the JVM license)
The only license that I've ever worried about when doing commercial software development is the GPL.
Show me on the doll where his noodly appendage touched you.