The 25-Year-Old BSD Bug 213
sproketboy writes with news that a developer named Marc Balmer has recently fixed a bug in a bit of BSD code which is roughly 25 years old. In addition to the OSnews summary, you can read Balmer's comments and a technical description of the bug.
"This code will not work as expected when seeking to the second entry of a block where the first has been deleted: seekdir() calls readdir() which happily skips the first entry (it has inode set to zero), and advance to the second entry. When the user now calls readdir() to read the directory entry to which he just seekdir()ed, he does not get the second entry but the third. Much to my surprise I not only found this problem in all other BSDs or BSD derived systems like Mac OS X, but also in very old BSD versions. I first checked 4.4BSD Lite 2, and Otto confirmed it is also in 4.2BSD. The bug has been around for roughly 25 years or more."
more proof (Score:5, Funny)
Re:more proof (Score:4, Funny)
Re: (Score:2, Insightful)
Unless you present some proof that this never happened in a Microsoft product, you have nothing.
I'm not saying it did, but you have to take Microsoft's word that it didn't, and no more evidence than that.
I'd rather go with the more transparent option, thank you.
Re:more proof (Score:5, Interesting)
Nothing shady about it either; that's the beauty of BSD code.
Re: (Score:3, Funny)
the developers probably knew about it (Score:5, Funny)
Re:the developers probably knew about it (Score:5, Funny)
Such as dodging chairs.
Now it's time for a little housekeeping (Score:2)
That is, wouldn't somebody in the past quarter century have exploited this bug to hide a malicious executable file or two?
Not sayin', just wonderin'...
Re:Now it's time for a little housekeeping (Score:5, Informative)
Re: (Score:3, Insightful)
See? SEE? (Score:5, Funny)
This is the power of Open Source!
With all those eyes looking at the code, stuff like this gets ID'd and fixed LICKITY SPLIT!
(runs and hides)
Re:See? SEE? (Score:5, Insightful)
In comparison, Microsoft has been around for what... 20 years? And who knows what bugs in Windows are there, lurking, just waiting to bite us?
Old Code (Score:3, Insightful)
Re: (Score:2)
Re: (Score:2)
Re: (Score:3, Funny)
Re:Old Code (Score:5, Informative)
Only 4 years ago.
Re:Old Code (Score:4, Informative)
analysis of th win2000 source code
Don't click that link!!! (Score:5, Insightful)
Re: (Score:3, Funny)
Re: (Score:2)
Buzzwords are not entirely derived of meaning, it's just that they don't convey a clear message, more of an idea. Granted, most of the time, that idea has a lot of different interpretations, making the buzzword nearly meaningless.
But you wouldn't really argue that when someone calls something "Web 2.0", that there's no way to know what is meant, would you?
Trac (Score:5, Funny)
Re: (Score:2, Redundant)
(hate those boundary bugs!)
Re:Trac (Score:4, Funny)
Samba knew, but didn't pass it on? (Score:5, Insightful)
Surely both the samba communities and the *BSD communities are active enough that this could have been passed on for further investigation by the *BSD crowd? (Sure, samba probably would still need a workaround, particularly given the long uptimes and widespread deployment of *BSDs)
I know nothing of the devs at Samba and *BSD, but seems a bit strange. Perhaps they did try..
Meanwhile, congrats to Marc on fixing a bug. One of the most touted benefits of open source (whatever your license) code.
--Q
Re: (Score:3, Insightful)
Re:Samba knew, but didn't pass it on? (Score:5, Interesting)
Yes, Samba did pass on what it found and it appears they were promptly shot down by someone on the *BSD side.
The Samba e-mail archives contain a message from over 3 years ago [samba.org], but it doesn't give attribution to the *BSD source.
The Samba Bugzilla also has a bug reported more recently [samba.org] involving the same issue. Reading through the bug history, you can see there was one FreeBSD dev involved in the bug discussion, and he referenced a prior conversation between Tridge (Samba) and PHK (FreeBSD) where PHK said there was no bug in FreeBSD.
Re: (Score:2)
Would this be a "Critical" or "Important?" (Score:3, Funny)
If no one has cared enough to fix it for 25 years, I'm guessing this should be rated as "inconsequential."
Must have been a really slow news day at OSNews.
bug blassification, side effects and Insults! (Score:5, Funny)
1. I think this bug would be classified "archeological".
2. The question now is what happens to the Samba work-around patches. Now that the bug is fixed, do the patches cause a side-effect (i.e. "a new bug")?
3. This gives rise to a new meme of nerd insults. "You call yourself a programmer? Why I've fixed bugs older than you!" Of course, only one man is entitled to use that line.
Re: (Score:2)
1. Excellent point! Wish I'd thought of it before submitting.
2. It's still a feature that now will need remediation. Argues well against using work-arounds for long periods, rather than fixing the root problem. Think ITIL or Y2K.
3. Actually others have solved older bugs, they just haven't had a slashdot article with their names in light. Think COBOL/FORTRAN.
Re: (Score:2)
If the GCC guys had access to the old Intel source code, would thay have made the same mistake?
Re: (Score:3, Insightful)
BSD is Dying! (Score:5, Funny)
Re:BSD is Dying! (Score:4, Funny)
Must have been a CockRoach. (Score:2)
After this long (Score:4, Funny)
Should it be fixed? (Score:5, Insightful)
Re: (Score:2, Insightful)
Re: (Score:2)
Re:Should it be fixed? (Score:5, Informative)
Re:Should it be fixed? (Score:4, Interesting)
Yes.
People were aware that the notion of a directory being a sequence of entries, with each entry having a position such that you can get the position of an entry and later seek to that position and have the next read return that entry even if changes were made to the directory in the interim, was wrong.
That doesn't mean that they were just trying to avoid having the standard imply that particular bug was fixed - it means that they were trying to avoid making a promise that some reasonable implementations of directories can't keep even if those implementations have no bugs.
Known defect? (Score:2, Interesting)
Did the Samba folk not tell the BSD folk of the issue?
This couldn't have happened with Linux... (Score:3, Insightful)
Re: (Score:3, Funny)
Re: (Score:2)
http://finance.yahoo.com/q?s=SCOXQ.PK [yahoo.com]
Re: (Score:3, Funny)
Long live the Code (Score:5, Interesting)
Here is why (Score:5, Insightful)
That is why they are still around and still popular. They are K.I.S.S., work as they are supposed to, and the modular code that is plugged into them can just be sloughed away when it becomes out dated, and newer, better code plugged in to modernize the OS as you go.
That's also why Windows has had so many problems over the years. Windows was designed to be everything you need in a single package. That means everything is all tied up together. So, unlike BSD and the *nixes, when part of the OS becomes out dated, MS can't just unplug the old stuff and plug in new stuff. It's all interlinked from the ground up. That means a large portion of development time getting is spent fixing bugs caused by new additions, which then cause even more problems down the line when you go to update again. It also makes it bloated as legacy code ends up stuck in the mix because without it the patched together additions wouldn't function right.
And, unfortunately for MS, their market dominance is based on the windows "feel" being familiar and backwards compatibility. If they could, I'm sure they'd re-write windows from the ground up, but now they are in a catch 22 where doing so might significantly kill their market share.
I'm guessing Bill and company sometimes look back and kick themselves for not having the guts to go for broke and re-do the OS from the ground up for Windows XP. Because, back then MS was still king, Apple was at its low point with a very small and stagnant market share, and the *nixes were still primarily a hard core enthusiast hobby. Today, if MS were to completely change Windows, they'd probably lose a significant amount of market share to a variety of alternatives.
Another common old bug (Score:5, Interesting)
Need a new system call to really fix this. (Score:5, Interesting)
Any filesystem based on a non-linear-file directory format, such as a B-Tree, will simply never produce consistent offsets or indices within such a buffer.
The only way to *REALLY* fix this is to add a cookie field to the filesystem-independant dirent structure (and if your BSD isn't using a filesystem-independant dirent structure, it needs to be first fixed to do that). lseek()ing to a directory cookie works just fine, and always will (or at least will far more robustly then trying to scan a re-cached buffer from getdirentries()).
When DragonFly went to a filesystem-independant dirent structure I very stupidly only added ~40 reserved bits to the dirent structure, instead of the 64 we need to properly implement per-entry directory cookies. I'm still pissed at myself for that gaff.
In anycase, a per-entry directory cookie effectively solves the problem. The only other way to get such cookies, if it can't be embedded in the dirent structure, is to create a new system call similar to getdirentries() but which also populates an array of directory cookies. FreeBSD and DragonFly have kernel implementations of readdir which supply per-entry directory cookies so it is really just a matter of creating the new system call and then making libc use it.
-Matt
Demonstration of the bug (Score:5, Insightful)
OpenBSD is good at fixing this kind of bug (Score:4, Insightful)
Re:Wait... Would you ever hit this? (Score:5, Funny)
Re:Wait... Would you ever hit this? (Score:5, Informative)
Re: (Score:2, Funny)
Re: (Score:2)
Re: (Score:3, Insightful)
Re: (Score:3, Insightful)
"many eyes make bugs shallow" is equivalent to the "infinite number of monkeys..." thing.
In my experience it's better to have quality than quantity when it comes to the eyes used for finding bugs.
Any idiot can tell you about obvious bugs, and it's kind of waste of time to see 1 million duplicate bug reports, because it's too slow to search through 100 million other bugs (with dupes) for dupes
For UI stuff, you get the naive (as
Re: (Score:2, Interesting)
Re:Many eyes make bugs shallow... (Score:4, Interesting)
I mean, a burglar can sue the owner of the property they're burgling for leaving it in a dangerous condition, so why not this too?
That's if it were true, of course.
Re:Many eyes make bugs shallow... (Score:4, Insightful)
BSD has been checked over by 'quality' eyes--when it was used as the basis of NeXT/OSX, for example. They missed it too.
If the code wasn't open (i.e. if there weren't many eyes), this bug would have remained forever, or at least until the code was dumped.
Re: (Score:2)
The "good old" weaknesses of proprietary code make it likely to get dumped way before 25 years.
a) the company having the source could go bust, or decide to do something different.
b) people could lose track and/or understanding of the source and since it's not "mirrored and documented by everyone", it's gone.
c) someone could decide to throw it away and write a new version from scratch, and so the old version will vanish.
Often you do
Re:Many eyes make bugs shallow... (Score:4, Funny)
Re:Many eyes make bugs shallow... (Score:5, Funny)
Re: (Score:3, Informative)
b) truncating title attributes is not a bug
Re:Many eyes make bugs shallow... (Score:5, Insightful)
Re:Many eyes make bugs shallow... (Score:5, Insightful)
Re:Many eyes make bugs shallow... (Score:5, Interesting)
Re: (Score:2)
Re:Many eyes make bugs shallow... (Score:5, Insightful)
Re:Many eyes make bugs shallow... (Score:5, Informative)
Re: (Score:3, Insightful)
Re:Many eyes make bugs shallow... (Score:5, Insightful)
Re: (Score:3, Interesting)
Except that the bug had been triggered many times before, seeing as how Samba had code in place to work around it.
Which makes me wonder if there will be applications that will break when the bug is fixed. This would not surprise me in the slightest, I have seen really obscure bugs relied on. I worked on a Wordplex system that would hang if you gave the display instructions to roll zero lines of the display up zero lines starting at line zero. We fixed it to do nothing and someone complained that they used this to "lock the system" if someone entered the wrong code too many times!
Re: (Score:2, Insightful)
That, or the individual who discovers it would be fired, blacklisted, and possibly be arrested and charged with some criminal act.
Re:Many eyes make bugs shallow... (Score:5, Informative)
This bug has been around for a long time, but is only visible if you have large directories and delete files from them in between calls to readdir and seekdir. This is quite uncommon behaviour, and was incredibly uncommon 25 years ago when filesystems were much smaller and directories almost never contained enough files to require more than one or two disk blocks to store the directory.
When the Samba people found it, they decided to just code a work-around and not bother to report it to any of the BSD teams. If they had done, it would probably have been fixed in 22 years.
Now that it has been fixed in OpenBSD, the change can easily be taken and incorporated into FreeBSD, NetBSD, DragonFlyBSD and Darwin.
Re:Many eyes make bugs shallow... (Score:4, Interesting)
This bug has been around for a long time, but is only visible if you have large directories and delete files from them in between calls to readdir and seekdir.
But that's exactly my point, isn't it? The bug was only "visible" through its behavior, not its manifestation in code. The shallow bugs argument basically says that if enough people stare at the code, they will find the bugs. Clearly that did not happen here.
Whether the bug fix can propagate rapidly has nothing to do with what I'm talking about. I'm not trying to disparage the concept of open source, I'm arguing that the shallow-bugs argument should be rejected.
Re:Many eyes make bugs shallow... (Score:5, Insightful)
A quick googling of "many eyes make all bugs shallow" brings me the more complete statement that adage is simplified from: "Given a large enough beta-tester and co-developer base, almost every problem will be characterized quickly and the fix will be obvious to someone." (Linus via ESR). Clearly this 25-year-old bug is one of the exceptions that calls for the 'almost'.
Re:Many eyes make bugs shallow... (Score:5, Insightful)
Well. Just reading the source is part of it, but not all.
Fact is, if I run into odd behaviour when testing/using - if the source is available I can read it, I can breakpoint.
I cannot do that with a binary.
So yes. Things did occur as they were supposed to. Someone found something odd, they were able to look at code in question, and fix it.
The shallowness is the fact that there is a direct connection between the thousands of testers/users and the code in question.
Instant turnaround. No "user reports behaviour in detailed fashion, including testcase, to some corporate e-mail address, and maybe it eventually gets a to a developer three layers down who may be able to figure it out and fix it if he has the time"
Re: (Score:2, Insightful)
I am not an open source zealot or anything, in fact I'm more inclined to use proprietary software at home and open source, almost exclusively, for my business. I say this so that I'm clear about my disclosing my personal views. (In other words, I believe in all things moderation and think zealotry is absurd and I probably shouldn't be confused with an open source zeal
Re: (Score:2, Funny)
(In other words, I believe in all things moderation and think zealotry is absurd and I probably shouldn't be confused with an open source zealot or even an advocate.)
Sounds like you're a bit of a moderation zealot...
Re:Many eyes make bugs shallow... (Score:5, Insightful)
You sound like those people that don't like evolution. The concept of shallow bugs is an approximate description of how things work, not a methodology. Also, if enough people stare at the code and use it, they will find the bugs that matter.
Seems like a strawman arguement to me (Score:3, Insightful)
I don't believe that many in the open source community dogmatically accept the shallow-bugs arguement as a universally applicable rule of software development. It seems to me that any reasonable person would agree that
Re: (Score:3, Insightful)
what was so special about this code that the samba developers couldn't have just written a patch rather than a work around?
Well, if you wrote a program with a bug, and I wrote a program that used yours, and i found your bug, what would you expect me to do if i told you about it and you said "that isnt a bug, and we wont be fixing it"?
Why would I write a fix to give to you when I know you wont be adding it to your program at all?
Why would I write it at all? Specifically in this case, its usually considered 'bad' for a user level application to require you to patch your kernel, and only on a certain OS but none of the others.
Re: (Score:3, Insightful)
And even more important, they would have to code a workaround anyway, to unbreak older BSD systems running Samba.
Re: (Score:2, Informative)
seekdir and readdir are unreliable when you're modifying the directory being read. The API requirement is that readdir return each directory entry that existed at the time the directory was opened exactly once. In the traditional UNIX implementation, the directory is simply a sequential stream of bytes; this is pretty easy -- you can simply lseek to the position that telldir returned. However, other systems don't use something that simple -- Mac OS X, for example, uses a B-Tree for the catalog file. Wo
Re: (Score:2)
Re:Many eyes make bugs shallow... (Score:5, Informative)
https://bugzilla.samba.org/show_bug.cgi?id=4715 [samba.org]
I did point out that no other POSIX system behaved like that, but that didn't seem to make much difference
Jeremy.
Re:Many eyes make bugs shallow... (Score:5, Insightful)
Re: (Score:2)
Re:Many eyes make bugs shallow... (Score:4, Insightful)
Heck, how many other bugs have been fixed over the years?
These detracting arguments smack of FUD mongering...
Re: (Score:3, Interesting)
I am sure you will agree that the correct statement sans flamebait modifications does not warrant a "clear contradiction" as many detractors of FOSS who are jumping at this opportunity to point out a example of a fixed bug that was not necessarily a security risk and saying "see, the OSS model is clearly flawed! BSD has a 25year old bug that was only fixed now!"
Take off your paranoid hat. Holy crap. I am an open source author myself. I just have always hated this particular argument.
Re: (Score:2)
yeah, sure (Score:2)
Re:yeah, sure (Score:4, Insightful)
This is touted as a slip up (or flaw) in the Open Source model of doing things, yet a proprietary software developer, and one of the largest mind you, failed to spot this completely.
Re: (Score:2)
"Many eyes make all bugs shallow" is clearly wrong, in detail. There do exist bugs that can't be traced that way, e.g. (The one I'm thinking of is the infamous C compiler that was jiggered to insert a binary mod into itself whenever it recompiled itself.)
However, being wrong in detail isn't the same as being wrong in principle. Very few statements that use an un-circumscribed "all" are actually TRUE!!!, bu
Re:They actually do... (Score:5, Insightful)
Re: (Score:2)
Was that flamebait aimed at stirring up responses from all the people that were thinking about looking into unit tests until they got permission from Knuth to not use them in his recent interview? BTW, this bug didn't exactly blow the world away, and this is the sort of heavy load testing that you don't have time to run in your "make tests" phase or your xUnit derived unit testing platform.
Re: (Score:3, Insightful)
Nobody's saying that - that would be retarded. What's said is that there would be fewer undiscovered bugs, and more rapid and complete fixes. Notice how he began his investigation by looking at the SAMBA source code. You might also note that he was able to look into the second issue as well, making both SAMBA and FreeBSD a tiny bit better along the wa