News for hackers. Stuff that matters.
Re:There’s a Hole in the Bottom of the C: Effectiveness of A... by Animats on Wednesday November 14, 2018 @04:56PM (#18454421)
Rust is getting some traction, and much web infrastructure has moved away from C/C++ to C# or Go or Java. After decades of little progress, we're seeing forward motion.
Re:There’s a Hole in the Bottom of the C: Effectiveness of A... by pjmlp on Wednesday November 14, 2018 @05:32PM (#18454792)
True, myself have moved definitely into Java/.NET worlds back in 2006, although C++ is still an option for what is unavoidable to do without it. Maybe in the future their canonical implementations can even be fully bootstraped or have replaced the C++ layer with something else.

But even if all userspace developers move to safer languages, we still have the UNIX derived kernels, PIC and other microcontrollers, routers and plenty of other embedded stuff to worry about.

Even Microsoft with their Azure Sphere project, which is supposed to be all about secure IoT, still bundles a Linux kernel with it.

Hence why we really need to fix C somehow.

Re:There’s a Hole in the Bottom of the C: Effectiveness of A... by andrewflnr on Wednesday November 14, 2018 @05:56PM (#18455003)
There's no way to "fix C" in a way that saves you from the cost of fixing all those broken programs written in C. The best a language-level solution can do for an existing project is make it easier to figure out what specifically needs fixing. Or blow up your code and run time with checks, I guess, but if that was technically feasible, to say nothing of political challenges, those projects wouldn't have been in C to start.

I feel like Elrond at the council of Rivendell: "you have only one choice." Except throwing a ring into a hole is a comparatively well-defined task relative to rewriting an unknown number of crappy pieces of software. Ed: also there's no conveniently situated group of people to whom to assign the project.

Re:There’s a Hole in the Bottom of the C: Effectiveness of A... by pcwalton on Wednesday November 14, 2018 @06:16PM (#18455162)
> Or blow up your code and run time with checks, I guess, but if that was technically feasible, to say nothing of political challenges, those projects wouldn't have been in C to start.

Most of the infrastructural projects you're referring to predated modern languages. There is no reason, for example, for an MTA to be written in C today. We use MTAs written in C because MTAs are old.

Re:There’s a Hole in the Bottom of the C: Effectiveness of A... by andrewflnr on Wednesday November 14, 2018 @06:48PM (#18455426)
They had pascal and friends, didn't they? Which are safer, safe-ish, right? But I guess today you could eat the cost of automatically inserted runtime checks on software designed to push the limits of 30yo hardware. Still won't fly for Linux or embedded systems...
Re:There’s a Hole in the Bottom of the C: Effectiveness of A... by pjmlp on Thursday November 15, 2018 @01:25AM (#18457308)
There is this expression, a language is a dialect with an army.

The same applies to system languages, just that the army is the OS that bundles them as THE official language.

Pascal based OSes unfortunately lost their place on the market.

To pick a more modern example, how many people would have bothered with JavaScript if it wasn't THE language on the Web OS?

Re:There’s a Hole in the Bottom of the C: Effectiveness of A... by nickpsecurity on Wednesday November 14, 2018 @08:31PM (#18456128)
Schemes for memory safety of C code have already been applied to UNIXy OS's. SVA-OS with SAFEcode used FreeBSD.

Far as embedded, there were some done in Ada and a Java subset. There's even real-time GC's for that kind of stuff. One or two companies sell Java processors that run it natively. CompSci stays doing CPU extensions that could work with MCU's.

Re:There’s a Hole in the Bottom of the C: Effectiveness of A... by pcwalton on Wednesday November 14, 2018 @08:20PM (#18456057)
The versions of Pascal that are practical aren't any safer than C.

With a properly designed programming environment, you don't need many bounds checks to begin with. Almost every embedded system can easily afford the cost of the few you can't eliminate.

Re:There’s a Hole in the Bottom of the C: Effectiveness of A... by pjmlp on Thursday November 15, 2018 @01:21AM (#18457294)
On the contrary.

While they aren't Rust level safe, they eliminate like 80% of the common C safety errors.

Thanks to explicit conversions, proper enums, reference parameters, actual string and vector types, memory allocation based on types instead of arbitrary numbers, type safe linkage thanks modules.

So while use after free or double frees would are still an issue, many other classes of typical C errors would be gone.

Re:There’s a Hole in the Bottom of the C: Effectiveness of A... by pcwalton on Thursday November 15, 2018 @12:19PM (#18461161)
Conversions and such aren't where the memory-safety-related vulnerabilities in C++ come from nowadays. They come from memory management problems, which Pascal doesn't help with.
Re:There’s a Hole in the Bottom of the C: Effectiveness of A... by pjmlp on Thursday November 15, 2018 @04:49PM (#18463749)
Moving goal posts here? I thought we were speaking about C.

Yes Rust is great and all, sometimes getting people half-way is better than not at all.

Re:There’s a Hole in the Bottom of the C: Effectiveness of A... by andrewflnr on Thursday November 15, 2018 @07:53PM (#18465172)
He probably meant to type C/C++ or something but typo'd it. The set of vulnerabilities is exactly the same. If Pascal still lets you do heap corruption, it's only a matter of time before RCEs become common. So yeah, I'm convinced on that point.
Re:There’s a Hole in the Bottom of the C: Effectiveness of A... by pjmlp on Wednesday November 14, 2018 @06:06PM (#18455075)
Basically, until the world gets rid of UNIX derived OSes, we call it a defeat and go back home.
Re:There’s a Hole in the Bottom of the C: Effectiveness of A... by andrewflnr on Wednesday November 14, 2018 @06:22PM (#18455218)
If you're trying to characterize what I said, no. I'm saying we need to work on convincing the world to frigging drop Unix-derived OSes already.
Re:There’s a Hole in the Bottom of the C: Effectiveness of A... by pjmlp on Thursday November 15, 2018 @01:29AM (#18457324)
Agreed, but it seems we are loosing on that front from the last 20 years, right?

Including the commercial failure of Inferno.

How things are going even Microsoft could eventually have again their own version.

So from the business perspective it seems the only way to win is to fix the language UNIX is written on.

Re:There’s a Hole in the Bottom of the C: Effectiveness of A... by pdkl95 on Wednesday November 14, 2018 @07:54PM (#18455890)
> userspace

Pure userspace software is the easiest to fix; there has already been a huge shift to {safer,easier} languages for most new(-ish) software. C/C++ is mostly used for existing software where other options we not {possible,practical}. Porting to another language will probably happen now that we have options like Rust, but it will take a massive amount of work.

However, one place where we need more (and better) alternatives to C is the library ABI. If you want to make a library that can be used by as widely as possible you either use C or something that can generate libraries with a standard C-style ABI. That's the FFI tools of most other languages expect. (C++ ABI is also used, but name-mangling complicates interfacing with other languages) Rust's #[no_mangle] helps, but what we really need is standardized ABI with a safer calling conventions and memory handling semantics that is still very generic, without any language specific baggage or other complications. Until that exists, key parts of the infrastructure will stay with C out of necessity.

> kernels

That's one of the infrastructure pieces I was referring to. Other parts that depend critically on a generic C-like ABI interoperability might include driver-based stuff like libGL.so.

> microcontrollers

While I needed the low-level properties of C (w/ assembly) when I was implementing {802.3,IP,TCP,HTTP,SNMP} on a Z80-clone with 16kB of RAM, modern "microcontrollers" often aren't very "micro" and basically a lightweight linux host. They will move to other languages following after regular userspace software.

However, this is assuming there is even a need for safer languages on the micro, which is true when it's accepting data from a hostile source like a network. A much better idea is to simply not connect your embedded device to a network. A safer language isn't necessary if you aren't controlling anything dangerous, your input is limited to reading buttons states with GPIO, and any bugs can be fixed with a reset from a hardware watchdog timer.

> other embedded stuff to worry about.

There is defiantly a lot of embedded crap that need to be junked and replaced asap, but that's not really a C problem. Buffer overrun safety is great but it doesn't do much when the device has a backdoor password clearly visible in the firmware, ships with the admin password "admin", or grants remote admin access when the password is "" (empty string).

We do need to fix C, but there are, unfortunately, far worse problems with embedded devices.

Re:There’s a Hole in the Bottom of the C: Effectiveness of A... by pjmlp on Thursday November 15, 2018 @02:48AM (#18457599)
Regarding ABIs, ChromeOS, Android, Windows (COM/UWP/.NET) and the old guard mainframes are living proof that one can have a library ABI completely unrelated to C.

On the microcontrollers side, there are a couple of vendors that I usually advocate, which do sell Basic, Pascal, Oberon, Java implementations, however if it surprising and refreshing as well, that they still manage to keep in business, given how hard is to move most embedded devs away from C89 + extensions/Assembly duo.

Talks about how to advocate C++ to such devs are a now a recurring theme at C++ conferences.

Even Microsoft which uses a mix of C# and Rust for IoT Edge, they went with Linux and C on Azure Sphere, which is supposed to be their mark on secure IoT, while I was expecting that at very least they would use the opportunity to push their Checked C project, given that Azure Sphere is being pushed by the same MSR group from Singularity and friends.