Better HN
topnewbestaskshowjobs
Log inSign up

staticassertion

13,486 karma · joined Jun 1, 2016 (10y ago) · 4,896 submissions

@insanitybit
Submissions

comment 9y ago · link · parent

It's hard to emphasize the auditability enough. With auditing a C/C++ codebase, in my experience, you rely a lot on intuition. "Well, there's parsing done here, so I'll focus my efforts" or "Historically we've had a lot of CVEs from this part of code so I'll start there".

I'm not a professional RE so my experience is limited, but when I went looking for vulns that's how I went about it, and I think that's generally the case.

With rust there's significantly less guesswork. That parser doesn't use unsafe? OK, let's start elsewhere. That seemingly innocent code uses unsafe? Great, check that out.

You can grep for vulnerabilities, basically.

comment 9y ago · link · parent

I've also found this to be a really good approach to unsafe. Declare why something is actually safe and you may realize it isn't. It also helps when writing tests to assert safety - you have a comment explaining exactly the invariants you need to test.

comment 9y ago · link · parent

> So FF might actually be slower. It's definitely not noticeably faster than Chrome.

Yep, on some pages, on some benchmarks, it can go either way. I think this more brings Firefox to a competitive place, and shows the potential for the project Quantum - there's much more to come, webrender in particular.

> Both of those things can be counted in Chrome's favor as well.

Totally. Whether one browser is more secure than another is a complicated topic.

comment 9y ago · link · parent

> just as I don't install every package available in OS just in case I'll need later it.

But your OS does come with lots of packages and features you may not use.

comment 9y ago · link · parent

> ren't going to be rewritten because it would take a decade to do.

Semi-related question - does anyone know what that would look like? Like if someone were to rewrite v8/Tracemonkey from scratch, what's the cutting edge research on this?

comment 9y ago · link · parent

> why would it make people switch back to FF? because it's 1% faster than chrome?

General responsiveness is definitely something I consider when choosing any tool. 1%? I don't think that's a real number. It can be much faster, especially since this is just one of many-to-come improvements.

When you have lots of tabs open, lots of extensions, etc, pages can actually be quite slow to render. As webpages become more complex (I'm thinking about my company's web-app product) or as we start leveraging renderers for more than just web content, performance is more important.

Beyond that, given mobile devices low memory usage, strong energy requirements, and insane popularity, it makes sense to care about how well we utilize resources in our applications.

> FF had its selling point to power users which is why i'm currently browsing from ff.

"Power users" like to believe this, and they're certainly the loudest, but I don't think it's true. Most people are not power users, and I think it stands to reason that most Firefox users are not "power users". Many are just regular people using their browser to get to Facebook, a site that loads a huge a mount of content. Things like "I visited a website and got hacked, I hate firefox now" or "Ugh firefox hung on facebook" or "ugh instagram is taking forever to load" matter a lot to these users.

> Now there is no reason at all to use it.

Well, performance is one reason. Security could easily be another - as Firefox moves to a memory safe language we can expect to see lower critical bug rates. I know for a lot of the older people whose computers I've set up "I don't want to get viruses" is a huge ask from them. So moving your renderer to a memory safe language is a nice win there.

Most users extensions are likely to continue to work with the new Firefox. Maybe not the 'power users', who almost by definition are a minority, but most.

comment 9y ago · link · parent

Lots of extensions are waiting for the stable release before updating.

comment 9y ago · link · parent

I really doubt that that feature has any performance impact. It looks like a bunch of counters.

comment 9y ago · link · parent

Is that really such an improvement?

comment 9y ago · link · parent

What would that look like? How would this prevent me from returning a pointer to a stack frame that no longer exists, just for example? Clearly undefined behavior, but C doesn't seem capable of expressing this safely, with or without the compiler's help?

comment 9y ago · link · parent

That's the thing, it's feels impossible to generalize since this can get pretty arbitrary. The size of the data, how sorted the data already is, what you're processing, etc.

comment 9y ago · link · parent

I wouldn't expect the cost to offset the impact of having to sort first. But, if you need to process the same data many times, it may be a good idea to sort it up front.

comment 9y ago · link · parent

You wouldn't have to rewrite Adobe. You could rewrite one component of it (0 cost FFI). That's fair more reasonable. I think Servo is proving that Rust has a lot of potential for slowly replacing a C++ codebase, piece by piece.

comment 9y ago · link · parent

> In your example, the cause of the collapse would be that developer drove a tank onto the bridge and didn't bother to check the weight limits beforehand.

I don't see how, at all, and you haven't addressed how this somehow makes the C++ developer different from an engineer.

I think your analogy is absolutely imprecise.

And the people on the bridge aren't going to care.

> If you forgot to initialise the variable before using it - it's your problem, not the problem of the language.

