News for hackers. Stuff that matters.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by qwertyuiop924 on Tuesday October 04, 2016 @08:20PM (#12640736)
No. Stop it. I don't want to hear that we should be re-writing all of our systems code in Rust, or that Oberon and the Wirth family should have won, or that C is crap, and Linux should die, and be re-written, or that this wouldn't have happened if we had all just adopted the Lisp Machine.

We've all heard it already, we all know what you'll say. So skip the smug post, and go do something productive. Like writing a really cool piece of new code, or fixing a use-after-free, or posting something more insightful, or inventing a new type of shoelace that doesn't come untied until you want it to.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by xenadu02 on Wednesday October 05, 2016 @12:41AM (#12641593)
"The revolution will not be televised".

The beginning of the end of use-after-free, buffer overflows, stack smashers, et al will be when we as a community finally accept that C is a terrible language, impossible for ordinary humans to reason about, and must be abandoned. Only when we begin to accept that truth will we all get serious about moving away from it.

For many years the response has been that "C is fine" or some variant of "humans will be better programmers in the future" both of which are demonstrably false.

No one questions the wisdom of paramtaraizing SQL. No one questions the wisdom of not writing your own crypto. Yet despite the mountains of evidence, wasting billions (yes BILLIONS) of man-hours and dollars, and even lives lost there is still resistance to the idea that C needs to die ASAP.

So as long as there are posts like yours our job of educating and persuading isn't finished and that's extremely important if we have a hope of actually making this desperately needed change.

If you still doubt let me go ahead and make a prediction: before the end of the year there will be another RCE exploit in the Linux kernel discovered and a different one will be written, code-reviewed, and committed but not discovered until later (but within 5 years). I'm happy to put $1,000 on this wager.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by qwertyuiop924 on Wednesday October 05, 2016 @05:21AM (#12642541)
I've got no problem admitting that C isn't good enough in most cases, and should probably die. I know that's true. I'm just sick of the annoyingly smug comments about it that pop up like mushrooms on HN. If you're posting here, you're more often than not preaching to the choir.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by GrumpyYoungMan on Wednesday October 05, 2016 @03:00PM (#12646727)
>The beginning of the end of use-after-free, buffer overflows, stack smashers, et al will be when we as a community finally accept that C is a terrible language, impossible for ordinary humans to reason about, and must be abandoned.

1) All the complaints you have apply equally well to assembly language, yet assembly language is all that the CPU understands. Somebody always has to deal with the low level complexity of writing the foundational software constructs necessary to build safe environments and C is still the most natural mapping to varied assembly languages that we have.

2) Nothing else will fit for many embedded systems. Your choices are C or assembly language. What safe environment/language are you going to fit into a microcontroller with 1kB of RAM?

