News for hackers. Stuff that matters.
Re:OpenSSL Security Advisory by zzzcpan on Tuesday May 03, 2016 @11:28AM (#11621490)
To be fair, most of the vulnerabilities found in C codebases are preventable with static analysis, bound checking, etc. If you are ok with it getting as slow as Go, you can get similar safety guarantees as well.
Re:OpenSSL Security Advisory by nickpsecurity on Tuesday May 03, 2016 @11:35AM (#11621542)
You can get complete spatial and temporal safety with Softbound + CETS:

http://www.cs.rutgers.edu/~santosh.nagarakatte/softbound/

They and Cambridge CHERI team have hardware modifications, too, if you want to run C apps on FPGA CPU with inherent safety. Software-only, though, has significant performance penalties.

Re:OpenSSL Security Advisory by vog on Tuesday May 03, 2016 @11:47AM (#11621668)
> If you are ok with it getting as slow as Go, you can get similar safety guarantees as well.

FWIW, Rust can make these guarantees without performance penalties.

Re:OpenSSL Security Advisory by seangrogg on Tuesday May 03, 2016 @12:00PM (#11621792)
There are penalties, they are just relatively marginal.
Re:OpenSSL Security Advisory by kibwen on Tuesday May 03, 2016 @12:07PM (#11621859)
Specifically, Rust does runtime bounds checking when you index into an array. LLVM is theoretically capable of optimizing these checks out if they're unnecessary, but it's far from guaranteed. It would take a dependent type system to perform compile-time bounds checking, and Rust isn't that sophisticated.

However, indexing is far, far less prevalent in Rust than it is in C, due to the existence of iterators. I've asked the Servo team on multiple occasions whether the cost of bounds checking shows up in performance profiles, and they never have, likely because they just aren't doing very much indexing to begin with.

Re:OpenSSL Security Advisory by pcwalton on Tuesday May 03, 2016 @03:44PM (#11623613)
> There are penalties, they are just relatively marginal.

What are the penalties, specifically?

Re:OpenSSL Security Advisory by geodel on Tuesday May 03, 2016 @12:19PM (#11621995)
Since Rust does not provide sec-libs in standard distribution nor they are available in larger ecosystem, Rust benefits seems theoretical to me. As with other things in theory C/C++ code could also avoid memory/security issues.
Re:OpenSSL Security Advisory by pcwalton on Tuesday May 03, 2016 @03:45PM (#11623621)
I don't see any other way to read this other than "there's no point in rewriting security code in Rust because security code in Rust hasn't been written yet". That, obviously, doesn't make sense to me.
Re:OpenSSL Security Advisory by geodel on Tuesday May 03, 2016 @05:33PM (#11624409)
You do not see any other way to read because you are looking to argue over innocuous statement which is not even false. Security code in Rust could be great and I will be happy if and when it is available for general use.
Re:OpenSSL Security Advisory by eridius on Tuesday May 03, 2016 @08:54PM (#11625432)
I agree with pcwalton, that's how I read it too. The context of this thread is security vulnerabilities in OpenSSL, so it's quite reasonable to read your parent comment exactly as pcwalton did.
Re:OpenSSL Security Advisory by bluejekyll on Tuesday May 03, 2016 @01:50PM (#11622778)
They do exist in the larger ecosystem, they are just very young. Also, we devs have had "don't build your own crypto" beaten into our heads so often lately that I think people are generally wary of starting new, or using new, projects that haven't already been battle hardened.

I've looked at the OpenSSL code, and I have to say that it's not well documented in many cases and easy to make mistakes in it's usage. The rules on when locks are needed vs. not are not always clear, and then the ownership of memory is as confusing as it's always been in C.

This is where something like Rust would shine just by cleaning up these interfaces. The Rust OpenSSL bindings, http://sfackler.github.io/rust-openssl/doc/v0.7.10/openssl/ , for example are very sane, and it's difficult to screw up the usage.

Re:OpenSSL Security Advisory by geodel on Tuesday May 03, 2016 @02:19PM (#11622992)
Do you mean Rust-openssl bindings will not require patching openssl for Rust apps in case vulnerabilty? In that case Rust surely helps applications written in it.
Re:OpenSSL Security Advisory by dfc on Tuesday May 03, 2016 @03:24PM (#11623473)
What are "sec-libs"? From the other reply it seems "sec-libs" are the hip mounted pouches of enchanted crypto dust so you can sprinkle it around and get "security".
Re:OpenSSL Security Advisory by lmm on Tuesday May 03, 2016 @11:41AM (#11621601)
> To be fair, most of the vulnerabilities found in C codebases are preventable with static analysis, bound checking, etc.

You can work in an ad-hoc dialect of C based on particular tools that will be a bit safer than standard C, sure (though probably still not as safe as an actually memory-safe language). But at that point most of the advantages of C no longer apply: you don't have a huge library ecosystem, you don't have a supply of experienced developers, you don't have a bunch of standard automated tools that work with your dialect.

> If you are ok with it getting as slow as Go, you can get similar safety guarantees as well.

There is no native/standard/supported-by-tools way to do tagged unions, so whatever you do C will always be less safe than languages that have native tagged unions.

Re:OpenSSL Security Advisory by jjnoakes on Tuesday May 03, 2016 @03:09PM (#11623351)
I don't think "most of the advantages of C no longer apply [if you use static analysis or bounds checking]" is fair.

Even if your claims about losing libraries, experienced developers, or automated tools was true (which think is false), you still get portability, close-to-the-metal code, full control of your processes, direct access to the native ABI, full access to the platform facilities, fast compilation, small executables, standalone libraries, memory layout control, ...

Re:OpenSSL Security Advisory by lmm on Tuesday May 03, 2016 @03:56PM (#11623695)
C code is less portable than most of the alternatives. In the rare cases where the things you list are hard requirements there are still safer options e.g. Ada.
Re:OpenSSL Security Advisory by jjnoakes on Tuesday May 03, 2016 @05:13PM (#11624287)
C code is less portable than which alternatives?

As far as I know, most/all? alternatives are implemented in C or C++.

Re:OpenSSL Security Advisory by lmm on Wednesday May 04, 2016 @05:16AM (#11627161)
Plenty of alternatives are self-hosting, but that's neither here nor there. Even if it's a major effort to port e.g. the Python interpreter to a new platform (particularly the first new platform - once you have a C codebase that enforces portability over many platforms it's much easier to add a new one). But that major effort has by and large been done for even relatively obscure languages and relatively obscure platforms. Whereas if you write in C you get to do that major effort for yourself for each program.
Re:OpenSSL Security Advisory by jjnoakes on Wednesday May 04, 2016 @08:20AM (#11627779)
More portable means "can be ported to new platforms more easily", not "has been ported to new platforms by someone else".

A C program (in general) is more portable than anything written on top of C because to port, say, Python to a new platform, one has to have C there first.

It has nothing to do with whether the work has been done by you or someone else.

Of course, one can write code in either language which is not portable, but that is also beside the point.

Re:OpenSSL Security Advisory by lmm on Wednesday May 04, 2016 @11:19AM (#11628957)
> A C program (in general) is more portable than anything written on top of C because to port, say, Python to a new platform, one has to have C there first.

Port C compiler -> port your C program vs port C compiler -> port Python interpreter -> port your Python program. The latter can still end up a lot easier and cheaper, because the Python interpreter is already multi-platform and Python programs tend not to have much if any platform-specific code by the nature of the language.

> It has nothing to do with whether the work has been done by you or someone else.

It has everything to do with that. Ultimately via Turing equivalence it's possible to port anything to anywhere, so when we're talking about "portability" we must be talking about how much it costs to port a program to a new or existing architecture.

> Of course, one can write code in either language which is not portable, but that is also beside the point.

Again, it's very much the point, because it can't possibly be a yes-or-no thing. How costly is typical/idiomatic C code to port? How costly is typical/idiomatic Python code? Those are the questions that matter when we talk about language portability.

Re:OpenSSL Security Advisory by jjnoakes on Wednesday May 04, 2016 @11:33AM (#11629060)
By definition, the C language is more portable than the Python language, because in order to run Python on a system, C must run there first.

Unless you are talking about a Python not implemented in C, or a C compiler that was created to only compile the Python interpreter (and not all of the C language), then there is no other way around this simple fact.

A standard-conforming program should be part of the topic here, not "typical/idiomatic" non-objective software. Just because most people may not write portable C code doesn't make the language itself more or less portable. It just makes those particular programs less portable.

Plenty of C code is highly portable. Plenty is not. Same can be said of Python. It is moot. The language is under discussion here, not any set of specific programs written in the language.

Also, beside that simple logical conclusion, it is 2-3 orders of magnitude easier for me to port a C program I wrote to a new platform than it is for me to port the Python interpreter just to support my Python program on a new platform. Nevermind all of the features I would have to port (or neuter) inside Python which my program may not even use.

Re:OpenSSL Security Advisory by lmm on Thursday May 05, 2016 @04:09AM (#11634603)
> By definition, the C language is more portable than the Python language, because in order to run Python on a system, C must run there first.

What definition are you using, and what practical use is your definition? You seem to be defining "portable" in some absurd, irrelevant way so that your preferred language "wins", regardless of what that actually means.

> A standard-conforming program should be part of the topic here, not "typical/idiomatic" non-objective software. Just because most people may not write portable C code doesn't make the language itself more or less portable. It just makes those particular programs less portable. > Plenty of C code is highly portable. Plenty is not. Same can be said of Python. It is moot. The language is under discussion here, not any set of specific programs written in the language.

The standard is just some words on a page. The programs and tools are what give it meaning. If 90%+ of the things we call "C programs" don't conform to the standard, it's not reasonable to treat the standard as the definition of a "C program". And for any practical, real-world decision like "should I write my program in C or Python", the typical/idiomatic is the question that matters.

> it is 2-3 orders of magnitude easier for me to port a C program I wrote to a new platform than it is for me to port the Python interpreter just to support my Python program on a new platform. Nevermind all of the features I would have to port (or neuter) inside Python which my program may not even use.

How often do you port things to a platform on which the Python interpreter doesn't already build? And how large are these programs for the 2-3 orders of magnitude? (I guess small in any case if you're talking about writing a program yourself rather than in a team). The Python interpreter is actually pretty small.

Re:OpenSSL Security Advisory by jjnoakes on Thursday May 05, 2016 @07:42AM (#11635228)
Are you being obtuse on purpose?

There are C compilers for N platforms. There are Python interpreters for M platforms. Since the Python interpreter is written in C, N >= M.

The programs I have ported are more than a million lines. Not the largest, sure, but not trivial. And they run on platforms where Python does not.

The size of the C code or the Python interpreter code does not matter. What does matter is what subsystems are required. Python is general purpose and has a wide set of requirements (networking, file systems, process manipulation, dynamic loading, the list is quite long). Oh, and the Python list includes compiling C programs (for extensions). A second reason backing my absurd definition.

The C programming language requirements placed on the hosting environment are much smaller. So the language is more portable for that reason as well. It is beneficial to only port what you use, instead of having to port a monolithic interpreter, including the parts you don't need (which may not even run on the target platform easily or at all).

Re:OpenSSL Security Advisory by lmm on Friday May 06, 2016 @06:43AM (#11642937)
> There are C compilers for N platforms. There are Python interpreters for M platforms. Since the Python interpreter is written in C, N >= M.

Sure, but existence of a compiler is only a small piece of portability. As a FreeBSD user I'm very used to downloading a random program and finding it won't run on my platform. Happens a lot more often when the program's written in C than when it's written in Python.

Re:OpenSSL Security Advisory by jjnoakes on Friday May 06, 2016 @08:50AM (#11643568)
So? The existence of a conforming C compiler is all it takes for the C language to have been ported to that platform.

Or do you think C isn't ported to a platform unless every random C program you download from the internet compiles and runs?

Re:OpenSSL Security Advisory by lmm on Friday May 06, 2016 @10:23AM (#11644167)
I think portability is best understood as a measure of how difficult/expensive it is to port a typical program in that language to a new platform, because that's the question which is likely to be relevant in practice.
Re:OpenSSL Security Advisory by jjnoakes on Friday May 06, 2016 @11:28AM (#11644607)
That doesn't define the portability of the language though, that only discusses typical programs. They aren't the same thing at all.

The portability of a language is best understood as how difficult/expensive it is to port a conforming program written in the language in question.

It's easy to confuse the two. But a discussion based on that confusion is not very useful, as you are discovering.

Re:OpenSSL Security Advisory by lmm on Monday May 09, 2016 @11:13AM (#11660400)
> The portability of a language is best understood as how difficult/expensive it is to port a conforming program written in the language in question.

What proportion of the things that are referred to in ordinary, everyday language as "C programs" would you estimate are conforming? Maybe 0.01%? If I'd meant "conforming C code" I would've said "conforming C code".

Writing conforming C is not a realistic choice for most use cases. E.g. there are very few experienced conforming C developers available.

Re:OpenSSL Security Advisory by jjnoakes on Wednesday May 11, 2016 @12:50PM (#11676945)
I don't think any of your assertions are true at all.

There are lots of conforming C programs (just look at the huge list of software which compiles on a huge list of platforms).

There are tons of experienced C developers. Who do you think writes all of that conforming software?

And none of this is related to the topic at all.

If you really can't get your head around the simple idea that the portability of the language is different than the portability of some arbitrary program written in the language, then just look at it this way: If you want to write a program in a language, and you pick C, your program will run on more platforms than if you pick Python.

This is true, regardless of any other argument you might raise, simply because Python won't run on a platform until C runs on that platform (since Python is written in C).

We've been over this. Ad nauseum. Please stop trolling.

Re:OpenSSL Security Advisory by lmm on Monday May 16, 2016 @11:14AM (#11706798)
> There are lots of conforming C programs (just look at the huge list of software which compiles on a huge list of platforms).

And look at how much of that list breaks when a new version of GCC introduces a minor improvement in optimization.

> just look at it this way: If you want to write a program in a language, and you pick C, your program will run on more platforms than if you pick Python.

That is the question to ask. And your answer simply isn't true. It will (in the overwhelmingly likely case) run on more platforms if you pick Python. Certainly if you hold costs constant, which is surely the only way to compare. If you're willing to spend unlimited time and effort on portability then your C program will run everywhere, but so will your Python program (since you can just port the Python interpreter).

> This is true, regardless of any other argument you might raise, simply because Python won't run on a platform until C runs on that platform (since Python is written in C).

Not actually true (Jython exists and could run on platforms that don't run C), but it doesn't matter. It is overwhelmingly likely that the Python interpreter will run on more platforms than your C program will.

> We've been over this. Ad nauseum. Please stop trolling.

I'm not trolling. Maybe you are?

Re:OpenSSL Security Advisory by ashitlerferad on Tuesday May 03, 2016 @01:30PM (#11622624)
Exploitation of some of those issues can be prevented using the new RAP GCC plugin by grsecurity. Unfortunately, it is only available to paying customers.

https://grsecurity.net/rap_announce.php https://grsecurity.net/rap_faq.php https://pax.grsecurity.net/docs/PaXTeam-H2HC15-RAP-RIP-ROP.p...

Re:OpenSSL Security Advisory by dfc on Tuesday May 03, 2016 @03:20PM (#11623448)
Does anyone know how much it costs to be a "paying customer" at the individual level? Im not OVH with a sea of rack mounts, I am just interested in covering a handful of machines.
Re:OpenSSL Security Advisory by ashitlerferad on Tuesday May 03, 2016 @11:25PM (#11625940)
Zero idea, but if you get an answer, please put it here and or post the GPL code publicly.
Re:OpenSSL Security Advisory by konceptz on Tuesday May 03, 2016 @12:16PM (#11621951)
I'd only go so far as to agree that vulnerabilities which are bug related maybe _detected_ by static analysis.

Preventing vulnerabilities is an entirely larger problem not addressed by static analysis alone. Architectural security flaws are outside of the scope for static analysis. I'm not trying to nitpick semantics but in this case I think it's important to understand that, in this context, prevention and fixes as well as bugs and flaws need to be differentiated.