News for hackers. Stuff that matters.
Re:Cross-platform Rust rewrite of the GNU coreutils by cbsmith on Tuesday March 22, 2016 @01:56PM (#11338472)
Really, if your project intends to be portable C code, you need to compile it with undefined behaviour generating an error.
Re:Cross-platform Rust rewrite of the GNU coreutils by adrusi on Tuesday March 22, 2016 @02:08PM (#11338564)
Undefined behavior is not always identifiable through static analysis. Obviously it can be checked against at runtime, but that's actually quite expensive. It would, for example, include bounds checks for everything, and overflow checks on all signed arithmetic.
Re:Cross-platform Rust rewrite of the GNU coreutils by pcwalton on Tuesday March 22, 2016 @03:29PM (#11339291)
That's not the worst of it: the truly intractable part is preventing use-after-free UB. The only ways to do this are (a) remove malloc from your language; (b) add a lifetime system (incompatible with all existing C libraries); (c) add a garbage collector (which most projects written in C will not accept for performance reasons).
Re:Cross-platform Rust rewrite of the GNU coreutils by kbenson on Tuesday March 22, 2016 @06:50PM (#11340570)
I think that's mostly solved by changing the whole of the idea from "remove/disallow all undefined behavior" to "remove as much of the common needed undefined behavior as possible such that most programs need not really use it". Perfect is the enemy of good.
Re:Cross-platform Rust rewrite of the GNU coreutils by pcwalton on Tuesday March 22, 2016 @11:11PM (#11341853)
That'd be fine if use-after-free was a corner case that doesn't show up often in practice, but every single exploit at Pwn2Own this year was UAF…
Re:Cross-platform Rust rewrite of the GNU coreutils by kbenson on Wednesday March 23, 2016 @12:07AM (#11342092)
Are we arguing the same thing? If UAF is the cause of security problems, and UAF is undefined behavior now, redefining it under a special mode to mean "this is an error (whether or not the compiler enforces it)" at least clarifies the situation,and lets and included static analysis report an error as needed and capable.

That is, I'm not arguing that as much undefined behavior as possible should be made defined and possible, just that it's defined. That definition may very well be "you are not allowed to do this. Don't do this."

Re:Cross-platform Rust rewrite of the GNU coreutils by cbsmith on Tuesday March 22, 2016 @08:19PM (#11341067)
With portable software (as in, portability is more valuable than other factors), imperfect is the enemy. ;-)
Re:Cross-platform Rust rewrite of the GNU coreutils by kbenson on Tuesday March 22, 2016 @08:55PM (#11341284)
We have over four decades history of portability being valued over correctness, stability and security. I'm not impressed with where it's gotten us.
Re:Cross-platform Rust rewrite of the GNU coreutils by cbsmith on Wednesday March 23, 2016 @12:11PM (#11345724)
See, I look at it as the opposite. You aren't really portable if your code isn't correct.
Re:Cross-platform Rust rewrite of the GNU coreutils by astrange on Tuesday March 22, 2016 @06:50PM (#11340569)
And once you've eliminated that, you have DoS bugs like forcing infinite loops, abandoned (referenced but unused) memory leaks, and worst-case hash table insertions. All of those are serious attacks for anything with a resource budget.
Re:Cross-platform Rust rewrite of the GNU coreutils by cbsmith on Tuesday March 22, 2016 @08:20PM (#11341068)
rlimit ftw
Re:Cross-platform Rust rewrite of the GNU coreutils by cbsmith on Tuesday March 22, 2016 @06:49PM (#11340564)
Trapping on an overflow register signal is very, very cheap, and there are standard libraries for it.

Some of this stuff can be caught at compile time. Like code that does signed addition of positive values and checks if they might be less.