(And, yes, maybe Rust or one of the other proposed system language replacements will be better than C someday, but that someday isn't today.)

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by dragonwriter on Wednesday October 05, 2016 @03:04PM (#12646749)
> All the complaints you have apply equally well to assembly language, yet assembly language is all that the CPU understands.

No, machine code is all that the CPU understands. Assembly language is source code that gets converted into machine code by an assembler.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by crististm on Wednesday October 05, 2016 @02:28AM (#12641915)
Actually, it is still possible to use C as a higher than assembly target language for compilers.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by MaulingMonkey on Wednesday October 05, 2016 @02:42AM (#12641953)
While I'm really interested in this for making languages available everywhere (tm), basic things like signed integer overflow being undefined behavior make me question is C is fit for purpose even here.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by jjnoakes on Wednesday October 05, 2016 @08:07AM (#12643113)
Since you are generating the C code, you can generate the appropriate checks where needed to avoid such undefined behavior too.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by MaulingMonkey on Wednesday October 05, 2016 @08:56AM (#12643370)
Which is the one thing keeping it in the running.

The problem is this line of reasoning doesn't generally hold up when applied to C codebases (because in practice statistics catches up with you eventually) and C code generators, in effect, happen to contain an admittedly small but rather obfuscated C codebase.

Moreover, you must always include such checks - manually crashing on e.g. null pointers even if you'd be entirely satisfied with a segfault - just to avoid the optimizer potentially going apeshit on your code. Which can have... poor effects on program performance.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by jjnoakes on Wednesday October 05, 2016 @02:31PM (#12646479)
If you are writing a code generator, it all depends on the source language. If, for example, your source language doesn't have NULL pointers, then you don't have to waste cycles checking them in C.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by progman on Wednesday October 05, 2016 @11:24AM (#12644621)
Indeed. That's what Nim and Rust (for instance) can do to ease porting to other platforms. Even safety critical applications can be written in C by using tools like FramaC.

https://frama-c.com

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by geofft on Tuesday October 04, 2016 @10:56PM (#12641266)
The smug replies on this comment seem to be the ones saying "Don't tell me about Rust".

So, then, why do you think that "We need to rewrite everything in Rust" isn't doing something productive? I've been a C++ and C developer for a long time and have been waiting for some safer language that lets me do what I've been doing in those languages. Knowing that Rust was a realistic option was what inspired me to learn it and write new things in it. If that happens at scale, that's how we actually get things written in a memory-safe language.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by sirtaj on Wednesday October 05, 2016 @12:58AM (#12641640)
> So, then, why do you think that "We need to rewrite everything in Rust" isn't doing something productive?

The Linux kernel didn't get written because people on a forum said "we need to write a complete open source reimplementation of the UNIX kernel," but because Torvalds just went ahead and wrote it. Most things in F/OSS work that way.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by geofft on Wednesday October 05, 2016 @01:12AM (#12641684)
GNU had a whole manifesto, though. https://www.gnu.org/gnu/manifesto.en.html (Although, yes, a signifiant body of software existed when the manifesto was published.)
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by Natsu on Wednesday October 05, 2016 @02:39AM (#12641940)
Linus Benedict Torvalds 8/25/91

Hello everybody out there using minix -

I'm doing a (free) operating system (just a hobby, won't be big and professional like gnu) for 386(486) AT clones. This has been brewing since april, and is starting to get ready.

https://groups.google.com/forum/#!msg/comp.os.minix/dlNtH7RR...

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by falcolas on Wednesday October 05, 2016 @09:52AM (#12643770)
I imagine the project is big enough now that anyone who would undertake it would want to be compensated for it. And since that is unlikely to ever pass the cost/benefit ratio for any given corporation, it's unlikely to happen. Not to mention the potential for alienating of the entire existing kernel development group.

It would be much easier to submit patches to slowly upgrade the kernel to a memory safe language, but that would require a lot of political savvy to push through, also making it an unlikely path to be taken. Ultimately, you'd have to convince Linus of the merits, and we all know how much he likes complex languages.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by falcolas on Wednesday October 05, 2016 @09:19AM (#12643534)
If it hasn't happened already, with another of the dozens of memory safe languages (like ada) which have been on the market for dozens of years, another memory safe language coming (like Rust) along won't change that.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by geofft on Wednesday October 05, 2016 @12:23PM (#12645276)
Why do you think that? Or, put another way, why specifically do you think it didn't happen with previous memory-safe languages?

For one, Rust is a different language from the other memory-safe languages that have existed in the past, and in fact incorporates a lot of research in programming languages that didn't exist when Ada was designed. But even if that weren't true, one thing that's changed since the past is we now are slowly understanding how difficult it is to write secure software in C, and how important it is to write secure software. When Unix was first designed we (the entire programming community) didn't know about a lot of security issues, and the lack of Internet meant that it was less important to defend against them. It is probably much more worth rewriting our tools in Ada today than it was ten or twenty or thirty years ago.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by falcolas on Wednesday October 05, 2016 @01:32PM (#12645903)
> Or, put another way, why specifically do you think it didn't happen with previous memory-safe languages?

IMO, because it's harder to break the rules. Sometimes the rules just need to be broken. There was a recent article about someone attempting to interface with OpenGL in Rust a month or so ago, and it discussed how they ended up giving up, since the things they needed to do didn't mesh well with how Rust expected programs to be written. If interfacing with a driver is so hard, how will interfacing with hardware be easier?

Programming for hardware requires a lot of breaking and bending the rules. How can being memory safe help when you're creating memory spaces as most software knows of it?

Performance is King, low memory overhead is Queen. Even rust can't take those thrones away from C. Not yet, at least. Perhaps not ever (I expect that C++ would have done it, were it possible for a language with the complexity of Rust).

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by steveklabnik on Wednesday October 05, 2016 @01:41PM (#12645994)

  >  If interfacing with a driver is so hard, how will interfacing with
  > hardware be easier?
It really depends. The key is to identify the proper ways to make the abstraction as safe as possible. This is a fairly new skill, in a new language. Said post was good, and the author has been using Rust for a long time, but one person failing to do so doesn't mean that it's impossible.

I'm still a noob at this kind of thing myself, but I recently wrote a (tiny) driver for a memory-mapped device. My first iteration had tons of unsafe code. My second iteration had three lines of unsafe code. My latest iteration has zero unsafe code, though you do need one call to an unsafe function outside of it in order to construct it. (to create a slice from the raw memory location that's mapped.)

That is, of course, pretty much the simplest possible case. But I believe the pattern will hold, over time, as people learn how to do it.

  > Even rust can't take those thrones away from C.
Rust is faster than C on some microbenchmarks. We'll see what the future holds.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by lmm on Wednesday October 05, 2016 @06:40AM (#12642807)
This is a discussion forum, of course you're going to find talking rather than doing here.

Once there's a firm consensus that it's time to move away from C we'll probably stop talking about it. But that consensus has to develop through discussion and argument here and elsewhere (and if you look at the conversations now compared to a year or two ago, I'd say we've made a lot of progress). If you don't believe there's value in talking about technical issues then what are you even doing here?

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by qwertyuiop924 on Wednesday October 05, 2016 @10:48AM (#12644232)
There's actually a pretty solid consensus here. I'm the only one I've seen arguing about C, and even I agree that it should be moved away from with these sorts of codebases. It's the rest of the world which doesn't have a consensus.

You're welcome to post, of course. I'd just rather you not. There's no sense preaching to the choir.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by meanduck on Wednesday October 05, 2016 @09:14AM (#12643495)
I guess GP is refering to repetitiveness of same arguments.

A tree thread is good for discovery but not so good for reaching a conclusion/consensus. Flat/linear thread should be used instead.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by kardashian007 on Tuesday October 04, 2016 @09:58PM (#12641111)
There are no unicorn solutions, however being religously blind to potential net value of fallible but potentially better interoperable alternatives would be irrational. Any rewrite cannot likely be accomplished in one pass (without some really smart code transpiler), but would more likely occur on a gradual migration todo list with a bidirectional interoperable language. The evaluation of such languages would likely involve requesting necessary features such as freestanding compilation, performance profiling/tracing tools and debugger integration, proofs of correctness and GC-less operation, among others. It's not impossible but it would need to be demonstrated that the perceived immense cost is significantly offset by the perceived immense value over "doing things as they've always been done."
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by swsieber on Wednesday October 05, 2016 @12:22AM (#12641538)
And it definitely could be done in one pass because bugs like this do exist, and the language we want to port to should prevent them.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by nine_k on Tuesday October 04, 2016 @09:46PM (#12641068)
Instead of fixing a particular use-after-free, how about making use-after-free impossible?
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by qwertyuiop924 on Wednesday October 05, 2016 @05:23AM (#12642550)
Great. Instead of telling us, most of whom already know, about it, go do it.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by walter_bishop on Tuesday October 04, 2016 @09:51PM (#12641087)
> Instead of fixing a particular use-after-free, how about making use-after-free impossible?

Yes ..

Does this vulnerability work only on a particular architecture?

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by mark4o on Wednesday October 05, 2016 @12:41AM (#12641592)
The bug is architecture independent, although a particular exploit may work only on a specific architecture.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by otterley on Tuesday October 04, 2016 @11:30PM (#12641358)
At what cost to performance? Very rarely are there solutions that exist without tradeoffs.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by johncolanduoni on Tuesday October 04, 2016 @11:44PM (#12641417)
Many verification systems can understand virtually any proof you can throw at them, so any memory management scheme for which you have a rigorous argument for correctness should be able to operate with no additional runtime overhead. And if you don't have such an argument, you've already lost no matter what language you use.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by AstralStorm on Wednesday October 05, 2016 @03:34AM (#12642124)
The main cost to performance is related to multicore proofs. It is an open question on how to work out complete proofs of multithreaded operations.

This is why seL4 does not support internal SMP. You can run an instance per core and assign it a separate memory space like to a VM though.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by topspin on Wednesday October 05, 2016 @03:13AM (#12642033)
Well that's the thing about C and its ilk; it is an endless wellspring of awful failures and so the voices you are trying to shout down have an unlimited supply of ammo. This will keep happening and you're going to keep hearing about it and the arguments for alternatives will continue to strengthen. That's the reality to which you need to adapt, if you're a reasonable person.

The advocates of these alternatives aren't creating this situation. The unavoidable fact is that our traditional tools have a propensity to propagate bugs that are fabulously difficult to discover. That's one of the lessons of nearly a half century of C. New tools are emerging that solve this problem and their advocates have every reason to say so.

Another lesson C teaches us through its popularity and longevity is that performance will always be critical for systems code; there will never be a day when we can squander cycles and RAM on garbage collectors and reference counts and indirections and all the other bookkeeping and abstractions inherent to so many languages that have utterly failed to displace C for systems programming.

I don't know what the future looks like. Maybe it's Rust. Maybe Linus will get fed up and invent a better language in 4 days. Maybe someone will create an AI system that can spot this sort of bug before it ever gets checked in. All I know for sure is that the current situation is intolerable and yelling at people to shut up about it won't work.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by qwertyuiop924 on Wednesday October 05, 2016 @05:27AM (#12642564)
I'm fine with admitting C had flaws. It does need to be replaced for many projects. It's just the smug comments on HN that irritate me, especially because most of us are already in agreement (including me, now), and those who aren't won't be convinced by the sheer power of smugness. In short, I'm not complaining because the people who do this sort of thing are wrong, but because they're not actually helping.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by pjmlp on Wednesday October 05, 2016 @08:17AM (#12643145)
Hence why I support projects done in Go, even if I dislike the design decisions regarding its type system.

Every program written in Go is one program less written in C.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by qwertyuiop924 on Wednesday October 05, 2016 @09:50AM (#12643755)
Fair enough.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by phyzome on Wednesday October 05, 2016 @08:44AM (#12643292)
Hey, you know how to get rid of the smug comments, including this one?

...

Make sure there's less C code around.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by qwertyuiop924 on Wednesday October 05, 2016 @09:50AM (#12643757)
Unfortunately, when you get rid of C code, comments don't get deleted.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by MaulingMonkey on Wednesday October 05, 2016 @02:16PM (#12646328)
Now now, some C code is commented.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by qwertyuiop924 on Wednesday October 05, 2016 @03:06PM (#12646768)
All right, I'll admit it, I laughed out loud when I heard this. Maybe it's because of my all-too-fresh experiences trying to decipher undocumented C as a newbie (which I still am). It almost makes this thread worth it.
Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by zigzigzag on Wednesday October 05, 2016 @04:40AM (#12642372)
I don't know about that - very little software is written in C these days. Even parts of the Windows and Mac kernels are written in at least C++ and Microsoft had an entire OS written in C# internally. Meanwhile the games industry has been C++ since forever (which still isn't great but better than C) and most business and web software is written in GCd languages.

BTW the kernel is full of reference counts.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by johncolanduoni on Wednesday October 05, 2016 @05:18AM (#12642531)
> BTW the kernel is full of reference counts.

I think the OP is pointing to languages like Swift/Objective-C where reference counts are used even if you don't really need them, not that ever reference counting anything is a lazy abstraction.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by falcolas on Wednesday October 05, 2016 @10:04AM (#12643869)
I'll add to this. Before you can even begin championing your language for kernel development, make sure it can compile to all of the same architectures that C can. Make sure that programs written in your language are as space and time efficient as the equivalent C programs. These are things you can do today, if you feel strongly enough about this cause.

Once your language is at that point, then start building up your arguments to convince Linus and the majority of the core kernel developers that your language is the right choice for continued development.

Until these occur, it's all just pointless speculation.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by zzzcpan on Wednesday October 05, 2016 @10:37AM (#12644139)
> to convince Linus and the majority of the core kernel developers

The biggest cost is not them, it's every other C programmer, every other company, the whole industry. It's unrealistic to even think that any significant part of them is going to invest resources into another language just to gain memory safety.

Re:Linux Kernel Use-After-Free Remote Code Execution Vulnera... by falcolas on Wednesday October 05, 2016 @10:55AM (#12644299)
I figure, if you're capable of coming up with an argument which convinces Linus to move away from C, you can use that logic to convince anybody (who is capable of being convinced by logic in the first place).