The first CVE vulnerability has been assigned to a piece of the Linux kernel's Rust code.

Greg Kroah-Hartman announced that the first CVE has been assigned to a piece of Rust code within the mainline Linux kernel.

This first CVE for Rust code in the Linux kernel pertains to the Android Binder rewrite in Rust. There is a race condition that can occur due to some noted unsafe Rust code. That code can lead to memory corruption of the previous/next pointers and in turn cause a crash.

all 5 comments

sorted by: hot top controversial new old
[–] 1 point 10 months ago

159 C CVEs released on the same day BTW.

  • source
  • [+] -25 points 10 months ago (3 children)

    race condition ... unsafe... memory corruption of the previous/next pointers... crash.

    I expected this for long enough. I am satisfied. Good. I wait for more.

  • source
  • hideshow 3 child comments
  • [–] 21 points 10 months ago*

    How's the weather up there, on your high horse?

    Rust wasn't meant to be the be-all, end-all solution to safety and soundness; it's meant to be better than the alternatives, confining potential memory safety issues to explicitly-annotated unsafe blocks.

    But, hey. That's okay. With that kind of gloating attitude, I'm sure your code is 100% safe and vulnerability free, too. Just remind me to never step foot anywhere near an industrial system or operating system using it.

  • source
  • parent
  • 46 comments in c/technology@lemmy.world view that post
    [–] 42 points 10 months ago (1 child)

    JavaScript would have prevented this.

  • source
  • hideshow 1 child comment
  • [–] 38 points 10 months ago (1 child)

    Sucks to be the person who made that commit. Genuinely.

  • source
  • hideshow 1 child comment
  • [–] 105 points 10 months ago (10 children)

    No one said rust was invulnerable.

  • source
  • hideshow 10 child comments
  • [–] 80 points 10 months ago (5 children)

    I think the other takeaway here is that it was found in a section marked "unsafe". At the very least, that's a useful tool for the Devs to isolate potential problem areas. Comparing that to a pure C codebase where the problem could be anywhere.

  • source
  • parent
  • hideshow 5 child comments
  • [–] 1 point 10 months ago (2 children)

    The funny part is: the fix does not change the unsafe block at all. The issue is elsewhere in safe rust code.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 4 points 10 months ago*

    No. The issue is that an assumption they make in the unsafe block does not actually always hold true. They changed the safe rust code to strenghten the (incorrect) assumption they made in the first place, because that is way easier than rearchitecting the unsafe part. I.e. if the unsafe part was somehow to be written safely, the mitigation they introduced now would not result in any difference in behaviour, it would be correct behaviour both before and after.

    Tldr: the problem lies in the unsafe part

  • source
  • parent
  • [–] 2 points 10 months ago

    I'll admit, I haven't looked at the code. I would stand by my comment of the unsafe block being a start point.

    Countering that however, what is the difference to just debugging effectively? Not sure. I suppose it's down to the people that identified it and fixed it at the end of the day to say if there was any benefit.

  • source
  • parent
  • [–] -3 points 10 months ago (1 child)

    doesn't change anything if you can't avoid having to write the unsafe parts

  • source
  • parent
  • hideshow 1 child comment
  • [–] 9 points 10 months ago

    It certainly does. It's way simpler to keep up all invariants and to review the few percent lines of code in unsafe blocks than making sure that the 30 million lines of code are free of undefined behavior.

    Is some part of the code it battle tested of course it's complete unreasonable to rewrite it in any language, but if you have to do a major rewrite anyway or write a new component you should definitely use a memory safe language. And no it doesn't matter that there is an unsafe escape hatch because it's literally impossible to write low level kernel stuff or FFI to other languages without unsafe because Rust can't uphold/guarantee the invariants of the hardware itself or the behavior of other languages.

  • source
  • parent
  • [–] 11 points 10 months ago (3 children)

    Boone? There are plenty of fan boys out there that are selling rust like AI, or in other words snake oil.

    Rust obviously has built in securities that C doesn't have, but a shitty coder is a shitty coder and bad QC is bad QC. Now we're seeing the reality of the consequences.

    Rust and/or other memory safe(r) languages are like the future, but hopefully more people are now seeing the cracks. Just look at cloudflare for a prime example.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 7 points 10 months ago (2 children)

    the cloudflare issues were configuration… they have nothing even remotely relayed to any of this

  • source
  • parent
  • hideshow 2 child comments
  • [–] -1 points 10 months ago (1 child)
  • [–] 8 points 10 months ago

    The software had a limit on the size of the feature file that was below its doubled size. That caused the software to fail.

    this is not a rust problem… nor was the original problem of code writing entries to a file multiple times, and nor is the thing that made it worse: propagation of the poisoned file

  • source
  • parent
  • [–] 21 points 10 months ago (1 child)

    Surprised it took so long.

  • source
  • hideshow 1 child comment
  • [–] 14 points 10 months ago (28 children)

    What's the point of rewriting parts of the kernel in unsafe rust?

  • source
  • hideshow 28 child comments
  • [–] 79 points 10 months ago (14 children)

    Because Rust lets you choose when something is unsafe vs writing all unsafe in code all the time:

    Note the other 159 kernel CVEs issued today for fixes in the C portion of the codebase

  • source
  • parent
  • hideshow 14 child comments
  • [–] 3 points 10 months ago (3 children)

    I wonder if this can be adjusted for LoC count in each language

  • source
  • parent
  • hideshow 3 child comments
  • [–] 7 points 10 months ago (2 children)

    Not sure if that's a fair metric yet.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 4 points 10 months ago (9 children)

    Yes same concept as other languages like C#

  • source
  • parent
  • hideshow 9 child comments
  • [–] 8 points 10 months ago (8 children)

    You go ahead and write an OS kernel in C# then.

  • source
  • parent
  • hideshow 8 child comments
  • [–] 9 points 10 months ago (6 children)

    Why the hell would you do that

  • source
  • parent
  • hideshow 6 child comments
  • [–] 4 points 10 months ago (5 children)

    Why would you bring up C# in a thread about kernel programming?

  • source
  • parent
  • hideshow 5 child comments
  • [–] 2 points 10 months ago* (4 children)

    Talking about how unsafe is not some new fancy rust feature and exists in other languages. Your comment makes it sound like the choice is some new wild computing concept.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 2 points 10 months ago

    Memory safe languages that are not garbage collected are not all that common. Ada and Rust are two examples.

    With great care C++ and zig can be.

    I'm sure there's a good reason a lot of the big players and the community at large have picked up rust though. Docs, error messages, cargo community etc.

    I would argue that Rust does bring a lot to the table. I certainly would never code in C for work but I'll happily reach for Rust.

  • source
  • parent
  • [–] 1 point 10 months ago (2 children)

    Bruh do you actually not get it. The point of rust is that its memory safe(with a huge grain of salt in the case of low level programming) and is a language you can write kernels in. Youre not gonna write a kernel in C# so it doesnt really matter for a discussion about kernels.

  • source
  • parent
  • hideshow 2 child comments
  • [–] [S] 4 points 10 months ago (10 children)

    Because Rust is the popular thing in FOSS/Linux at the moment.

  • source
  • parent
  • hideshow 10 child comments
  • [–] 18 points 10 months ago (9 children)

    For memory safety, which is not unsafe rust

  • source
  • parent
  • hideshow 9 child comments
  • [–] [S] 9 points 10 months ago (8 children)

    You say that. But the CVE is a memory corruption bug.

  • source
  • parent
  • hideshow 8 child comments
  • [–] 48 points 10 months ago (1 child)

    Which is worse?

    • Entire driver written in a non memory safe language?
    • The interface to the rest of the kernel is marked as unsafe and then the other X percent is safe from memory corruption?

    Surely if X > 0 then this is still a net improvement?

  • source
  • parent
  • hideshow 1 child comment
  • [–] 2 points 10 months ago (4 children)

    You don't understand what unsafe means

  • source
  • parent
  • hideshow 4 child comments
  • [–] 8 points 10 months ago* (last edited 10 months ago) (3 children)

    Rust by default will not allow you to make certain kinds of errora, which is great. But if you are doing something advanced, down at the hardware level [see below], you might need to disable those defaults in order to write the code you need. This is what people mean by "unsafe" -- lacking the normal memory safeguards.

    With careful coding, "unsafe rust" or normal C, for that matter, can be free of bugs and safe. But if programmers make a mistake, vulnerabilities can creep in more easily in the unsafe sections.

    Is that basically it?

  • source
  • parent
  • hideshow 3 child comments
  • [–] 7 points 10 months ago (2 children)

    But if you are doing something advanced, down at the hardware level

    This part is wrong. Otherwise yes correct.

    The “unsafe” code in rust is allowed to access memory locations in ways that skip the compiler’s check and guarantee that that memory location has valid data. They programmer is on their own to ensure that.

    Which as you say is just the normal state of affairs for all C code.

    This is needed not because of hardware access but just because sometimes the proof that the access is safe is beyond what the compiler is able to represent.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 1 point 10 months ago (1 child)

    Thank you for the correction, I'll edit my comment.

    sometimes the proof that the access is

    safe is bevond what the compiler is able to represent

    Could you say a few more words about this? In what situations do you have to write 'unsafe-tagged' code blocks? Could this be changed by improvements to the compiler? Or is it necessitated by the type of task being done by the code?

  • source
  • parent
  • hideshow 1 child comment
  • 2 comments in c/technology@lemmy.zip view that post
    [–] 14 points 10 months ago

    It leads to a crash, not RCE or anything security-related

  • source
  • [–] 3 points 10 months ago

    A link in the middle of the article leads to a rather detailed explanation of why they're rewriting binder. Pretty decent read.

  • source