Live data from Hacker News

Memory Safety

memorysafety.org

31–40 of 157 posts

Re: Memory Safety

#31

[flagged]

> codebase search for `unsafe`

> Is this website promoting Rust, memory unsafety and insecurity?

What a joke of a question. The website prioritizes programs with 98% safe code over programs with 0% safe code. Does that mean it's "promoting memory unsafety" because it's not demanding 100%? No.

> Nor is it guaranteed to be secure.

Nothing is, and nobody is claiming that.

Re: Memory Safety

#33

[flagged]

Firstly, the existence of unsafe does not inherently mean the code isn’t memory safe.

Secondly, memory safety does not mean no security vulnerabilities. What it does mean is that 80% of the most commonly found vulnerabilities (as gathered through statistical analysis of field failures) are gone. It means that the price for finding a vulnerability is higher.

And also sudo-rs precisely removes a lot of complexity that’s the source of vulnerabilities in normal sudo. There may be better approaches but it’s specifically not targeting 100% compat because sudo is horribly designed right now.

TLDR: this is a lazy knee jerk critique. Please do better in the future.

Re: Memory Safety

#34

Earlier quoted context omitted.

C and C++ as defined by their current standards are memory unsafe. You may argue that some specific implementations manage to stay as memory safe as they can get away with, but even then, features like union prevents a fully memory-safe implementation.

> C and C++ as defined by their current standards are memory unsafe. I don’t think the spec says one way or another (but please correct me if you find verbiage indicating that the language must be memory unsafe). It’s possible to make the whole language memory safe, including unions. It’s tricky, but possible. Someone else mentioned Fil-C but Fil-C builds on a lot of prior art. The fact that C and C++ can be memory s…

By definition, C and C++ are memory safe as long as you follow the rules. The problem is that the rules cannot be automatically checked and in practice are the source of unenumerable issues from straight up bugs to subtle standards violations that trigger the optimizer to rewrite your code into what you didn’t intend.

But yes, fil-c is a huge improvement (afaik though it doesn’t solve the UB problem - it just guarantees you can’t have a memory safety issue as a result)

Re: Memory Safety

#35

[flagged]

> codebase search for `unsafe` > Is this website promoting Rust, memory unsafety and insecurity? What a joke of a question. The website prioritizes programs with 98% safe code over programs with 0% safe code. Does that mean it's "promoting memory unsafety" because it's not demanding 100%? No. > Nor is it guaranteed to be secure. Nothing is, and nobody is claiming that.

> The website prioritizes programs with 98% safe code over programs with 0% safe code.

Please explain this section of the Rustonomicon.

https://doc.rust-lang.org/nomicon/working-with-unsafe.html

> This code is 100% Safe Rust but it is also completely unsound. Changing the capacity violates the invariants of Vec (that cap reflects the allocated space in the Vec). This is not something the rest of Vec can guard against. It has to trust the capacity field because there's no way to verify it.

> Because it relies on invariants of a struct field, this unsafe code does more than pollute a whole function: it pollutes a whole module. Generally, the only bullet-proof way to limit the scope of unsafe code is at the module boundary with privacy.

If 2% code means that, wildly spitballing, 50% code has to be manually reviewed, it's not quite as impressive.

And it might be worse regarding memory safety than the "status quo" if one accepts the assumption that unsafe Rust is harder than C and C++, as many Rust developers do.

https://www.reddit.com/r/rust/comments/1amlfdj/comment/kpmb2...

> It may be even less safe because of the strong aliasing rules. That is, it may be harder to write correct unsafe {} Rust than correct C. Only use unsafe {} when absolutely needed.

https://chadaustin.me/2024/10/intrusive-linked-list-in-rust/

Re: Memory Safety

#36

[flagged]

If you're writing C/C++ and you don't care about memory safety, you're taking one of a few possible positions:

1. "I don't care what my program does."

Why write it though?

2. "I don't care what the standard says, I've put text into a compiler and it gave me a binary that does the thing."

What if you want to put the same text into a different compiler in the future, or the same compiler again? Are you certain the binary is going to continue doing the thing? Have you even fully tested the binary?

3. "I use a special runtime that makes memory unsafety defined again."

One, I don't believe you unless you're part of a very small group of people and two, why are you accepting the serious drawbacks (performance, process death, all the broader issues of UB) that come with this?

It's genuinely hard for me to understand why you wouldn't think memory safety is important Don't you want to write code that's portable and correct? Don't you want to execute other people's programs and trust they won't segfault? Doesn't it frustrate you that the language committees have spent years refusing to address even the lowest-hanging fruit?

Re: Memory Safety

#37
post #2

This site is curious in that in incorrectly categorizes go as memory safe. Perhaps in part because the sponsors are invested in using go and benefit from its inclusion in a list of memory safe languages.

If we're being extremely strict, Python probably also shouldn't be on that list because the CPython runtime is written in C and has had issues with memory safety in the past. Ultimately, "memory safety" is a conversation about what a program is intended to do and what semantics the language guarantees that program will have when executed. For the vast majority of programs, you can be just as confident that your Go an…

No, because then no language would be included, including Rust. Implementation bugs are not treated the same as integral parts of the language as defined by the standard. Python is defined as memory safe.

Re: Memory Safety

#38

[flagged]

Firstly, the existence of unsafe does not inherently mean the code isn’t memory safe. Secondly, memory safety does not mean no security vulnerabilities. What it does mean is that 80% of the most commonly found vulnerabilities (as gathered through statistical analysis of field failures) are gone. It means that the price for finding a vulnerability is higher. And also sudo-rs precisely removes a lot of complexity that’…

> Firstly, the existence of unsafe does not inherently mean the code isn’t memory safe.

That does not contradict what I wrote.

I am confounded by your post, since an article with vulnerabilities in sudo-rs was posted.

You can also read

https://news.ycombinator.com/item?id=46388181

> TLDR: this is a lazy knee jerk critique. Please do better in the future.

TL;DR: This is a lazy knee jerk critique. Please do better in the future.

Re: Memory Safety

#39

Earlier quoted context omitted.

> codebase search for `unsafe` > Is this website promoting Rust, memory unsafety and insecurity? What a joke of a question. The website prioritizes programs with 98% safe code over programs with 0% safe code. Does that mean it's "promoting memory unsafety" because it's not demanding 100%? No. > Nor is it guaranteed to be secure. Nothing is, and nobody is claiming that.

> The website prioritizes programs with 98% safe code over programs with 0% safe code. Please explain this section of the Rustonomicon. https://doc.rust-lang.org/nomicon/working-with-unsafe.html > This code is 100% Safe Rust but it is also completely unsound. Changing the capacity violates the invariants of Vec (that cap reflects the allocated space in the Vec). This is not something the rest of Vec can guard against…

If you're letting safe code in the same module as unsafe code mess with invariants, then the whole module needs to be verified by hand, and should be kept as minimal as feasible. Anything outside the module doesn't need to be verified by hand. "Modules with unsafe" should be a lot lot less than 50%. Your spitball is not a fit to real code.

When I wrote "98% safe code" I meant the code that can be automatically verified by the compiler. I wish the terminology was better.

Post reply on HN