r/programming • • Feb 20 '25

Google's Shift to Rust Programming Cuts Android Memory Vulnerabilities by 68%

https://thehackernews.com/2024/09/googles-shift-to-rust-programming-cuts.html
3.4k Upvotes

475 comments sorted by

View all comments

70

u/zugi Feb 20 '25

Transitioning to Rust, from what?

It's popular to bash C++, but straight C is where simple string concatenation introduces vulnerabilities if not done right. I'd be curious to see the analysis of those vulnerabilities in the first place.

55

u/websnarf Feb 20 '25

Google's entire codebase is C++, Java, and Python. Aside from the BIOSes, there is no raw C in their codebase at all.

0

u/[deleted] Feb 21 '25

[deleted]

13

u/currentscurrents Feb 21 '25

It is almost impossible to interface with any OS primitives using pure C++

Wait, why?

23

u/New_Enthusiasm9053 Feb 21 '25

Maybe he means because you need the C ABI for like Windows but idk. I think he's wrong, you can directly call syscalls on posix systems without needing C at all because it's a stable interface and for windows your language just needs to use the C calling convention which also doesn't require C.

0

u/[deleted] Feb 21 '25

[deleted]

0

u/New_Enthusiasm9053 Feb 21 '25

No that's simply not true. Posix syscalls are a hardware level interface, there's a C wrapper for them which is what most people use but it's not required. Yes after the syscall triggers a switch into the kernel there's C being ran but that's only because the OS is in C. 

I have personally written a print to stdout function using machine code on Linux and it works as expected. 

I don't mean assembly, I really mean directly writing out bytes to a file and then running it with no linker or assembler involved and certainly no C.

2

u/steveklabnik1 Feb 21 '25

This is true of Linux but not unices generally. Heck, OpenBSD will check to make sure a syscall originates from within libc and actively error if you try to make the calls yourself.

1

u/New_Enthusiasm9053 Feb 21 '25

That's certainly an interesting choice lol. I'll be sure to not try and write a compiler on BSD then since that would make initial development a pain lol. 

It doesn't change that syscall is hardware level, and I suspect it'd be possible to read the BSD source code and do whatever they're doing to bypass it since you won't have switched privilege level yet.

Do you happen to have any good links on the topic? 

Also are you The Steve Klabnik?

3

u/steveklabnik1 Feb 21 '25

It doesn't change that syscall is hardware level,

I don't know what you mean by "hardware level", syscalls are implemented in software.

I suspect it'd be possible to read the BSD source code and do whatever they're doing to bypass

There's nothing to bypass. When you're the kernel, you're the one implementing the syscalls, not calling them.

Do you happen to have any good links on the topic?

Here's one about openbsd: https://lwn.net/Articles/806776/

Fuchsia also does something similar: https://fuchsia.dev/fuchsia-src/concepts/kernel/vdso#enforcement

Also are you The Steve Klabnik?

Yes :)

→ More replies (0)