Re:Microsoft: Rust Is the Industry’s ‘Best Chance’ at Safe S...
by phkahler on Saturday June 13, 2020 @02:18PM
(#23511417)
What about a Rust to C translator? It would produce "safe" C right?
[ Parent
| on HN ]
Re:Microsoft: Rust Is the Industry’s ‘Best Chance’ at Safe S...
by zozbot234 on Saturday June 13, 2020 @02:26PM
(#23511484)
You would also need to comprehensively annotate the Linux C headers in order to provide the information that Rust expects (e.g. for each ptr instance whether it's a "raw" pointer, a shared/exclusive reference or a piece of "owned" data, whether it can be NULL etc. etc.). This might actually get accepted upstream though. Having the kernel-build itself depend on Rust could be far more problematic, given e.g. the variety of hardware that Linux must support.
Re:Microsoft: Rust Is the Industry’s ‘Best Chance’ at Safe S...
by ufmace on Saturday June 13, 2020 @04:36PM
(#23512467)
I would think such a thing would be more like "compiling" rust to C. As in the C code would have no means to maintain most of the safety guarantees, rather they would be verified at compile time, and the produced C would be meant to be used unchanged. So as long as nobody ever edits the C manually, it would still presumably be safe.
Re:Microsoft: Rust Is the Industry’s ‘Best Chance’ at Safe S...
by phkahler on Saturday June 13, 2020 @06:11PM
(#23513254)
That's what I really meant. Write it in Rust but then output C instead of ASM. The parent is right though. A component/driver would need to use the C headers from the Rust side.
Re:Microsoft: Rust Is the Industry’s ‘Best Chance’ at Safe S...
by TheDesolate0 on Saturday June 13, 2020 @02:37PM
(#23511579)
Not only that, but Rust depends on LLVM.
Re:Microsoft: Rust Is the Industry’s ‘Best Chance’ at Safe S...
by dijit on Saturday June 13, 2020 @03:18PM
(#23511908)
Last time I looked at this comment it was flagged [dead]; I'm glad someone was able to remedy that as I was unable to upvote.
I think this is a good criticism, but might not be true forever and is certainly something to keep in mind.
As I said in the GP, Rust will not be upstreamed into the kernel- this is one of the reasons why.
Re:Microsoft: Rust Is the Industry’s ‘Best Chance’ at Safe S...
by kbenson on Saturday June 13, 2020 @04:50PM
(#23512592)
If a comment is dead that you think is worthwhile, you can follow the permalink to it and vouch for it. I imagine that feature is gated behind some point threshold, but my guess is whatever that threshold is you're past it.
Re:Microsoft: Rust Is the Industry’s ‘Best Chance’ at Safe S...
by dijit on Sunday June 14, 2020 @02:36PM
(#23520052)
Oh, nice, thanks for that. :)
Re:Microsoft: Rust Is the Industry’s ‘Best Chance’ at Safe S...
by saagarjha on Saturday June 13, 2020 @02:52PM
(#23511701)
It doesn't have to, but yes, it currently pretty much requires LLVM.
Re:Microsoft: Rust Is the Industry’s ‘Best Chance’ at Safe S...
by 6c696e7578 on Saturday June 13, 2020 @02:44PM
(#23511636)
https://lwn.net/Articles/797828/
Perhaps the way to do it is to rewrite common bits that get CVEs, just so it doesn't happen again.
Re:Microsoft: Rust Is the Industry’s ‘Best Chance’ at Safe S...
by arcticbull on Saturday June 13, 2020 @02:27PM
(#23511489)
The output of the translator would be right, but messy, and someone would have to go back and clean it up. Doing that work would almost certainly introduce bugs. How many, and whether it outweighs is the question.
Re:Microsoft: Rust Is the Industry’s ‘Best Chance’ at Safe S...
by gfs on Saturday June 13, 2020 @03:26PM
(#23511972)
There is a lot of work being done on a translator now [0]. However, the goal is to translate C to equivalent Rust and then allow developers to intervene to migrate to safe Rust.
[0]: https://c2rust.com
EDIT: Oops, read the parent comment backwards.