Wrong! It's very clearly not the developer's problem, because they don't take responsibility. It's the end user's problem, because they're the ones who get hacked.

> It is well documented, it is expected

Oh, please. As if any C++ developer can spot every instance of UB.

> it is there for a good reason

Is it? This is an unfounded statement. Is there ever a good reason to read from an uninitialized variable? It's UB, so it seems like the language is telling you explicitly that it is not a good idea. But the language gives you not way of formally verifying that you don't.

> And if you are running into this issue all the time, perhaps C++ is not for you.

Alternatively, perhaps C++ is not for any human, as it's clearly far too complicated to reason about.

comment 9y ago · link · parent

Really? You accept responsibility? In what way has any developer ever accepted responsibility for bad code? When an engineer is negligent and a bridge collapses, they are responsible - there's a whole system of insurance around it. When a developer is negligent and user data is compromised, do they take responsibility?

No.

Should the developers of C++ take responsibility? Or just the consumers of the language? Why is one different from the other?

This entire argument that the users of C++ are at fault for everything is absurd. Users suffer for it, and no one truly takes responsibility.

comment 9y ago · link · parent

> C++ shows that in theory you can fix any flaw in an existing programming language as long as you maintain backwards compatibility by simply adding more features.

I feel like C++ proves exactly that you can't.

comment 9y ago · link · parent

Sure...

* Most developers are not writing data structures, so optimizing for that seems unnecessary.

* There is work and research going into verifying unsafe code

* I think historically we can see that most memory safety vulnerabilities are not going to be in some lower level data structure, which is well encapsulated and likely already built by someone else, but in the use of that data structure. In particular - sharing references and also invalidating data safely without leaving references to that data. Rust helps you here, and this seems like the far better target.

* Even if your rust code uses unsafe, you still have benefits - you know where to audit for unsafety, you know where to pay extra close attention, and you can still write a large portion of your code in safe rust.

comment 9y ago · link · parent

Sorry, I should have said array OOB.

comment 9y ago · link · parent

And integer out of bounds, and (most) segfaults, and data races, etc

comment 9y ago · link · parent

People will write awful rust code. The impact of this will not be an attacker's ability to completely take over a system. That's a level of "awful" I'll take.

comment 9y ago · link · parent

Cool, yeah I see what you're saying - thanks.

comment 9y ago · link · parent

What part of actors are hard to reason about?

comment 9y ago · link · parent

> and cloudbleed was their fault, not ragels

Meaningless statement - 'fault' in these discussions is impossible to objectively attribute. Is every vulnerability the fault of the developer writing the code, or the tool that facilitated the code? Some would argue the former, some the latter.

The end result is the same - using these tools you can produce vulnerabilities, and your users get exploited all the same. So is fault really important?

> Writing a parser in a memory-safe language does nothing for it's correctness, as memory safety is not the only security problem. One should use a domain specific language, as simplicity is very important for safety.

You have two statements here - one is that memory safety is no the end of safety, one is that simplicity is important to safety beyond memory safety.

The first feels... weak. No kidding - security encompasses more than memory safety. But eliminating memory safety issues limits what you have to worry about.

As for simplicity leading to security, this isn't a supported argument. But as for encoding semantic security issues into your program (security issues outside of memory safety), I would argue a strong type system is the right way to go here, something Rust certainly provides.

> edit: Rust is the new systemd, full of fanboys pushing it forcefully on others (or, as they say, "gently nudging"). I have not much to say against rust itself (except that it is not for "systems programming"), but the fanboys are idiots.

blah blah blah, literally just vapor at this point, not worth addressing.

comment 9y ago · link · parent

This is always going to lead to the same place - whether it's the developer's fault or the tool's.

The author of this post wants uncompromising safety, ragel does not allow for that - programmer error can introduce memory unsafety. They even explicitly call out Cloudbleed.

comment 9y ago · link · parent

I'm not trying to be rude or smug. I'm trying to extract the meaning from their statement that I feel is conveyed. When you strip down what they're saying, to me, it's just "new is worse".

comment 9y ago · link · parent

"It's the way we've always done it" is all I hear.

comment 9y ago · link · parent

Not stupid at all, and something that a lot of people ask.

It's not really like that - with reference counting you sort of have multiple 'owners' of a variable, and they all get to 'free' that memory except that 'free' just decrements a counter.

With rust there is a very clear owner at all points - you always know that your code in one spot owns the memory, and no other code does. There may be references handed out but those are very clearly distinct - that is, by looking at the code you can see "yes, I own this" or "yes, I'm borrowing this".

Now, with borrowing it's a little bit more like reference counting, but it's really just scope based. We know that the references are valid for some scope, and after that scope they are not. There's no internal counting or anything like that in the compiler as far as I am aware.

comment 9y ago · link · parent

Thanks, unfortunately I can't edit the post. :(
1
155156157
164