websnarf@gmail.com wrote
(in article
<1125209654.068310.325250@o13g2000cwo.googlegroups .com>):
[color=blue]
> Randy Howard wrote:[/color]
[color=blue][color=green][color=darkred]
>>> Bad programming + good programming language does not allow for buffer
>>> overflow exploits.[/color]
>>
>> For suitably high-level languages that might be true (and
>> provable). Let us not forget that C is *not* a high-level
>> language. It's not an accident that it is called high-level
>> assembler.[/color]
>
> Right. If you're not with us, you are with the terrorists.[/color]
Excuse me?
[color=blue]
> Why does being a low language mean you have to present a programming
> interface surrounded by landmines?[/color]
If you have access to any sequence of opcodes available on the
target processor, how can it not be?
[color=blue]
> Exposing a sufficiently low level
> interface may require that you expose some danergous semantics, but why
> expose them up front right in the most natural paths of usage?[/color]
Do you feel that 'gets()' is part of the most natural path in C?[color=blue][color=green]
>> I'd love for you to explain to us, by way of example, how you
>> could guarantee that assembly programmers can not be allowed to
>> code in a way that allows buffer overflows.[/color]
>
> Ok, the halting problem means basically nobody guarantees anything
> about computer programming.[/color]
Fair enough, but you're just dodging the underlying question.
[color=blue]
> But its interesting that you bring up the questions of assembly
> language. If you persuse the x86 assembly USENET newsgroups, you will
> see that many people are very interested in expanding the power and
> syntax for assembly language (examples include HLA, RosAsm, and
> others).[/color]
For a suitably generous definition of 'many', perhaps.
[color=blue]
> A recent post talked about writing a good string library for
> assembly, and there was a strong endorsement for the length prefixed
> style of strings, including one direct reference to Bstrlib as a design
> worth following (not posted by me!).[/color]
I would have been shocked if you had not figured out a way to
bring your package up. :-)
[color=blue]
> So, while assembly clearly isn't an inherently safe language, it seems
> quite possible that some assembly efforts will have a much safer (and
> much faster) string interface than C does.[/color]
Which does absolutely nothing to prevent the possibility of
developing insecure software in assembler. It may offer some
advantages for string handling, but that closes at best only one
of a thousand doors.
[color=blue][color=green]
>> [...] If you want to argue that too many people
>> write code in C when their skill level is more appropriate to a
>> language with more seatbelts, I won't disagree. The trick is
>> deciding who gets to make the rules.[/color]
>
> But I'm not arguing that either. I am saying C is to a large degree
> just capriciously and unnecessarily unsafe (and slow, and powerless,
> and unportable etc., etc).[/color]
Slow? Yes, I keep forgetting how much better performance one
achieves when using Ruby or Python. Yeah, right.
Powerless? How so? It seems to be the only language other than
assembler which has been used successfully for operating system
development.
Unportable? You have got to be kidding. I must be
hallucinating when I see my C source compiled and executing on
Windows, Linux, NetWare, OS X, Solaris, *bsd, and a host of
other UNIX-like platforms, on x86, x86-64, PPC, Sparc, etc.
[color=blue][color=green][color=darkred]
>>> Ok, this is what I was talking about when I mentioned rose colored
>>> glasses. If programmers are perfect, then what you are saying is fine,
>>> because you can expect perfection. But real people are not. And I
>>> think expectations of perfection in programming is really nonsensical.[/color]
>>
>> /Exactly/ Expecting zero buffer overruns is nonsensical.[/color]
>
> Well, not exactly. If you're not using C or C++, then buffer overflows
> usually at worse lead to a runtime exception; in C or C++, exploits are
> typically designed to gain shell access in the context of the erroneous
> program. Its like honey for bees -- people attack C/C++ programs
> because they have this weakness. In other safer programming languages,
> even if you had a buffer overflow, allowing a control flow
> zombification of the program is typically not going to be possible.[/color]
That is all true, and it does nothing to address the point that
C is still going to be used for a lot of development work. The
cost of the runtime error handling is nonzero. Sure, there are
a lot of applications today where they do not need the raw speed
and can afford to use something else. That is not always the
case. People are still writing a lot of inline assembly even
when approaching 4GHz clock speeds.
[color=blue][color=green]
>> Anyway, a language so restrictive as to guarantee that nothing
>> can go wrong will probably never be used for any real-world
>> project.[/color]
>
> How about simpler language that is more powerful, demonstrably faster,
> more portable (dictionary definition), obviously safer and still just
> as low level?[/color]
That would be nice.
[color=blue]
> Just take the C standard, deprecate the garbage, replace
> a few things, genericize some of the APIs, well define some of the
> scenarios which are currently described as undefined, make some of the
> ambiguous syntaxes that lead to undefined behavior illegal, and you're
> immediately there.[/color]
I don't immediately see how this will be demonstrably faster,
but you are free to invent such a language tomorrow afternoon.
Do it, back up your claims, and no doubt the world will beat a
path to your website. Right? "D" is already taken, what will
you call it?
[color=blue]
> Your problem is that you assume making C safer (or faster, or more
> portable, or whatever) will take something useful away from C that it
> currently has. Think about that for a minute. How is possible that
> your mind can be in that state?[/color]
It isn't possible. What is possible is for you to make gross
assumptions about what 'my problem' is based up the post you are
replying to here. I do not assume that C can not be made safer.
What I said, since you seem to have missed it, is that the
authors of the C standard are not responsible for programmer
bugs.
[color=blue][color=green]
>> So is the idea of a 'perfect language'.[/color]
>
> But I was not advocating that. You want punishment -- so you
> implicitely are *demanding* programmer perfection.[/color]
No, I am not. I do not demand that doctors are perfect, but I
expect them to be highly motivated to attempt to be perfect.
[color=blue][color=green]
>> It's quite easy to simply make the use of gets() and friends
>> illegal for your code development. Most of us have already done
>> so, without a standard body telling us to do it.[/color]
>
> So, estimate the time taken to absorb this information per programmer,
> multiply it by the average wage of that programmer, multiply that by
> the number of programmers that follow that and there you get the cost
> of doing it correctly.[/color]
What cost? Some 'world-wide rolled-up cost'? For me, it cost
me almost nothing at all. I first discovered gets() was
problematic at least a decade ago, probably even earlier, but I
don't keep notes on such things. It hasn't cost me anything
since. If I hire a programmer, this has all been settled to my
satisfaction before they get an offer letter. It hasn't been a
problem and I do not expect it to be one in the future.
[color=blue]
> The standards body, just needs to remove it and those costs go away.[/color]
They do not. As we have already seen, it takes years, if not
decades for a compiler supporting a standard to land in
programmer hands. With the stunningly poor adoption of C99, we
could not possibly hope to own or obtain an open source C0x
compiler prior to 2020-something, if ever. In the mean time,
those that are serious solved the problem years ago.
[color=blue]
> You don't think people who move code around with calls
> to gets() in it should remove them?[/color]
Of course I do. In fact, I say so, which you conveniently
quoted just below...
[color=blue][color=green]
>> Even so, anyone dusting off an old program that doesn't go
>> sifting through looking for the usual suspects is a fool.[/color]
>
> And an old million line program?[/color]
Didn't /you/ just say that they should be removed?
[color=blue]
> I think this process should be
> automated. In fact, I think it should be automated in your compiler.
> In fact I think your compiler should just reject these nonsensical
> functions out of hand and issue errors complaining about them.[/color]
Make up your mind. Fixing them in the the compiler, as I would
expect an 'automated' solution to do, and rejecting the
offending lines are completely different approaches.
[color=blue]
> Hey! I have an idea! Why not remove them from the standard?[/color]
Great idea. 15 years from now that will have some value.
A better idea. Patch gcc to bitch about them TODAY, regardless
of the standard.
[color=blue][color=green]
>> I don't have a problem with taking gets() out of modern
>> compilers, but as you already pointed out, this doesn't
>> guarantee anything. People can still fire up an old compiler
>> and use it. I don't see a realistic way for the C standard to
>> enforce such things.[/color]
>
> Interesting -- because I do. You make gets a reserved word, not
> redefinable by the preprocessor, and have it always lead to a syntax
> error.[/color]
What part of 'people can still fire up and old compiler' did you
fail to read and/or understand?
[color=blue]
> This has value because, developers can claim to be "C 2010 compliant"
> or whatever, and this can tell you that you know it doesn't have gets()
> or any other wart that you decided to get rid of.[/color]
They could also simply claim "we are smarter than the average
bear, and we know better to use any of the following offensive
legacy functions, such as gets(), ..."
To clarify, since it didn't soak in the first time, I am not
opposed to them being removed. I simply don't this as a magic
bullet, and certainly not in the sense that it takes far too
long for the compilers to catch up with it. I would much rather
see compilers modified to deny gets() and its ilk by default,
and require a special command line option to bypass it, /if at
all/. However, the warning message should be far more useful
than
gets.c: 325: error: gets() has been deprecated.
That's just oh so useful, especially to newbies. I wouldn't
care if it dumped a page and a half of explanation, along with a
detailed example of how to replace such calls with something
safer. After all, good code doesn't have it in them anyway, and
it won't annoy anyone that is competent.
[color=blue]
> This would in turn
> put pressure of the legacy code owners to remove the offending calls,
> in an effort that's certainly no worse than the Y2K issue (without the
> looming deadline hanging over their heads).[/color]
If, and only if, they use a compiler with such changes. We
still see posts on a regular basic with people using old 16-bit
Borland compilers to write new software.
[color=blue][color=green][color=darkred]
>>> And what if its not the programmer's fault?[/color]
>>
>> It is the fault of the development team, comprised of whoever
>> that involves for a given project. If the programmer feels like
>> his boss screwed him over, let him refuse to continue, swear out
>> an affidavit and have it notarized the bad software was
>> knowingly shipped, and that you refuse to endorse it.[/color]
>
> Oh I see. So, which socialist totally unionized company do you work as
> a programmer for? I'd like to apply![/color]
I don't think you understood me. I know of no company that has
a policy for this. However, if I was working on something and
felt that something was being done that could be inherently
dangerous, and it was going to ship anyway, I would take some
form of legal action, if for no other reason than to be able to
disassociate myself from the impending lawsuits.
I would much rather go look for work than participate in
something that might wind up with people dying over the actions
of some meddling manager.
[color=blue][color=green]
>> [...] If you
>> are being overworked, you can either keep doing it, or you can
>> quit, or you can convince your boss to lighten up.[/color]
>
> Hmmm ... so you live in India?[/color]
Why would you think so?
[color=blue]
> I'm trying to guess where it is in this
> day and age that you can just quit your job solely because you don't
> like the pressures coming from management.[/color]
Where do you live? Because I am trying to guess where on the
planet you would /not/ have the right to quit your job.
Indentured servitude is not widely practiced anymore, AFAIK.
[color=blue][color=green]
>> [...] ESPECIALLY in this case, the C standard folks are not to blame.[/color]
>
> But if the same issue happens and you are using a safer language, the
> same kinds of issues don't come up. Your code might be wrong, but it
> won't allow buffer overflow exploits.[/color]
You can have 10 dozen other forms of security failure, that have
nothing to do with buffer overflows. It isn't a panacea. When
one form of attack is removed, another one shows up.
For example, the last straw the sent Microsoft windows off my
network for eternity happened recently. A computer system
running XP, SP2, all the patches, automatic Windows updates
daily, virus software with automatic updates and real-time
protection, email-virus scanning software, two different brands
of spyware protection, also with automatic updates enabled, and
both a hardware firewall and software firewall installed, got
covered up in viruses after 2 hours of letting my kids use it to
go play some stupid online kids game on disney.com or
nickelodeon.com (not sure which, since they went to both, and I
didn't want to replicate it). Suddenly, when I come back to
look at it, it has 3 or 4 new taskbar icons showing downloads in
progress of I know not what task manager shows a bunch of extra
processes that shouldn't be there, the registry run keys are
stuffed fool of malware, and it's pushing stuff out the network
of I know not what. I pull the cable, start trying to delete
files, which Windows wants to tell me I don't have permission to
do, scanning, the browser cache directories are filled with .exe
and .dll files, it's out of control.
A few expletives later, and I was installing a new Linux distro
that I had been meaning to try out for a while.
I had done just about everything I could imagine to lock the
system down, and it still got out of control in 2 hours letting
a 12-yr-old browse a website and play some games.
Of course, if enough people do the same thing, the bad guys will
figure out how to do this on Linux boxes as well. But for now,
the OS X and Linux systems have been causing me (and the kids)
zero pain and I'm loving it.
[color=blue][color=green]
>> Try and force me to write something in a way that I know is
>> wrong. Go ahead, it'll be a short argument, because I will
>> resign first.[/color]
>
> That's a nice bubble you live in. Or is it just in your mind?[/color]
No, I'm just not a spineless jellyfish. It's rather
disappointing that it surprises you, it doesn't say much for
your own backbone that you would just roll over when faced with
this sort of thing.
[color=blue][color=green]
>> We expect architects, doctors, lawyers, pretty much all
>> other real 'professions' to meet and typically exceed a higher
>> standard, and those that do not are punished, fined, or stripped
>> of their license to practice in the field. Why should
>> programmers get a pass? Is it because you do not feel it is a
>> professional position?[/color]
>
> Because its not as structured, and that's simply not practical.
> Doctors have training, internships, etc. Lawyers have to pass a bar
> exam, etc. There's no such analogue for computer programmers.[/color]
Thank you. You get it now. That is exactly what is missing.
[color=blue]
> Because the most successful programmers are always ones that are
> able to think outside the box,[/color]
Then they should have zero problems passing a rigorous training
program and examinations.
[color=blue]
> but the bar for average programmers is pretty low --[/color]
Fine. If you don't have your cert, you can be a 'nurse', you
can write scripts, or use uber-safe languages certified for
those not willing to prove themselves worthy through formal
certification.
[color=blue]
> but both can make a contribution, and neither can guarantee
> perfect code.[/color]
And no doctor can guarantee that you won't die on the operating
table. But, they have to prove that they are competent anyway,
despite the lack of a guarantee of perfection. Would you like
it if they didn't have to do so?
[color=blue][color=green][color=darkred]
>>> Programmers are generally not aware of the liability of
>>> their mistakes.[/color]
>>
>> Then those you refer to must be generally incompetent.[/color]
>
> Dennis Ritchie had no idea that NASA would put a priority inversion in
> their pathfinder code.[/color]
Are you implying that Dennis Ritchie is responsible for some bad
code in the pathfinder project?
[color=blue]
> Linus Torvalds had no idea that the NSA would
> take his code and use it for a security based platform.[/color]
Is there any evidence that the NSA chose his code because it was
not worth fooling with? What is your point? Oh, you're going
to tell us...
[color=blue]
> My point is
> that programmers don't know what the liability of their code is,
> because they are not always in control of when or where or for what it
> might be used.[/color]
Wow, that is tortured at best. Presumably Ritchie is in your
list because of C or UNIX? How could he be 'liable' for an
application or driver written by somebody else 30 years later?
Are the contributors to gcc responsible for every bad piece of
software compiled with it?
If someone writes a denial-of-service attack program that sits
on a Linux host, is that Torvald's fault? I've heard of people
trying to shift blame before, but not that far. Maybe you might
want to blame Linus' parents too, since if they hadn't conceived
him, Linux wouldn't be around for evil programmers to write code
upon. Furrfu.
[color=blue]
> The recent JPEG parsing buffer overflow exploit, for example, came from
> failed sample code from the JPEG website itself. You think we should
> hunt down Tom Lane and linch him?[/color]
Nope. If you take sample code and don't investigate it fully
before putting it into production use, that's /your/ problem.
You think a doctor would take a sample of medicine he found
laying on a shelf in 7-11 and administer it to a patient in the
hopes that it would work? Downloading source off the web and
using it without reading and understanding it is similarly
irresponsible, although with perhaps less chance (although no
guarantee) of it killing someone.
[color=blue][color=green]
>> I highly doubt that. Low-level language programmers would be
>> the cream of the crop, not 'the lowest bidder' as is the case
>> today.[/color]
>
> You still don't get it. You, I or anyone you know, will produce errors
> if pushed. There's no such thing as a 0 error rate for programming.[/color]
Then I do get it, because I agree with you. Let me know when I
can write a device driver in Python.
[color=blue]
> Just measuring first time compile error rates, myself, I score roughly
> one syntax error per 300 lines of code. I take this as an indicator
> for the likely number of hidden bugs I just don't know about in my
> code. Unless my first-compile error rate was 0, I just can't have any
> confidence that I don't also have a 0 hidden bug rate.[/color]
Strange logic, or lack thereof. Having no first-compile errors
doesn't provide ANY confidence that you don't have hidden bugs.
[color=blue]
> Go measure your own first-compile error rate and tell me you are
> confident in your own ability to avoid hidden bugs.[/color]
That would be pointless, since measuring first-compile error
rate proves zilch about overall bug rates. If you want to avoid
hidden bugs, you have to actively look for them, test for them,
and code explicitly to avoid them, regardless of how often your
compiler detects a problem.
[color=blue]
> If you still think you can achieve a 0 or near 0 hidden bug rate,[/color]
[snip, no sense following a false premise]
[color=blue]
> For a nuclear reactor, I would also include the requirement that they
> use a safer programming language like Ada. Personally I would be
> shocked to know that *ANY* nuclear reactor control mechanism was
> written in C. Maybe a low level I/O driver library, that was
> thoroughly vetted (because you probably can't do that in Ada), but
> that's it.[/color]
Well gee, there you have it. It seems that there are some
places were C is almost unavoidable. What a shock. Who's
wearing those rose-colored glasses now?
[color=blue][color=green]
>> [...] For
>> example, there are operations that have very low success rates,
>> yet there are doctors that specialize in them anyway, despite
>> the low odds.[/color]
>
> Well, your analogy only makes some sense if you are talking about
> surgeons in developing countries who simply don't have access to the
> necessary anesthetic, support staff or even the proper education to do
> the operation correctly. In those cases, there is little choice, so
> you make do with what you have. But obviously its a situation you just
> want to move away from -- they way you solve it, is you give them
> access to the safer, and better ways to practice medicine.[/color]
You seem to ignore the /fact/ that even in the finest medical
facilities on the planet (argue where they are elsewhere) there
are medical operations that have very low success rates, yet
they are still attempted, usually because the alternative is
certain death. A 20% chance is better than zero.
[color=blue][color=green]
>> If you don't want to take the risk, then go write in visual
>> whatever#.net and leave it to those that are.[/color]
>
> So you want some people to stay away from C because the language is too
> dangerous.[/color]
So are chainsaws, but I don't want chainsaws to be illegal, they
come in handy. So are steak knifes, and despite them be illegal
on airplanes, being stuck with plastic 'sporks' instead, I still
like them when cutting into a t-bone. You can not eliminate all
risk.
Do you really think you can do anything to a language that
allows you to touch hardware that will prevent people from
misusing it? Not all development work is for use inside a VM or
other sandbox.
[color=blue]
> While I want the language be fixed so that most people
> don't trigger the landmines in the language so easily.[/color]
I am not opposed to the language removing provably faulty
interfaces, but I do not want its capabilities removed in other
ways. Even so, there is no likelihood of any short-term
benefits, due to the propagation delay of standard changes into
compilers, and no proof that it will even be beneficial
longer-term.
It would probably be a better idea for you to finish your
completely new "better C compiler" (keeping to your string
library naming) and make it so popular that C withers on the
vine. It's been so successful for you already, replacing all
those evil null-terminated strings all over the globe, I quiver
in anticipation of your next earth-shattering achievement.
--
Randy Howard (2reply remove FOOBAR)