this post was submitted on 31 May 2024
294 points (98.4% liked)

Linux

46775 readers
1770 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 38 points 2 months ago (8 children)

Yet another security issue that Rust would solve.

[–] [email protected] 59 points 2 months ago (3 children)

Oh, we heard, Rust is the greatest invention since sliced bread. We heard it already. Like 65534 times.

[–] [email protected] 53 points 2 months ago (2 children)

Like 65534 times.

So close to full 16-bit max. So close...

[–] [email protected] 15 points 2 months ago

Yeah I figured he was going purposely for a memory overflow

[–] [email protected] 8 points 2 months ago (1 children)

Yeah we only need 2 brainRusts more to start seeing some fun.

[–] [email protected] 2 points 2 months ago

Gah. I should have stated "I see what you did there." instead. ;)

[–] [email protected] 25 points 2 months ago (5 children)

Aviation, Health, Space and Car industry have only 3 certified languages that they use. Ada, C and C++. Ada is dying because there are way less young engineers who want to invest their future learning it. Then there is C and C++ but they dont offer memory safety and its really hard to master and its really hard and long (thats what she said) to certify the code when being audited for safety by a tier company.

Rust solves by default (no need to review) like 2/3 of the standard requirements those industries have and are that found in C and C++. Rust will soon be approved in this group by the car industry.

Im not a rust fan, but I have 3 things to say about rust.

  • Its fun to program like C++ having the peace of mind knowing the compiler is there helping.
  • You dont feel like youre defusing a bomb like when writing C.
  • Even though its a fun language to write, its also really hard to master, itd say 2 years to be really proficient with it. There is just so much knowledge.
[–] [email protected] 12 points 2 months ago

Aviation, Health, Space and Car industry have only 3 certified languages that they use. Ada, C and C++.

Rust is automotive certified since over half a year. https://ferrous-systems.com/blog/officially-qualified-ferrocene

[–] [email protected] 4 points 2 months ago (1 children)

Could you explain the "no need to review" part? I do keep hearing good things about Rust.

[–] [email protected] 5 points 2 months ago* (last edited 2 months ago) (2 children)

These industries hire third parties to review c and c++ line per line to make sure it's memory safe. Rust by default forces you to write memory safe code, otherwise it won't even compile. The rust compiler tells where is the problem and what it expects. No only for basic Type errors but also for concurrent code.

load more comments (2 replies)
load more comments (3 replies)
[–] [email protected] 13 points 2 months ago (1 children)

I hate it when people talk about new technologies 🤬

[–] [email protected] 10 points 2 months ago (1 children)

Same. We should head back to ICQ!

[–] [email protected] 8 points 2 months ago (1 children)

eh, still beats Discord as far as I'm concerned

[–] [email protected] 4 points 2 months ago (2 children)

Yeah, but no one will hop on irc or mumble to hang out these days.

[–] [email protected] 2 points 2 months ago

Not with that attitude!

I'm already on IRC and XMPP. be the change you want to see.

[–] [email protected] 1 points 2 months ago

God I miss the IRC days

[–] [email protected] 28 points 2 months ago (3 children)

Yet another problem that actually updating your shit - which is trivially easy on enterprise Linux - would fix.

It's part of the 95% of problems solved by actually updating your enterprise Linux host.

[–] [email protected] 5 points 2 months ago (2 children)

unattended-upgrades and forget about it

[–] [email protected] 4 points 2 months ago (1 children)

oops, our third party application broke again

[–] [email protected] 5 points 2 months ago

Never happened to me when set to security.

[–] [email protected] 2 points 2 months ago (1 children)

Tell me more (for real, I'm unfamiliar).

[–] [email protected] 3 points 2 months ago* (last edited 2 months ago) (1 children)

Its a Debian package that automatically upgraded packages (if they have pending security updates)

[–] [email protected] 3 points 2 months ago

I run mine manually, good to know. Will check it out.

[–] [email protected] 1 points 2 months ago (1 children)

That requires that the patches be in the repos. With RHEL it might be a few months

[–] fruitycoder 2 points 2 months ago

Normally security patches are pretty good on same day releases as the CVE if available.

[–] [email protected] 1 points 2 months ago (1 children)

But then I can't screenshot my 7 years of uptime

[–] [email protected] 1 points 2 months ago

Just live patch

Although it is better to have some sort of HA system.

[–] [email protected] 10 points 2 months ago (2 children)

Any software can have security issues, including ones written in rust. Just because C/C++ allows one to shoot oneself in the foot doesn't mean it's something that's commonly allowed by anyone with any skill, it's just a bug like anything else. I swear, people advocating rust believe that it's something intrinsic in C/C++ that allows such a thing regardless of what a developer does, and it's getting tiresome.

[–] [email protected] 10 points 2 months ago (1 children)

Of course a good developer can avoid these problems for the most part. The point is that we want the bad developers to be forced to do things a safe way by default.

[–] [email protected] 7 points 2 months ago

Even good developers make mistakes. It's really nice to catch these mistakes at compile time.

[–] [email protected] 4 points 2 months ago (3 children)

But it is, do you not understand what rust brings compared to these two languages ?

load more comments (3 replies)
[–] [email protected] 10 points 2 months ago (1 children)

There are still slight advantages to C that probably will make some devs stick to it in specific cases

[–] gravitas_deficiency 16 points 2 months ago

But this isn’t one of them

[–] [email protected] 5 points 2 months ago (1 children)

Serious question, how would using rust avoid this? Rust still has reference types in the background, right? Still has a way to put stuff on the heap too? Those are the only 2 requirements for reusing memory bugs

[–] [email protected] 30 points 2 months ago (6 children)

This is a use-after-free, which should be impossible in safe Rust due to the borrow checker. The only way for this to happen would be incorrect unsafe code (still possible, but dramatically reduced code surface to worry about) or a compiler bug. To allocate heap space in safe Rust, you have to use types provided by the language like Box, Rc, Vec, etc. To free that space (in Rust terminology, dropping it by using drop() or letting it go out of scope) you must be the owner of it and there may be current borrows (i.e. no references may exist). Once the variable is droped, the variable is dead so accessing it is a compiler error, and the compiler/std handles freeing the memory.

There's some extra semantics to some of that but that's pretty much it. These kind of memory bugs are basically Rust's raison d'etre - it's been carefully designed to make most memory bugs impossible without using unsafe. If you'd like more information I'd be happy to provide!

[–] [email protected] 1 points 2 months ago (3 children)

Thanks for the response. Ive heard of rust's compiler being very smart and checking a ton of stuff. Its good thing it does, but i feel like there are things that can cause this issues rust cant catch. Cant put my finger on it.
What would rust do if you have a class A create something on the heap, and it passes this variable ( by ref ? ) to class B, which saves the value into a private variable in class B. Class A gets out of scope, and would be cleaned up. What it put on the heap would be cleaned up, but class B still has a reference(?) to the value on the heap, no? How would rust handle such a case?

[–] [email protected] 5 points 2 months ago* (last edited 2 months ago) (1 children)

You use lifetimes to annotate parameters and return values in order to tell the compiler about how long things must last for your function to be valid. You can link a specific input with the output, or explicitly separate them. If you don't give lifetimes the language uses some basic rules to do it for you. If it can't, eg it's ambiguous, then it's a compile error and you need to do it manually.

It's one of the harder concepts of rust to explain succinctly. But imagine you had a function that took strA and strB, used strB to find a subsection of strA, and then return a slice of strA. That slice is tied to strA. You would use 'a annotation for strA and the return value, and 'b for strB.

Rust compiler will detect the lifetime being shorter than expected.


Also, ownership semantics. Think c++ move semantics. Only one person is left with a good value, the previous owners just have garbage data they can't use anymore. If you created a thing on the heap and then gave it away, you wouldn't have it anymore to free at the end. If you want to have "multiple owners" then you need ref counting and such, which also stops this problem of premature freeing.


Edit: one more thing: reference rules. You can have many read-only references to a thing, or one mutable reference. Unless you're doing crazy things, the compiler simply won't let you have references to a thing, and then via one of those references free that thing, thereby invalidating the other references.

[–] [email protected] 1 points 2 months ago* (last edited 2 months ago) (1 children)

Thats interresting, thanks! Stuff for me to look into!
I also think halfway through the conversation i might have given the impression i was talking about pointers, while it was not my intention to do so. That said, the readonly/mutable reference thing is very interresting!
Ill look into what rust does/has that is like the following psuedocode :

DataBaseUser variable1 = GetDataBaseUser(20);
userService.Users.Add(variable1);
variable1 = null; // or free?
[end of function scope here, reference to heap now in list ]

[–] [email protected] 1 points 2 months ago* (last edited 2 months ago)

No problem. I'm no guru and I'm currently on Zig but I think learning some Rust is a really fast way to hone skills that are implied by other languages.

[–] [email protected] 3 points 2 months ago

It's not like C where you have control over when you can make references to data. The compiler will stop you from making references in the cases where a memory bug would be possible.

[–] [email protected] 2 points 2 months ago* (last edited 2 months ago) (2 children)

Rust simply doesn't allow you to have references to data that goes out of scope (unless previously mentioned hoops are jumped through such as an explicitly declared unsafe block). It's checked at compile time. You will never be able to compile the program.

Rust isn't C. Rust isn't C++. The memory-safe-ness of it is also not magic, it's a series of checks in the compiler.

load more comments (2 replies)
load more comments (5 replies)
[–] [email protected] 4 points 2 months ago

The problem is bad programmers. You can write good C code but it takes more effort and security checking. You also can write vulnerable and sloppy Rust code.

load more comments (2 replies)