News for hackers. Stuff that matters.
Re:Memory Safe Languages in Android 13 by lolinder on Thursday December 01, 2022 @03:15PM (#33822075)
Their notes about vulnerability severity are particularly interesting.

Defenders of C/C++ frequently note that memory safety bugs aren't a significant percentage of the total bug count, and argue that this means it's not worth the hassle of switching to a new language.

Google's data suggests that while this is true, almost all severe vulnerabilities are memory-safety related. Their switch to memory-safe languages has led to a dramatic decrease in critical-severity and remotely-exploitable vulnerabilities even as the total number of vulnerabilities has remained steady.

Re:Memory Safe Languages in Android 13 by yosefk on Thursday December 01, 2022 @04:30PM (#33823091)
It's even worse. The majority, not of all bugs, but all vulnerabilities (of all severities) do come from memory safety bugs. TFA: "For more than a decade, memory safety vulnerabilities have consistently represented more than 65% of vulnerabilities across products, and across the industry."

On top of that, memory safety vulnerabilities are disproportionately high severity: "Memory safety vulnerabilities disproportionately represent our most severe vulnerabilities. In 2022, despite only representing 36% of vulnerabilities in the security bulletin (NOTE: down to 36% from 65% because of moving from C++ to Rust and other memory safe languages), memory-safety vulnerabilities accounted for 86% of our critical severity security vulnerabilities, our highest rating, and 89% of our remotely exploitable vulnerabilities. Over the past few years, memory safety vulnerabilities have accounted for 78% of confirmed exploited “in-the-wild” vulnerabilities on Android devices."

Re:Memory Safe Languages in Android 13 by p-e-w on Thursday December 01, 2022 @11:09PM (#33826664)
> NOTE: down to 36% from 65% because of moving from C++ to Rust and other memory safe languages

Imagine if in any other field, a process or technology were developed that cuts the number of high-severity issues in half.

For example, a modification to the standard anesthesia protocols that demonstrably reduces anesthesia-related fatalities by 50% in clinical practice.

And now imagine, in reaction to this revolutionary development, thousands of anesthesiologists publicly said things like "what matters is not the technique but the skill of the physician", "good anesthesiologists don't make mistakes like that in the first place", "but this new technique takes 1%-3% longer than the previous one" or similar.

Utterly unthinkable, isn't it?

Yet in software engineering, this is exactly what has been happening every day for more than a decade.

Re:Memory Safe Languages in Android 13 by dralley on Thursday December 01, 2022 @11:39PM (#33826856)
Well, not exactly. There have been plenty of advancements in bridge / highrise construction over the past 100 years, but in practice we don't go around tearing down old infrastructure that is still functional because it was built with outdated designs and technologies, even when it could theoretically save lives. Buildings get "grandfathered" into meeting code all of the time.

Software is not terribly different from that. The cost of replacing foundational software is tremendous, much higher than just "adopting a new protocol".

Re:Memory Safe Languages in Android 13 by p-e-w on Thursday December 01, 2022 @11:46PM (#33826896)
This isn't primarily about replacing existing software. There are plenty of engineers that argue for continuing to use memory-unsafe programming languages. New projects written in C are being started every day.

This is the exact equivalent of physicians continuing to use unsafe medical procedures, and what's worse, many of those engineers defend their dangerous practices by claiming there is no real danger in the first place if the programmer is "smart enough".

Re:Memory Safe Languages in Android 13 by jstimpfle on Friday December 02, 2022 @03:36AM (#33828198)
I'm one of those people who still write in C, and I like the experience. I've had a lot of fun, and haven't been burned by it, although statistically it's likely that I will be at some point.

I'm currently not ready to dive into a whole new ecosystem, re-learn all the best practices, and unlearn what's worked very well for me with sometimes no good replacement. Best practice for Rust seems to be to avoid linked lists for example. I don't know what's the safe replacement for memset and memcpy to anonymous data structures (void pointers -- generic code) but I have a sense that it is more painful. The general recommendations seem to be to switch to different, more complicated datastructures with more failure modes, or to put boxes and Arcs around things.

I don't think this fits me - I like the feeling of understanding what I'm doing, and once in a while coming up with something that compiles and runs fast and robustly. If you can do that in Rust, good for you.

Another part is that it still seems easier to interface with existing ecosystems in C. I tried writing some Win32 Rust code once in an evening and I have to admit I failed. Maybe I picked the wrong bindings library or whatever. At this point in my life, I have little patience to spend my time like this.

I appreciate the work that is being done, and I feel it's not unlikely that at some point we all will switch. At this point though I feel I'm way more productive staying in my current habitat. And that's not only on me, but also that the ecosystem and developed practices likely are not quite ready.

Comparing the investment to simply washing hands and putting on gloves or following a checklist as a surgeon feels unfair to me.

Re:Memory Safe Languages in Android 13 by ajuc on Friday December 02, 2022 @04:47AM (#33828603)
It's not even about languages. Just using valgrind or sth similar as a part of CI would solve A LOT of issues.
Re:Memory Safe Languages in Android 13 by cjg on Friday December 02, 2022 @04:52AM (#33828626)
Implementing a linked list in Rust is somewhat challenging because of the safety issues that arise. Luckily you don't have to, there's one in the standard library: https://doc.rust-lang.org/std/collections/struct.LinkedList....

The equivalent of a generic memcpy is probably something like a .clone() call on a generic type that implements Clone.

Re:Memory Safe Languages in Android 13 by jstimpfle on Friday December 02, 2022 @07:04AM (#33829439)
This isn't an intrusively linked list.

Probably not the Clone trait but the Copy trait.

Re:Memory Safe Languages in Android 13 by steveklabnik on Friday December 02, 2022 @09:29AM (#33830819)
> The equivalent of a generic memcpy is probably something like a .clone() call on a generic type that implements Clone.

If you type "memcpy" into the documentation search, rustdoc will point you to

* https://doc.rust-lang.org/stable/std/primitive.slice.html#me...

* https://doc.rust-lang.org/stable/std/intrinsics/fn.copy_nono... (Though it should really point to the reexport at https://doc.rust-lang.org/stable/std/ptr/fn.copy_nonoverlapp... )

The latter will also mention

* https://doc.rust-lang.org/stable/std/ptr/fn.copy.html

Re:Memory Safe Languages in Android 13 by fiedzia on Friday December 02, 2022 @10:17AM (#33831594)
> Implementing a linked list in Rust is somewhat challenging because of the safety issues that arise

Implementing linked list in any language that is not memory-safe is challenging because of safety issues. Rust just points it out.

Re:Memory Safe Languages in Android 13 by ilyt on Friday December 02, 2022 @06:43AM (#33829255)
My limited experience with Rust was that I need to know exactly what I want to do in the code and compiler is there to make sure I write that intent as actual code, not my assumptions about how the code will work.

I don't feel that I am less in control, just that all of that needs to be put in code and not just go "okay, I know this part don't need a lock coz I will never call it concurrently" and hope for best.

Even writing for embedded (as in no os, tens of kilobytes of RAM microcontrollers) haven't been too bad althought I haven't managed to convince borrow checker to borrow non-contigous block of bits from a register yet... althought that's what unsafe{} is for after all

> Comparing the investment to simply washing hands and putting on gloves or following a checklist as a surgeon feels unfair to me.

The closer one would be "read that 300 pages of how to do stuff safely and apply it". Once you get into good habits it's not a problem but investment is there

Re:Memory Safe Languages in Android 13 by vineyardmike on Friday December 02, 2022 @04:07AM (#33828366)
> This isn't primarily about replacing existing software. There are plenty of engineers that argue for continuing to use memory-unsafe programming languages.

> New projects written in C are being started every day.

But it is mostly about existing software, even if its not about replacing existing software. I write C++ code every day. I hate it, and I'd rather not. But I use C++ libraries written by my teammates, and reference implementations in prior C++ work in our past projects, and have a set-up C++ toolchain, and my company even has all sorts of written C++ docs and style guides and linters and macros and ... and ...

Even if we wanted to stop, there's so much extra stuff to consider. I get your point, <<why start a new thing knowing there's a better way?>> and I would want to stop using c++ but most software isn't one-and-done like a surgery. It is a continuous commitment and ongoing operation, it is the tools used, and the knowledge learned, and the libraries built.

> This is the exact equivalent of physicians continuing to use unsafe medical procedures

Plenty of platforms don't support rust. Just because you've improved knee surgery, doesn't mean it works on an elbow... yet. And sometimes you still gotta perform surgery on elbows.

> if the programmer is "smart enough".

Can't defend this, but tbh I've never heard it.

Re:Memory Safe Languages in Android 13 by simiones on Friday December 02, 2022 @04:39AM (#33828549)
> > if the programmer is "smart enough".

> Can't defend this, but tbh I've never heard it.

Take a look at this comment: https://news.ycombinator.com/item?id=33824934

> Modern C++ has many memory safety features. If a company has learned that its people fail to use them, then bad for them.

It is a somewhat common attitude in this type of thread.

Re:Memory Safe Languages in Android 13 by josefx on Friday December 02, 2022 @05:58AM (#33828958)
> It is a somewhat common attitude in this type of thread.

Except the safety features are often a lot easier to use than the original C isms that tend to cause the most issues. So it is less an issue of smart and more one of bad habits. C strings instead of std::string, plain arrays instead of std::vector, implicit ownership instead of smart pointers, ... .

Re:Memory Safe Languages in Android 13 by pizza234 on Friday December 02, 2022 @07:50AM (#33829814)
The stats come from Google project(s) - you can be sure that they've used the best practices. If they've failed, rest assured that 90%+ of the rest of the devs will fail, and much worse.
Re:Memory Safe Languages in Android 13 by josefx on Friday December 02, 2022 @09:30AM (#33830838)
> he stats come from Google project(s) - you can be sure that they've used the best practices

The first Google Style Guide for C++ I ever came across in the wild espoused C with classes, had "standard" in scare quotes and banned most of boost for encouraging functional programming. I almost threw a fit when someone unironically tried to push that POS at work because "Google", it was entirely nonsensical especially given that we made heavy use of boost and math libraries with operator overloading.

Re:Memory Safe Languages in Android 13 by vineyardmike on Friday December 02, 2022 @01:35PM (#33834707)
> someone unironically tried to push that POS at work because "Google"

Especially since Google has a ton of automated tools to perform tests and analysis on code, and enforces certain behavior before you can merge your code in. Something that is probably missing from a smaller organization that’s simply adopting their style guide. Also probably missing is googles alternative stdlib they use.

Re:Memory Safe Languages in Android 13 by UncleMeat on Friday December 02, 2022 @08:12AM (#33830015)
And yet, you can happily have a UAF through a string_view.

This is not about C++ developers using old school C approaches. The language is fundamentally dangerous. There were huge efforts within Chrome to get all memory managed by smart pointers even more powerful than those offered by the standard, and they still have UAFs all the time.

Re:Memory Safe Languages in Android 13 by vineyardmike on Friday December 02, 2022 @01:32PM (#33834662)
> take a look at this comment

It’s hacker news. People say all sorts of inflammatory crap here. I discount anything said here, especially in response to an article about said topic.

If my c++ writing coworker shared that opinion with me, or someone at a conference, that’s be different.

> Modern C++ has many memory safety features. If a company has learned that its people fail to use them, then bad for them

I will admit I vaguely agree with this. My company has all sorts of tools that perform basic checks for memory safety and a style guide that is very opinionated. Just because we can’t switch easily doesn’t mean we can’t try to improve as an org.

I don’t avow the belief that any program is truly smart enough/too dumb to make bugs, but I do think the organization maintaining the code has a responsibility to improve. Especially a large organization. Whether that’s better code review processes, automated tooling, or even soft-banning the use of certain unsafe practices.

Re:Memory Safe Languages in Android 13 by ilyt on Friday December 02, 2022 @06:45AM (#33829273)
>> This is the exact equivalent of physicians continuing to use unsafe medical procedures

> Plenty of platforms don't support rust. Just because you've improved knee surgery, doesn't mean it works on an elbow... yet. And sometimes you still gotta perform surgery on elbows.

That's a non-argument, obviously if it isn't even applicable it's not a discussion. Also most of what people code on does support Rust

>> if the programmer is "smart enough".

>Can't defend this, but tbh I've never heard it.

Programmer is never smart enough. Decades of bugs showed that

Re:Memory Safe Languages in Android 13 by peoplefromibiza on Friday December 02, 2022 @06:49AM (#33829310)
> There are plenty of engineers that argue for continuing to use memory-unsafe programming languages

And why do you think it's wrong, per se?

> This is the exact equivalent of physicians continuing to use unsafe medical procedures

You mean with different safety tradeoffs?

Because what you propose is exactly like forcing very expert physicians to switch to a procedure they are novice of and that it's not been battle tested like the old one, that proved to be very effective in most cases.

It's the same reason why patients prefer to be treated with established procedures and to undergo experimental treatments they need to sign a document that proves their informed consent.

Re:Memory Safe Languages in Android 13 by ilyt on Friday December 02, 2022 @06:26AM (#33829134)
I mean if you want to use that comparison, C/C++ bridge would have random holes dropping the cars off the cliff below.

The issue is not "bridge is suboptimally designed" or "bridge will need some extra maintenance because something started to break".

The memory safety issues are "some cars randomly explode when passing that bridge" or "when driver breaks 6 seconds after entering the bridge, every other driver dies.

> Software is not terribly different from that.

It is MASSIVELY different, especially anywhere near anything security-related. Most buildings don't have a group of people with hammers trying to find a weak point that will never happen in any actual use conditions and then hit that weakpoint in every similar building built in every place of the world.

Please don't make horribly useless comparisons like that

Re:Memory Safe Languages in Android 13 by sitkack on Friday December 02, 2022 @07:18AM (#33829565)
> we don't go around tearing down old infrastructure

All the time! And the stuff we don't tear down, we retrofit.

Re:Memory Safe Languages in Android 13 by jimkoen on Thursday December 01, 2022 @11:30PM (#33826798)
That seems to be a very limited view on the issue, since the stakes with ansthesia related issues are much higher (a human life).
Re:Memory Safe Languages in Android 13 by p-e-w on Thursday December 01, 2022 @11:42PM (#33826873)
Every human life is directly or indirectly impacted by software. Software controls transport, food and energy production, and all human communication. If all software suddenly stopped working, society would collapse instantly and hundreds of millions of people would die within a year.

The attitude "it's just computers, nothing truly important like medicine" might have been viable 40 years ago, but it certainly isn't anymore.

Re:Memory Safe Languages in Android 13 by jstimpfle on Friday December 02, 2022 @04:28AM (#33828486)
It's not like you make a bad git commit and suddenly the world stops working. There are checks and processes and redundancies that reduce the impact of human error dramatically.

The earth is still spinning, despite so many things not working everywhere. That's not just in software. In every system, there's relatively few single points of failure. As you zoom out, failure points disappear and new ones appear.

Sure, still sometimes someone notices a critical security flaw that's been in there for a while, and that had found its way into large parts of the infrastructure already. (The last one I heard of was not a memory vulnerability).

Re:Memory Safe Languages in Android 13 by wrongtime on Friday December 02, 2022 @06:45AM (#33829276)
>It's not like you make a bad git commit and suddenly the world stops working.

https://qz.com/646467/how-one-programmer-broke-the-internet-...

Re:Memory Safe Languages in Android 13 by jstimpfle on Friday December 02, 2022 @07:00AM (#33829397)
Sure, I know this. I don't think this contradicts my argument. It didn't suddenly make running infrastructure exposed. But yeah, people needed to find a replacement to continue development (which I hope wasn't hard)?

If this breakage is an argument for anything, it is against depending on lots of code that you don't even know. The last Rust projects I tried to build all had on the order of 500 transitive dependencies, by the way.

Re:Memory Safe Languages in Android 13 by ilyt on Friday December 02, 2022 @06:47AM (#33829297)
I assume you're not familiar with https://en.wikipedia.org/wiki/Therac-25 ?
Re:Memory Safe Languages in Android 13 by MBCook on Friday December 02, 2022 @12:02AM (#33826996)
> Utterly unthinkable, isn't it?

No. Ignaz Semmelweis faced it in the 1800s for daring to suggest (what we know know as germs) made people sick and hand washing could drastically reduce medical complications. He was able to prove it too.

By the end was locked up in an asylum for his ‘crimes’.

Want more recent?

How many stories have you heard of instruments or gauze or whatever left in surgical patients? Of operating on the wrong part or person?

People are fallible. But checklists help a ton. We know that for sure. Why is aviation obsessed with following them? Because they work to increase safety.

Surgeons have resisted them. I don’t know the current state of it, but they were making that exact “good surgeons don’t need it” argument. I remember it being a plot point on an episode of a medical drama (ER? Or maybe Grey’s Anatomy).

There are probably tons of other examples in other fields.

Re:Memory Safe Languages in Android 13 by p-e-w on Friday December 02, 2022 @01:13AM (#33827414)
Semmelweis is ancient history. He was active at a time when regulations and "best practices" simply weren't a thing anywhere.

Surgeons resisting checklists is new to me. Do you have a reference other than a TV show? My understanding until now was that checklists are extensively used in medicine.

Re:Memory Safe Languages in Android 13 by timeinput on Friday December 02, 2022 @01:43AM (#33827607)
Here are a couple articles to start pulling threads on

> Despite all the evidence, Gawande admits that even he was skeptical that using a checklist in everyday practice would help to save the lives of his patients.

> "I didn't expect it," Gawande says with a chuckle. "It's massively improved the kind of results that I'm getting. When we implemented this checklist in eight other hospitals, I started using it because I didn't want to be a hypocrite. But hey, I'm at Harvard, did I need a checklist? No."

https://www.npr.org/2010/01/05/122226184/atul-gawandes-check...

Not sure if this supports the reluctance idea since it says 93% use checklists, but most surgeons don't think it improves safety.

> Of the 353 survey respondents, 93.6% use SSCs and 62.6% would want one used in their own child’s operation, but only 54.7% felt that checklists improve patient safety.

https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6221594/

Re:Memory Safe Languages in Android 13 by irishsultan on Friday December 02, 2022 @04:58AM (#33828652)
That first quote (as well as the rest of the article) supports the view that people tend to underestimate the usefulness of procedures they are not yet using and especially to overestimate their own abilities. It also shows that social pressure is the opposite of what it was in Semelweiss time, even people who feel they are above such things start using them (and then some of them get convinced that they were wrong).

The part you quoted from your second link directly contradicts your claim that most surgeons don't think it improves safety (even if the 54.7% is among the 93.6% that use it that still gives 51% that think it improves safety).

Re:Memory Safe Languages in Android 13 by gjadi on Friday December 02, 2022 @05:47AM (#33828895)
The usefulness of checklist in medical and the resistance to it is mentioned several times in The Checklist Manifesto.

https://en.wikipedia.org/wiki/The_Checklist_Manifesto

Re:Memory Safe Languages in Android 13 by themenomen on Friday December 02, 2022 @11:17AM (#33832513)
That IS the central issue though, processes, techniques, and so on are not a THING until they are. And something has to change for that to happen.
Re:Memory Safe Languages in Android 13 by ilyt on Friday December 02, 2022 @06:19AM (#33829085)
We have smaller version of that with masks in pandemic. Cheap and easy means to reduce problem by a bit ? Nah, let's not do that /s
Re:Memory Safe Languages in Android 13 by quotemstr on Friday December 02, 2022 @08:18AM (#33830069)
> Utterly unthinkable, isn't it?

> Yet in software engineering, this is exactly what has been happening every day for more than a decade.

Consider what happened to poor Semmelweis when he discovered in the middle of the 19th century that hand-washing improved medical outcomes: doctors of the time were too proud to accept his results and drove him out of the profession (and to his early grave) rather than change their practices.

All these people who insist on continuing to write new C programs have the same mentality as those doctors who refused to wash their hands.

Re:Memory Safe Languages in Android 13 by spookie on Friday December 02, 2022 @01:25PM (#33834541)
Woah.

A bit much, eh? I write programs in whatever I want as an hobby. Why does that make me a murderer? Everyone needs to chill about this.

Re:Memory Safe Languages in Android 13 by kllrnohj on Friday December 02, 2022 @10:39AM (#33831918)
> Yet in software engineering, this is exactly what has been happening every day for more than a decade.

Not really. Rust is the first major attempt to achieve c/c++ performance & capability while also being safe.

Prior to that nearly every memory safe language came with crippling tradeoffs, and that is why people rejected them. Especially as performance and efficiency took center stage again with the massive increase in battery powered devices & the general plateau of single core CPU performance over the last decade

Re:Memory Safe Languages in Android 13 by timbit42 on Saturday December 03, 2022 @10:06AM (#33843996)
More than a decade? It started back in the 1970's when Pascal and C were duking it out. Early programmers were mathematicians and they took their craft seriously, including safety. They designed Algol which Pascal and C came from but Pascal had the safety and C didn't. C won the battle because programmers felt saving a few CPU cycles was more important than safety. Unfortunately, Pascal had a few other issues that kept it from beating C. Wirth later came out with Modula-2 in the late 1970's, which was vastly superior to C, but it was too late to compete with C's popularity. We've been hamstrung by C and its derivatives ever since. The importance of safety became much more apparent when networking became popular but there was no turning back at that point. Now, finally, 50 years later, Rust is pulling us back toward safety in a C-syntax language.
Re:Memory Safe Languages in Android 13 by gnull on Thursday December 01, 2022 @04:40PM (#33823216)
> Defenders of C/C++ frequently note that memory safety bugs aren't a significant percentage of the total bug count, and argue that this means it's not worth the hassle

This says more about those C++ defenders.

Re:Memory Safe Languages in Android 13 by hinkley on Thursday December 01, 2022 @05:19PM (#33823756)
You can judge a person by the company they keep.
Re:Memory Safe Languages in Android 13 by munificent on Thursday December 01, 2022 @05:50PM (#33824115)
Lie down with C++, wake up with bugs.
Re:Memory Safe Languages in Android 13 by Gigachad on Thursday December 01, 2022 @06:31PM (#33824593)
C-nile developers have been making incorrect arguments for a while now. The reality is which almost everyone can see is that memory safe languages are pretty much always what you want to be using for new code. OS and security sensitive components are the prime targets for rewrites in more secure languages.
Re:Memory Safe Languages in Android 13 by saagarjha on Thursday December 01, 2022 @07:30PM (#33825156)
> The reality is which almost everyone can see is that memory safe languages are pretty much always what you want to be using for new code.

Nitpick, this is not quite true. Memory safe languages are what you should be using in contexts where security and reliability are critical. This is generally the case but there are some contexts where other concerns are genuinely more important. Of course when this is necessary is often misrepresented but these cases do exist.

Re:Memory Safe Languages in Android 13 by Sirened on Friday December 02, 2022 @12:10AM (#33827059)
writing exploits, for example, is an utter pain in today's safe languages :) C is unmatched in the sheer ease of manipulating raw bytes with some light structuring on top for convenience. I've tried writing exploits in Swift a handful of times but I always gave up after I found myself buried under a pile of UnsafeMutableRawBufferPointers.
Re:Memory Safe Languages in Android 13 by gnull on Friday December 02, 2022 @04:28AM (#33828488)
You mean, manipulating strings of bytes? Bytes don't have to be memory, you can just use bytestrings in Python or whatever.

Raw memory access is something you normally need to create vulnerabilities, not to exploit them :)

Re:Memory Safe Languages in Android 13 by Sirened on Friday December 02, 2022 @06:45AM (#33829277)
har har :)

It's an ergonomics thing, not a "can't" issue. There is a reason I called out Swift in particular—their "unsafe" APIs are so horrid to use that they make you regret doing unsafe things in the first place. Plus, throw in FFI and now you've got an even worse problem because not only are you forced to use the unsafe types, but often a lot of the critical APIs you need to interface with (in *OS exploitation, mach is the worst offender) have such funky types due to their generic nature that you have to go through half a dozen different conversions to get access to the underlying data.

Re:Memory Safe Languages in Android 13 by gnull on Friday December 02, 2022 @07:24PM (#33838834)
I still don't understand why would you prefer raw memory manipulation to bytestring manipulation. If you want, just make a Swift library that will implement the memory like you want but without unsafe raw access (but just a few methods over a byte array). Back in the days when I did CTFs, I used Python for writing binary exploits, never C.

https://github.com/hellman/libformatstr

You can do something like this, no need to work with raw memory.

Re:Memory Safe Languages in Android 13 by saagarjha on Saturday December 03, 2022 @07:07PM (#33848942)
Swift has the advantage that it can directly “speak” C, without any indirection needed. (C can already do this of course.) In particular operations like scanning an address space for things, easily expressing the layout of something, and so on are much easier to do in these languages. In theory you could do the same in Python but it’s often not worth the effort.
Re:Memory Safe Languages in Android 13 by logicchains on Thursday December 01, 2022 @11:06PM (#33826646)
>The reality is which almost everyone can see is that memory safe languages are pretty much always what you want to be using for new code.

Not everybody is writing security-critical code. For some things productivity and time-to-market is more important and security is not enough of a concern to justify dealing with a language with horrible compile times and a self-righteous, dogmatic community.

Re:Memory Safe Languages in Android 13 by Gigachad on Thursday December 01, 2022 @11:20PM (#33826721)
We probably need to bring in some kind of criminal liability for the companies that only cared about time to market and put their users at risk.

After memory safe languages become a bit more battle tested, C/++ needs to be regulated like asbestos.

Re:Memory Safe Languages in Android 13 by logicchains on Friday December 02, 2022 @01:24AM (#33827478)
Not everybody's building a product that deals with sensitive user data. By your logic all code not written in proof languages should be illegal.
Re:Memory Safe Languages in Android 13 by foxes on Thursday December 01, 2022 @11:54PM (#33826949)
Where has time to market and productivity ever been a factor for C and the C ecosystem? My most "productive" languages have been declarative languages like Haskell (depending on how you measure that). I don't care if it takes an extra few minutes to compile either, amortized away in the long term when you don't have to deal with entire additional classes of bugs to deal with. Also why is security never an important concern? There are a lot of security issues which are self inflicted if you use C. Using something like rust means a lot of issues simply don't exist. The optimal solution.
Re:Memory Safe Languages in Android 13 by jstimpfle on Friday December 02, 2022 @03:49AM (#33828265)
I spent a considerable amount of time learning Haskell but I always felt like a slave to the language. Oh, you want to do this other simple thing? Try language extension XYZ, but you'll have to learn some more language theory first. Also sorry but the extension isn't compatible with the extensions you're already using, and you need to require a new dependency on the outside interface.

There are some things that the language is good at, but at some other things (I think a lot actually) it isn't. At the very least, I wouldn't recommend it for writing a video decoder.

Re:Memory Safe Languages in Android 13 by tome on Friday December 02, 2022 @07:26AM (#33829640)
> sorry but the extension isn't compatible with the extensions you're already using

In nearly 10 years of professional Haskell I've never come across a practical situation where extensions that were mutually incompatible. Can you name any extensions that are incompatible in a way that actually matters in practice?

Re:Memory Safe Languages in Android 13 by jstimpfle on Friday December 02, 2022 @07:42AM (#33829756)
No, I haven't followed the language in 6 years. I remember there was at least one instance but can't recall. Other extensions significantly change the semantics of language module interfaces in more obtrusive ways than I'd like - compared to say C where it's pretty easy to offer a simple interface.

Some of these things would make working in the language pretty painful. I remember trying some library to toy around with a basic 400 line OpenGL program. It always needed 8 seconds to rebuild at the time. I don't recall and probably didn't understand why, but I suppose it has to do with some extra type or template hackery in the library that would just overcomplicate everything, probably even at the outset.

What remains is the feeling of, I can't do this thing yet in the type system, so take that extension. Oh wow. Now I can't do this other thing that I also need, the only fix is another extension (if it's available yet). I couldn't get around of this feeling of constantly having to hack around the language.

In my experience you need to have a very good overview and understanding of all the available tricks and extensions to be able to navigate your way around the language and not paint yourself into a corner. Maybe I have the wrong personality, the wrong motivations, or am just not smart enough. Obviously I'm not you, and am not Edward Kmett (who would resort to lots of GHC specific hacks and drop down to C++ as well).

Re:Memory Safe Languages in Android 13 by tome on Friday December 02, 2022 @12:37PM (#33833754)
> I remember trying some library to toy around with a basic 400 line OpenGL program. It always needed 8 seconds to rebuild at the time.

This is a fair criticism. Compile times are slow.

Extension confusion is not a fair criticism. Extensions typically remove restrictions. They don't create incompatible languages.

Granted, it's a bit annoying to have to turn them all on, one by one. These days one should just enable GHC2021 and forget about language extensions. That saves one having to be Edward Kmett, or from bothering to think about language extensions at all.

Re:Memory Safe Languages in Android 13 by roca on Friday December 02, 2022 @01:45AM (#33827623)
Anyone who writes a library that might get used in a context where it is presented with inputs derived from potentially malicious data, is writing security-critical code whether they acknowledge it or not.
Re:Memory Safe Languages in Android 13 by kaba0 on Friday December 02, 2022 @02:05AM (#33827741)
Which memory-unsafe language is more productive and has faster time -to-market than any managed language?
Re:Memory Safe Languages in Android 13 by jstimpfle on Friday December 02, 2022 @03:45AM (#33828245)
I'm pretty confident that systems programming (you know - moving data around) is easier with raw memory access compared to managed languages.
Re:Memory Safe Languages in Android 13 by gnull on Friday December 02, 2022 @04:46AM (#33828593)
Is this a joke? Systems programming is a lot about accessing APIs, dealing with all sorts of intricacies like interrupts, different execution contexts, and managing memory as you said.

If you write in C and your program is complex enough, you will spend a lot of time just chasing segfaults and concurrency bugs and getting it to work the first time you write it. If your systems programming is in userspace, that's sort of fine. But if you're in kernel or on bare metal, the cost of debugging goes up by an order of magnitude. There's no debuggers on bare metal, and nobody can tell you how your program crashed—the device just stops responding, that's it.

That's why safe languages make even more sense in these restricted environments. If you get twice fewer memory safety bugs while you're getting your program to work, that can reduce your development time like 5-6 times.

Re:Memory Safe Languages in Android 13 by jstimpfle on Friday December 02, 2022 @06:47AM (#33829289)
> Systems programming is a lot about accessing APIs, dealing with all sorts of intricacies like interrupts, different execution contexts

So now you need to make your interrupts talk to your Java objects? Is this any safer?

Is it easier to get a VM running in your kernel (probably no mean feat to do that in the first place) and you'll never get any concurrency bugs? And if you reduce memory bugs by half, those will be easier to debug?

And you won't be annoyed that you can't guarantee to be able to link objects in queues (because of allocation failure) and access them with generic code to copy data, link/unlink them, and so on? You're fine to pay for callbacks and interfaces everywhere, both in terms of runtime and performance as as maintenance headaches?

I'm asking incredulously, but seriously. Because frankly I've never looked at a project like MirageOS or whatever. But given real world evidence of what has survived, I don't see why you should assume I'm joking.

That you can't debug a "bare metal" kernel isn't quite true, either. But sure, the more complex a system becomes, the more contemplation it requires to figure out problems. This is universally true, but you can't simply discuss complexity away. And adding complex object models on top without consideration doesn't make your task easier just like that.

Re:Memory Safe Languages in Android 13 by kaba0 on Friday December 02, 2022 @12:06PM (#33833247)
An OS will always need some tiny assembly part, as some instructions needed for the kernel simply never gets generated by compilers. Also, an OS itself is pretty much a garbage collector for resources, it could very well reuse/link into its own GC for better performance.

Are we really talking about the “price” of managed code, when C code is chock-full of linked list data structures? A list of boxed objects is more cache-friendly than that. It is simply not always that performance sensitive to begin with (e.g. does it really matter if it queries the available display connectors in 0.0001s or 10x that?)

Regarding MirageOS, they actually achieved better performance by using a managed language than contemporary C OSs for select tasks. This is possible due to context switches being very expensive, and a managed env can get away with (some?) of those.

Re:Memory Safe Languages in Android 13 by jstimpfle on Friday December 02, 2022 @12:26PM (#33833586)
Those linked lists give some nice guarantee that significantly simplify a lot of code and give some guarantees that you just can't have otherwise.

Context switching can be expensive, but I don't see what's specific about managed envs about that. Fundamentally you have to have trust in code, and need to have the hardware support to enforce authenticity of the trusted code in order to avoid context switching. Maybe a promising development is CPUs growing more and more cores, and more and more kernel resources being available through io_uring and similar interfaces.

Re:Memory Safe Languages in Android 13 by gnull on Friday December 02, 2022 @07:33PM (#33838898)
I have a really hard time following anything you say here.

How did we start talking about Java and VMs? Is this some sort of strawman argument?

> But sure, the more complex a system becomes, the more contemplation it requires to figure out problems

Strawman again? I wasn't talking about complexity. I said that the more "systems" your programming is, the higher is the cost of memory safety bugs.

Re:Memory Safe Languages in Android 13 by jstimpfle on Saturday December 03, 2022 @02:26AM (#33841490)
> How did we start talking about Java and VMs? Is this some sort of strawman argument?

Is it a strawman if my comment was in response to "managed languages"?

> Strawman again? I wasn't talking about complexity. I said that the more "systems" your programming is, the higher is the cost of memory safety bugs.

For clarity, you spoke about the cost of debugging of memory bugs. And I said, it's universally true that programs are harder to debug the more "systems" it gets. That's because it typically isn't sufficient to simply trace an individual thread anymore. "Logical tasks" are served over a number of event handlers executed in various (OS) threads.

It's not first and foremost a refutal of what you said. But an observation that I even placed in opposition to my other statement that it's not quite true that you can't use debuggers with kernels. FWIW and so on. I don't get why you are calling "strawman" repeatedly, and don't get the aggressive tone of your comments.

Re:Memory Safe Languages in Android 13 by andrewjl on Friday December 02, 2022 @02:55AM (#33827997)
> For some things productivity and time-to-market is more important

Who would choose C/C++ and not something like Go in that situation?

Re:Memory Safe Languages in Android 13 by pjmlp on Friday December 02, 2022 @03:25AM (#33828139)
Only because unfortunely liability is still not enforcement by law as it should.
Re:Memory Safe Languages in Android 13 by athrowaway12 on Friday December 02, 2022 @09:21AM (#33830708)
> enforcement of security vulnerability should be by law

I think whether there "should" be a law making you liable could depend on the details of the exploit.

If you get exploited via rowhammer, I don't think anyone would blame you. It would be unreasonable if every small business running a website could be sued if they didn't defend against electromagnetic interference within the RAM.

However, if you're Apple and say -- you could get pwned because someone clicked a button to register version 9000 on the public npm/pypi registry (https://medium.com/@alex.birsan/dependency-confusion-4a5d60f...) -- maybe I agree there's an argument for some accountability there :)

Re:Memory Safe Languages in Android 13 by pjmlp on Friday December 02, 2022 @09:26AM (#33830772)
Yes it definetly should.

Computing is the only industry, where people accept to live with tainted goods instead of forcing whoever sold them to pay back, cover for their damage or whatever.

We already have high integrity computing, digital stores with returns, consulting with warranty clauses, and some countries are finally waking up that computing shouldn't be a special snowflake.

https://www.twobirds.com/en/insights/2021/germany/the-german...

Re:Memory Safe Languages in Android 13 by athrowaway12 on Friday December 02, 2022 @09:54AM (#33831226)
Just pointing that all software is exploitable. And punishing the application developer might not be right if the vulnerability is caused by a lower level dependency. For example, log4j.

I agree if there's a high social cost to a breach then the government should punish those involved. Also, the security of your software depends on your threat model and which threats are in scope and you're willing to invest in protecting against. The tradeoff is ease of development and velocity. So maybe such laws will incentive this process differently, and maybe it's a worthwhile change.

I look at computing as a big experiment. Personally, I am very careful to use trustworthy services and don't depend on software for anything critical (besides banking, but luckily FDIC). Most people don't take the same precautions and rely very heavily. It's obviously critical infrastructure at this point. Maybe it's time to stop thinking of it as an experiment, and maybe these laws make sense.

I don't like the concept for emotional reasons; to me it's sad and signals another step towards the end of the golden age of the internet.

Re:Memory Safe Languages in Android 13 by kobebrookskC3 on Friday December 02, 2022 @09:47PM (#33839976)
Re:Memory Safe Languages in Android 13 by raxxorraxor on Friday December 02, 2022 @09:01AM (#33830491)
> self-righteous, dogmatic community.

Worst Rust feature by far.

I understand how Rust solves some problems and these are indeed very important ones. But it still is a constraint that has to prove itself.

C is horrible, out of the question. Really dated too without thousands of band aids. C++ has millions of those. But why not start re-implementing stuff in Rust if that is so close to your heart?

We can also reimplement everything in JavaScript. It is memory safe too. Wait, where is the enthusiasm now?

Re:Memory Safe Languages in Android 13 by fiedzia on Friday December 02, 2022 @10:32AM (#33831820)
> We can also reimplement everything in JavaScript

Look at js package stats - that's exactly what's happening. Many of apps and packages created today in js would be created in C/C++ few years ago. People who learn programming today don't know what C/C++ is. If they need something low-level, it's Rust.

Re:Memory Safe Languages in Android 13 by raxxorraxor on Friday December 02, 2022 @08:55AM (#33830423)
Meh, bad argument. How about you write better code in Rust to replace existing stuff. There is so much more to consider and I think one of Rusts most repellent features is the preaching about its advantages. I definitely has some that are hard to deny. Still... how about just doing it, nobody is held hostage here.
Re:Memory Safe Languages in Android 13 by steveklabnik on Friday December 02, 2022 @09:32AM (#33830857)
> How about you write better code in Rust to replace existing stuff.

No matter what people do, it's never enough for the critics. Many people criticize Rust fans for "rewriting it in Rust"!

> how about just doing it

People absolutely are. That's what the article is about, even.

Re:Memory Safe Languages in Android 13 by harry8 on Thursday December 01, 2022 @04:54PM (#33823450)
Seems like drawing too many conclusions from evidence while arguing against a straw man?

Defenders of C might note that Android is java and IOS is not and compare the security of those two systems and say clearly memory-safe is focusing on the wrong thing. This is equally true but no more valid an argument.

The one that really bothers me in all these language-booster discussions (that we should and need to have) is the functional programming formal verification claims. We have no ssl library written in a memory-safe, functional language that has been proven correct that has dominated the space. Heartbleed wasn't yesterday.

I look down the list here: https://en.wikipedia.org/wiki/Comparison_of_TLS_implementati...

And I think something is not being discussed as far as replacing memory unsafe languages of critical security infrastructure. What is it?

Re:Memory Safe Languages in Android 13 by ghostwriter on Thursday December 01, 2022 @05:21PM (#33823796)
> We have no ssl library written in a memory-safe, functional language that has been proven correct that has dominated the space. Heartbleed wasn't yesterday.

Heartbleed didn't affect https://hackage.haskell.org/package/tls even though it isn't formally verified.

Re:Memory Safe Languages in Android 13 by harry8 on Thursday December 01, 2022 @05:27PM (#33823878)
Does anybody at all use that library in production at scale, ever? Genuine question. Maybe they do?

Why hasn't this really good result meant _everybody_ now uses that library by default and has to justify using something else?

There is something here not being discussed, what is it?

Re:Memory Safe Languages in Android 13 by ghostwriter on Thursday December 01, 2022 @05:46PM (#33824070)
There's a hint it was used at Dell in some capacity 6 years ago, judging by this comment https://www.reddit.com/r/haskell/comments/5gyrdv/what_is_war... The thread discusses "warp-tls" which is a webserver extension that uses that "tls" package as a dependency for TLS support.
Re:Memory Safe Languages in Android 13 by harry8 on Thursday December 01, 2022 @07:13PM (#33825007)
Ok but this is surely not compelling evidence of literally anything. Perhaps, in fact, the opposite. This is what we have for evidence and nothing more then WHY???

There is something here, at least one thing, that seems to be dominating outcomes, and is not being discussed.

Nobody has even a half-suggestion of what it might be and that is not making it (or them) go away as problems that are not being solved.

Re:Memory Safe Languages in Android 13 by roca on Friday December 02, 2022 @01:49AM (#33827652)
rustls isn't formally verified but no critical CVEs have been found in it yet. The only CVE is one DoS.

And I don't know about "used at scale" but we use it in production for Pernosco.

Re:Memory Safe Languages in Android 13 by raggi on Thursday December 01, 2022 @10:25PM (#33826375)
WireGuard is a recent and prominent example of a system that has been formally verified (https://www.wireguard.com/formal-verification/). There are implementations in a variety of languages due to integration considerations.

You will find at the bottom of that page C implementations of curve25519 that are proofed and derived from F* and Coq. Curve25519 is a relatively simple implementation and only one part of any system that uses it. As you can see in both of these implementations the papers recognize a team of contributors each - this should provide some insight as to the cost of such work. That doesn't make it unimportant, it just makes it rare.

Re:Memory Safe Languages in Android 13 by ShredKazoo on Thursday December 01, 2022 @10:39PM (#33826470)
Out of curiosity did the Wireguard formal verification effort end up identifying any security issues in the implementation?
Re:Memory Safe Languages in Android 13 by harry8 on Thursday December 01, 2022 @11:50PM (#33826932)
Now that is interesting. I didn't know that and will have to look further to understand what it means.

Wireguard seems to be written almost entirely in C, is that right?

Re:Memory Safe Languages in Android 13 by KMag on Friday December 02, 2022 @02:34AM (#33827876)
The symbolic proofs of the protocol are independent of the implementation. The portions of the implementation that are formally verified are written in F* and Coq, and emitted as machine-generated C.
Re:Memory Safe Languages in Android 13 by rob74 on Thursday December 01, 2022 @04:56PM (#33823469)
...but still, even with Android's importance and Google's resources, they're not planning to "rewrite it in Rust", at least not for now - only new code will use Rust.
Re:Memory Safe Languages in Android 13 by lolinder on Thursday December 01, 2022 @05:02PM (#33823563)
The overwhelming majority of bugs of any sort live in new code. The longer a piece of code has been around, the safer it generally is (with occasional high-profile exceptions). This means two things:

1) The most cost-effective way to eliminate the majority of memory bugs is to just start writing all new code in a memory-safe language. If you were going to write new code anyway, you may as well do it safely.

2) Going back and re-writing existing code that doesn't need to be changed may solve latent memory bugs, but it will likely introduce other regressions that could be worse for security or for user experience. If code doesn't need to change, it's often better to leave it as is.

Not that a rewrite is never called for, but it's not necessarily the best course of action by any metric (even when neglecting the cost).

Re:Memory Safe Languages in Android 13 by 8note on Thursday December 01, 2022 @09:17PM (#33825894)
Part of that safety is users working around known bugs, leading to inefficient solutions to whatever the code is supposed to do.

People tend to forget that they don't have to live with those problems, but they still have a cost

Re:Memory Safe Languages in Android 13 by estebank on Thursday December 01, 2022 @05:02PM (#33823558)
New code includes rewrites, like the Bluetooth stack.
Re:Memory Safe Languages in Android 13 by brundolf on Thursday December 01, 2022 @06:30PM (#33824579)
Mostly new code. They've rewritten some core, high-importance pieces. But any mature OS is a massive codebase, so it just wouldn't be feasible to systematically rewrite the entire thing indiscriminately
Re:Memory Safe Languages in Android 13 by ghostwriter on Thursday December 01, 2022 @05:05PM (#33823597)
> and argue that this means it's not worth the hassle of switching to a new language.

Defenders of C++ argue that there's no reason to change the language, because new features around safety guarantees are being introduced into every C++ standard starting from C++11 at a remarkable pace, so remarkable that compilers implement them faster than the existing adoption rate. And the adoption rate speaks volumes about existing capacity to port/rewrite big codebases in entirely new stacks. The new stacks also tend to have fewer custom static code quality analyzers from third-party vendors, and they are used a lot in mission-critical C++ codebases.

Re:Memory Safe Languages in Android 13 by lolinder on Thursday December 01, 2022 @05:10PM (#33823660)
> The new stacks also tend to have fewer custom static code quality analyzers from third-party vendors, and they are used a lot in mission-critical C++ codebases.

Are these static code quality analyzers detecting code quality problems that Rust and company are also vulnerable to? Or are they mostly looking out for the hundreds of legacy footguns that C++ still officially supports?

Re:Memory Safe Languages in Android 13 by ghostwriter on Thursday December 01, 2022 @05:39PM (#33823992)
They focus on quality control and compliance to safety requirements in specific domains and industries, for instance MISRA.
Re:Memory Safe Languages in Android 13 by estebank on Thursday December 01, 2022 @05:41PM (#33824019)
This might be of interest https://github.com/PolySync/misra-rust
Re:Memory Safe Languages in Android 13 by Ar-Curunir on Thursday December 01, 2022 @05:35PM (#33823947)
Google is one of the biggest C++ shops out there, and also authors and maintains many of the static analysis tools and safety features you mention.

If they’re saying that C++ can’t be saved, maybe they’re worth listening to.

Re:Memory Safe Languages in Android 13 by ghostwriter on Thursday December 01, 2022 @06:08PM (#33824330)
> If they’re saying that C++ can’t be saved, maybe they’re worth listening to.

It might be true, but it also sounds like an appeal to authority. I suspect there also might be voices that are being silenced or aren't given a similar platform to speak up and provide an alternative viewpoint on the matter within the same organisation, because <team budget/political reasons why>. After all, there are greenfield projects that are being started in C++20 and people are enthusiastic about their prospects. I wouldn't just blindly dismiss their reasons in favour of Google ones.

Re:Memory Safe Languages in Android 13 by aswanson on Thursday December 01, 2022 @06:29PM (#33824575)
C++ is needlessly complex and puts too much of a cognitive burden on the developer. I just wasted a day of my life traced to an errant semicolon in a legacy cpp base. I've used the language for 20 years. It can't be saved.
Re:Memory Safe Languages in Android 13 by saagarjha on Thursday December 01, 2022 @07:32PM (#33825180)
No offense, but I haven’t heard if people wasting days in semicolons outside of memes and really junior developers. What was the issue?
Re:Memory Safe Languages in Android 13 by aswanson on Thursday December 01, 2022 @08:11PM (#33825466)
In real-time systems with millions of lines of code, no debugging capabilities outside of logs, and user misuse use cases, you'd be surprised what can lurk beneath.
Re:Memory Safe Languages in Android 13 by j16sdiz on Friday December 02, 2022 @01:15AM (#33827426)
In my experience, a good, auto, code formatter helps alot. You can’t hide a semi colon from code formatter.
Re:Memory Safe Languages in Android 13 by galangalalgol on Friday December 02, 2022 @01:55AM (#33827689)
Are you suggesting a code formatter as a mechanism for static analysis? There are really good tools like coverity, and free ones like cppcheck and clang-tidy that will catch that and so much more. Using c++ without cppcheck and clang-tidy in your cmake and pipeline is like leaving the seat up. It takes so little time, and the benefits to others is great.

That said, they won't catch a ton of memory and thread safety issues. You'll need tests with 100% coverage for that. Or you could just write it in rust and the compiler will catch it.

Re:Memory Safe Languages in Android 13 by throw827474737 on Friday December 02, 2022 @06:52AM (#33829324)
If it was about a semicolon it even sounds more like running with not all warnings on. C++ is "bad" (shorting a lot) due to its compatibility being able to also compile last centuries code.. but if today on active code bases you are not even running with at least that, why would you ever switch to Rust?

And full agree, all what cppcheck does imo should have long gone into the warning suite, and Werror and Wall should be the default..

Re:Memory Safe Languages in Android 13 by MBCook on Friday December 02, 2022 @12:09AM (#33827047)
An appeal to authority is a fallacy because it doesn’t actually mean anything. It’s false credibility.

If the authority comes along with a bunch of well researched and documented data from experiences in the real world… that seems worth listening to.

It’s no longer an appeal to authority. It’s just looking at evidence.

Re:Memory Safe Languages in Android 13 by blub on Thursday December 01, 2022 @07:02PM (#33824894)
They’re not saying that C++ can or can’t be saved. And there’s no “they”, there are hundreds of teams with different expectations and policies.

You’re merely reading what you want between the lines.

Re:Memory Safe Languages in Android 13 by raggi on Thursday December 01, 2022 @09:57PM (#33826195)
True, but what is said is:

  We continue to invest in tools to improve the safety of our C/C++. Over the past few releases we’ve introduced the Scudo hardened allocator, HWASAN, GWP-ASAN, and KFENCE on production Android devices. We’ve also increased our fuzzing coverage on our existing code base. Vulnerabilities found using these tools contributed both to prevention of vulnerabilities in new code as well as vulnerabilities found in old code that are included in the above evaluation. These are important tools, and critically important for our C/C++ code. However, these alone do not account for the large shift in vulnerabilities that we’re seeing, and other projects that have deployed these technologies have not seen a major shift in their vulnerability composition. We believe Android’s ongoing shift from memory-unsafe to memory-safe languages is a major factor.
Re:Memory Safe Languages in Android 13 by throw827474737 on Friday December 02, 2022 @06:55AM (#33829342)
They "believe" the major shift is due to Rust, while they continously improve also their C++ tools, and the count in also all violations (even mabe more theoretical ones?) found by those .. I have no doubts about the actual claim, but especially this quite sounds like they may have made more out of this correlation==causation than there maybe is, I believe ;)
Re:Memory Safe Languages in Android 13 by UncleMeat on Friday December 02, 2022 @08:26AM (#33830135)
I know some of the people who own the tools described above. I can assure you that if those tools were the primary cause of the reduction in vuln they'd be screaming it from the hilltops. A huge amount of work at Google goes into answering questions like "what actually accounts for this change." This is one of the benefits of the promo culture that is often criticized.
Re:Memory Safe Languages in Android 13 by clnq on Thursday December 01, 2022 @07:05PM (#33824934)
Programming languages are tools for a job. As the saying goes, a bad workman blames his tools. It's not worth taking anyone who blames defects on a programming language too seriously, whether it's Google or not.

Modern C++ has many memory safety features. If a company has learned that its people fail to use them, then bad for them.

Of course, there are languages that abstract memory safety to the point that they eliminate those types of mistakes. But languages are tools for a job, and only some tools are applicable where C++ is applicable. We should not bury C++ prematurely before answering the question - "what else is as fast and efficient as to replace it for OOP?" And if a project doesn't need fast and efficient code, then why is it using C or C++ in the first place?

Overall, selecting the correct tool for a job is more important than figuring out which tool is better in some abstract way.

Re:Memory Safe Languages in Android 13 by mamcx on Thursday December 01, 2022 @07:33PM (#33825185)
> As the saying goes, a bad workman blames his tools.

And a good workman put his old/obsolete/dangerous/etc tool behind when something better show up.

The bad workman, instead, continue blaming his tools, when the problem is that he CONTINUE using bad tools, anyway!.

P.D: I learn about mechanical engineering. Get rid of bad tools fast is like key around that...

Re:Memory Safe Languages in Android 13 by ilyt on Friday December 02, 2022 @06:55AM (#33829341)
First rule of tool buying, never buy the cheapest for the safety-related tools. C/C++ IS the cheapest
Re:Memory Safe Languages in Android 13 by tptacek on Thursday December 01, 2022 @07:25PM (#33825116)
Modern C++ has many memory safety features. If a company has learned that its people fail to use them, then bad for them.

This recapitulates an argument at least as old as C89. You can probably find Usenet posts deploying it to argue against the adoption of strncpy, because if people don't know how to use sizeof and strlen, then bad for them.

Re:Memory Safe Languages in Android 13 by saagarjha on Thursday December 01, 2022 @07:32PM (#33825173)
strncpy is bad for other reasons, mind you.
Re:Memory Safe Languages in Android 13 by clnq on Thursday December 01, 2022 @08:23PM (#33825559)
Yes, my argument sounds similar. But it's in support of modernity rather than primitivism.

C++ nowadays can be used in a very memory-safe way without much effort. In my professional experience, memory leaks and corruptions are sporadic in modern C++ code and common in old-style pre-C++ 11 code.

That's why I'm a bit skeptical of this article from Google. It seems reasonable that Android has quite a lot of pre-C++ 11 code. And the article seems to lump two very different approaches to memory safety in pre and post-C++ 11 style programming.

Re:Memory Safe Languages in Android 13 by raggi on Thursday December 01, 2022 @09:27PM (#33825959)
You can do some basic analysis about your assumption: go pick out a bunch of the CVEs and look at the age and style of the source code.

Another approximation is to look at the Android source tree to see what proportion of it is as old as you assume in your argument. There are 431 results for a search `"Copyright 200" filepath:.\.cpp`. There are 7465 results for `"Copyright 201" filepath:.\.cpp`. 4152 results for `"Copyright 202" filepath:.\.cpp`. 220 for 2012, 354 for 2011. If you exclude tests the ratio is even less favorable for your theory.

In case you're wondering the project policy is to add a copyright header at the time the file is created, they do not update years in headers arbitrarily. As a spot check the first file matching "Copyright 200" that wasn't just essentially C code wrapped in extern "C" was: external/angle/src/libANGLE/Config.cpp. This file contains the use of std::make_pair.

You can perform these searches yourself here: https://cs.android.com/search?q=%22Copyright%20200%22%20file...

Re:Memory Safe Languages in Android 13 by clnq on Thursday December 01, 2022 @10:14PM (#33826303)
Thanks, that was very insightful. Yes, as you say, the copyright year in a .cpp/.h doesn't necessarily say whether C++ 11 features are used.

I've looked at many "Copyright 201" and "Copyright 202" headers. I needed to see more use of C++ 11 or equivalent smart pointers or containers to say that this codebase uses modern C++ memory safety features. Other modern C++ features (like std::make_pair that you mention) are easier to spot.

I expect this codebase to have many memory safety issues. It may not pass code review in a company/team that expects their people to use modern C++ memory safety features. After seeing it, I'm more convinced that the reason Google has so many problems with C++ in Android really is because they don't insist their engineers use modern C++ (or equivalent in-house containers/pointers).

Here's another insightful pair of searches:

" std::make_" filepath:.*\.cpp

"delete " filepath:.*\.cpp

Re:Memory Safe Languages in Android 13 by humanrebar on Friday December 02, 2022 @08:17AM (#33830058)
I mentioned this elsewhere, but the real A/B test here would be to do a rewrite in the existing language and compare it to doing a rewrite in Rust with respect to memory safety, etc.
Re:Memory Safe Languages in Android 13 by UncleMeat on Friday December 02, 2022 @08:33AM (#33830208)
"std::make_" isn't a great comparison (IMO) because Google has a widespread culture of noexcept so it wasn't critical to adopt this style for constructing smart pointers. std::unique_ptr<Foo>(new Foo()) was a thing for a while there. There is also an alternative absl::MakeUnique<T> that was available before we had std::make_unique available internally so you'll need to search for that too.

The style guide, C++ readability, and general code review has all but banned raw "new" for years and years. You can find plenty of CVEs where the root cause is a UAF on a managed object.

Re:Memory Safe Languages in Android 13 by clnq on Friday December 02, 2022 @10:22AM (#33831664)
Yes, there are more examples of smart pointer initialization than just std::make_. I couldn't find instances of "absl::Make" in Android Code Search. But your point still stands, and I should add that not all new-delete pairs are evil. With that said, what I've seen still has too many raw pointers.

Thanks for the context about UAF. I am curious about this. Much of my C++ experience comes from working with in-house reimplementations of std/stl, so my question might be a bit stupid, but how is use after freed of an obj managed by smart pointers so prevalent? Should the smart pointer not be nulled after the object is destroyed? Maybe you have a good example CVE? Are these cases of using the raw pointer in the smart pointer without checking it first?

Re:Memory Safe Languages in Android 13 by UncleMeat on Friday December 02, 2022 @10:55AM (#33832177)
> Should the smart pointer not be nulled after the object is destroyed?

I'm not sure what you are going for here.

The way this often happens is there is some module that owns an object with a unique_ptr and references to that object are used elsewhere. But the ownership of the object is complicated so a bug sneaks in where a non-owning reference to the object gets dereferenced after the unique_ptr is deleted. You can prevent this by having literally everything use shared_ptr for everything but that sucks for lots of reasons.

Re:Memory Safe Languages in Android 13 by clnq on Friday December 02, 2022 @01:33PM (#33834673)
There are also other smart pointers, like std::'s weak ptr and proprietary stuff.

You can avoid multi-ownership problems of shared ptrs with weak pointer member variables (which only need to be turned into shared in a given {} scope). Some other problems can be solved by marking objects as pending kill without destroying them immediately and ensuring all threads finish access before actual deletion.

Unreal Engine uses both weak pointers and object marking in a global object array. It also uses GC but that's besides the point.

Would the same approach to modern memory management not help Android?

Re:Memory Safe Languages in Android 13 by UncleMeat on Friday December 02, 2022 @02:10PM (#33835285)
Of course there are designs that help prevent bugs. Chrome is doing plenty of stuff like this but the ownership and lifetime design for something like a JIT are complex as hell and problems happen.

We've got like 30 years of people insisting that it really is possible to write safe C and C++ programs if you just follow the One True Way (TM) and its never been the case. Each new One True Way helps, but it sure as hell doesn't solve the problem altogether.

Re:Memory Safe Languages in Android 13 by jstimpfle on Friday December 02, 2022 @03:58AM (#33828315)
strncpy doesn't do what you want. Maybe you mean snprintf. Indeed use of sizeof, memcpy, and snprintf. Avoid strlen, it is rarely necessary.
Re:Memory Safe Languages in Android 13 by 3836293648 on Thursday December 01, 2022 @07:29PM (#33825147)
A bad workman may blame his tools, but a good workman uses the right tool for the job. If a better tool exists, use it.

(And sure, it doesn't apply to every niche yet, but it sure applies to a lot of them)

Re:Memory Safe Languages in Android 13 by Tuna-Fish on Thursday December 01, 2022 @08:05PM (#33825424)
> As the saying goes, a bad workman blames his tools. It's not worth taking anyone who blames defects on a programming language too seriously

Are you serious? A bad workman blames his tools, because workmen are reponsible for their tools. A large part of being a good workman is identifying what tools are good and using them.

And C++ is a terrible tool for any task where you are not forced to use it because of existing libraries. All the memory safety features of modern C++ are a tiny, almost vanishingly small step in the right direction.

> "what else is as fast and efficient as to replace it for OOP?" And if a project doesn't need fast and efficient code, then why is it using C or C++ in the first place?

If you need fast and efficient code, why on earth would you be doing OOP?

Re:Memory Safe Languages in Android 13 by clnq on Thursday December 01, 2022 @10:29PM (#33826408)
> A bad workman blames his tools, because workmen are reponsible for their tools. A large part of being a good workman is identifying what tools are good and using them.

As I said in the comment to which you are responding, "selecting the correct tool for a job is more important than figuring out which tool is better in some abstract way."

> C++ is a terrible tool for any task where you are not forced to use it

Many game developers, OS developers, and massive hardware-software makers doing embedded programming who use C++ would disagree. What would you say to them?

> If you need fast and efficient code, why on earth would you be doing OOP?

For small projects, I could agree. What would your recommended alternative be for massive codebases in large tech companies that need fast and efficient code?

P.S. Please read https://news.ycombinator.com/newsguidelines.html about snarky comments. Thanks.

Re:Memory Safe Languages in Android 13 by pizza234 on Friday December 02, 2022 @07:42AM (#33829758)
> For small projects, I could agree. What would your recommended alternative be for massive codebases in large tech companies that need fast and efficient code?

The poster wrote very clearly:

> where you are not forced to use it

If one is forced, there's obviously no option.

The idea is not that C/C++ should be replaced right now, rather, that devs finally understand that C/C++ should not be used where possible.

I actually see this pattern used by some, who defend C/++: "C/++" should be deprecated" - "No, it's impossible to eliminate C/++ today".

Deprecation is not elimination. Linux started introducing it, and Google is doing as well, so it can be done gradually.

Re:Memory Safe Languages in Android 13 by ilyt on Friday December 02, 2022 @06:53AM (#33829330)
>> As the saying goes, a bad workman blames his tools. It's not worth taking anyone who blames defects on a programming language too seriously

>Are you serious? A bad workman blames his tools, because workmen are reponsible for their tools. A large part of being a good workman is identifying what tools are good and using them.

Also C/C++ made into real life tools would be OHSA violation on OHSA violation in real world

Re:Memory Safe Languages in Android 13 by raggi on Thursday December 01, 2022 @09:08PM (#33825815)
> We should not bury C++ prematurely before answering the question - "what else is as fast and efficient as to replace it for OOP?"

We have an answer: Rust. It's no longer premature, bury it.

Re:Memory Safe Languages in Android 13 by aswanson on Thursday December 01, 2022 @09:25PM (#33825945)
Amen.
Re:Memory Safe Languages in Android 13 by j16sdiz on Friday December 02, 2022 @01:23AM (#33827471)
Rust is over engineered in some area, immature in other.

See how many reference types are there, how async is handled and the underspecified unsafe semantic.

For higher level tasks, I prefer a language with GC like go or java. Rust can work with references counting, but it don’t mix well with the larger ecosystem. For lower level task, the underspecified unsafe model make it worse than C aliasing problem

Re:Memory Safe Languages in Android 13 by unrealhoang on Friday December 02, 2022 @01:35AM (#33827557)
> See how many reference types are there,

2, & and &mut. What else?

Re:Memory Safe Languages in Android 13 by kaba0 on Friday December 02, 2022 @02:12AM (#33827780)
I guess parent meant ARC, RC, and the like.
Re:Memory Safe Languages in Android 13 by ilyt on Friday December 02, 2022 @06:58AM (#33829378)
I vastly prefer "just write you code serially and never worry about async then spawn 10000 goroutines" approach over async/await/Future nexus of bad ideas (just do message passing like Erlang or don't do it at all...), but I wouldn't use Go in place where I'd use Rust and vice versa, they kinda feel different (if overlapping in places) niche
Re:Memory Safe Languages in Android 13 by lanstin on Friday December 02, 2022 @11:34AM (#33832733)
It is very freeing. And one concise readable go routine doing the channel reads and the socket ops becomes your connection pool, but is as easy to understand as a Network programming 101 assignment.
Re:Memory Safe Languages in Android 13 by verdagon on Friday December 02, 2022 @01:45AM (#33827625)
How's Rust at doing OOP these days? (Assuming we're in a domain or situation where OOP is a good choice, of course.)

I would love to know about any projects that do OOP well in Rust.

Re:Memory Safe Languages in Android 13 by nicoburns on Friday December 02, 2022 @04:55AM (#33828644)
IMO Rust has most of the best bits of OOP (the ability to encapsulate functionality in an object with private fields and present a restricted public interface), without the bad bits (inheritance, and complex soups of objects all holding pointers to each other that make code flow hard to reason about)
Re:Memory Safe Languages in Android 13 by HideousKojima on Friday December 02, 2022 @02:12AM (#33827778)
Rust isn't OOP though. Structs, traits, etc. let you approximate some aspects of OOP, but not much more than plain old C does.
Re:Memory Safe Languages in Android 13 by hardware2win on Friday December 02, 2022 @03:57AM (#33828306)
Languages encourage or prevent its users from doing things

Concepts like sugar syntax and syntax salt do exist

Approaches to problems may vary by languages because lang environment shapes its users in some ways

Re:Memory Safe Languages in Android 13 by logicchains on Thursday December 01, 2022 @11:08PM (#33826657)
>If they’re saying that C++ can’t be saved, maybe they’re worth listening to.

Google's one of the worst C++ shops because their code standard basically forbids using modern C++, and their C++ is more like 90s Java than modern C++. It's no wonder they want to get away from it.

Re:Memory Safe Languages in Android 13 by Xorlev on Thursday December 01, 2022 @11:31PM (#33826806)
I...what?

I write C++ at Google, and it encourages use of modern C++ features, and many things you see adopted in std have roots in our libraries.

I'm curious what you think Google prevents us from using and why you think our C++ is like 90s Java.

https://abseil.io/tips has a lot of our philosophies and abseil is chunks of our internal libraries published externally.

Re:Memory Safe Languages in Android 13 by UncleMeat on Friday December 02, 2022 @08:28AM (#33830157)
I've weirdly heard people say this in the past too and I am equally baffled.

I think it stems from the fact that Google was slow at making C++11 available internally so there was a period of time where the rest of the world was using smart pointers and we couldn't. That may have just solidified a "Google uses old C++" meme out in the wild despite it being wildly out of date.

Re:Memory Safe Languages in Android 13 by kaba0 on Friday December 02, 2022 @02:08AM (#33827758)
Google’s C++ coding guide is (was?) not really up-to-date, so there is that.

Modern C++ is indeed a huge upgrade on what came before and with a good amount of static and dynamic analysis the state of low-level programming is much better now, but there really is no reason for new programs to be written with these. Besides the bottom of the stack, managed languages are more than fast enough for nigh everything.

Re:Memory Safe Languages in Android 13 by rob74 on Friday December 02, 2022 @02:47AM (#33827948)
> Besides the bottom of the stack, managed languages are more than fast enough for nigh everything

And yet, there is a lot of enthusiasm (at least here on HN) for web development in Rust...

Re:Memory Safe Languages in Android 13 by UncleMeat on Friday December 02, 2022 @08:22AM (#33830101)
There are plenty of people who want to write in Rust for the fun of it. But I'm not aware of too many people saying that you should avoid writing a web application in java/python/js in favor of rust. Pretty much the only people being told to stop doing what they are doing are the people starting new projects that process untrusted data in C and C++.
Re:Memory Safe Languages in Android 13 by steveklabnik on Friday December 02, 2022 @09:36AM (#33830917)
You and your parent are saying slightly different things with regards to web dev; they said there's enthusiasm for doing it, not that you shouldn't write web applications in those languages.

Someone can think it's fine to write a web application in java/python/js and Rust.

Re:Memory Safe Languages in Android 13 by bitexploder on Friday December 02, 2022 @07:53AM (#33829842)
Never mind you don’t give up any performance to use Rust anyway. They focused heavily on only incorporating features with zero cost abstractions.
Re:Memory Safe Languages in Android 13 by humanrebar on Friday December 02, 2022 @08:13AM (#33830024)
Google is great at engineering projects that look great in promotion packets. Just because they're big and funded doesn't mean they're good at this.

It seems plausible that splashy projects in new languages are better for careers than grinding through "stable" codebases using "boring" engineering practices.

I also gather that Google has a challenge, possibly for similar reasons, keeping their third party dependencies updated and up to standards. A lot of those are written in C and C++, probably.

Re:Memory Safe Languages in Android 13 by UncleMeat on Friday December 02, 2022 @08:20AM (#33830083)
//third_party is indeed a challenge, but it is definitely not the case that vulns are only coming from //third_party. I mean, the linked article is about the Android codebase (not attached to //third_party) and the Chrome codebase publishes a ton of vuln data (again, not attached to //third_party).
Re:Memory Safe Languages in Android 13 by humanrebar on Friday December 02, 2022 @10:01AM (#33831340)
I was saying Google might be pessimistic about C and C++ for some reasons specific to Google culture, like inability to get engineers to care about "boring" work. I wasn't making the point you're addressing.
Re:Memory Safe Languages in Android 13 by UncleMeat on Friday December 02, 2022 @10:17AM (#33831592)
I assure you that "fix vulns caused by memory safety issues through some means other than a total language shift" is not boring work, but the sort of problem that will happily get people promoted to L8. It is just hard as hell.
Re:Memory Safe Languages in Android 13 by humanrebar on Friday December 02, 2022 @05:43PM (#33837988)
I more meant the mid range engineer work to just buckle down, test, and fix things. As in, just owning and cleaning up a lot of important projects, including third party ones.

Designing the ultimate everything sanitizer with zero performance overhead would surely be impressive even at Google. Especially if it was actually adopted across the org.

Re:Memory Safe Languages in Android 13 by UncleMeat on Saturday December 03, 2022 @07:23AM (#33842944)
But "buckle down and own it" doesn't actually prevent vulns in any sort of systematic way.

And I assure you that, despite the memes, code health efforts do end up with promos here. The org responsible for third_party and large scale code health had above average promo rates for ages.

Re:Memory Safe Languages in Android 13 by tulio_ribeiro on Friday December 02, 2022 @04:03AM (#33828340)
While new safety features in C++ may be impressive, Google's data shows that memory safety vulnerabilities are still a major issue. Switching to a memory-safe language like Rust can help reduce the risk of vulnerabilities and improve the overall security and reliability of a product. The potential benefits make it a worthwhile investment, even if it requires some effort to migrate from C++. #RustIsTheRealDeal
Re:Memory Safe Languages in Android 13 by humanrebar on Friday December 02, 2022 @08:08AM (#33829983)
How much of the benefit comes from the rewrite itself? A more precise comparison would be rewriting that C or C++ in the same language but with memory safety in mind and see how things turned out.

The same question comes up when an existing system is rewritten from language A to language B and big performance gains are seen. The language could be the big cause, but so could the extra engineering effort itself -- updated design, fresh attention to the requirements, etc.

Re:Memory Safe Languages in Android 13 by lolinder on Friday December 02, 2022 @09:46AM (#33831087)
Google isn't rewriting more now than they were before, they're just discussing the use of C/C++ for new code. Presumably, if rewriting chunks of code were enough in its own right, they would never have had so many critical security flaws.
Re:Memory Safe Languages in Android 13 by clnq on Friday December 02, 2022 @10:33AM (#33831836)
> if rewriting chunks of code were enough in its own right, they would never have had so many critical security flaws.

Reducing defects is one of the main reasons (others being maintainability, readability, better integration, and similar) for refactoring and rewriting code. There's usually not enough time/money to do it, especially for large codebases.

I quite like rewriting parts of a codebase to modernize it, and I have often closed tons of bugs in a short time this way. It is definitely effective. But not as cost-effective as deprioritizing bugs into "won't fix" territory, which is what many companies like to do.

Re:Memory Safe Languages in Android 13 by humanrebar on Friday December 02, 2022 @10:03AM (#33831375)
I also agree that it's a presumption. I don't know that I agree with it is all. It seems like more engineering attention and excitement is actually good for project quality, and maybe that's a confounding factor here. More data would help, though all this might never be definitively conclusive.
Re:Memory Safe Languages in Android 13 by UncleMeat on Friday December 02, 2022 @08:16AM (#33830049)
And yet, people still store a string_view in a field and then access it past the lifetime of the underlying string.

Yes, things have gotten better. Smart pointers are a godsend. Sanitizers are a godsend. Various static analysis tools work pretty well.

But even codebases that adopt all of these things religiously still are riddled with security vulns.

Re:Memory Safe Languages in Android 13 by ncr100 on Thursday December 01, 2022 @09:02PM (#33825775)
Members of the C++ community are working on fixing that. The Herb Sutter CPP2 idea:

https://www.youtube.com/watch?v=ELeZAKCN4tY

Re:Memory Safe Languages in Android 13 by UncleMeat on Friday December 02, 2022 @08:49AM (#33830354)
cpp2 is more about freeing c++ from its syntax nightmare rather than making it a safe language to work with.
Re:Memory Safe Languages in Android 13 by tulio_ribeiro on Friday December 02, 2022 @03:58AM (#33828316)
Ah, yes, the age-old debate of memory safety vs. total bug count. It's like choosing between having a really bad headache or a really bad cold - either way, you're still feeling pretty lousy. But in all seriousness, I think Google's data shows that prioritizing memory safety can have a significant impact on the overall security of a product. I'm sure the C/C++ defenders will continue to argue their case, but at least now they have some hard numbers to contend with.

#RustForTheWin

Re:Memory Safe Languages in Android 13 by peoplefromibiza on Friday December 02, 2022 @06:43AM (#33829253)
> Defenders of C/C++ frequently note that memory safety bugs aren't a significant percentage of the total bug count

Well, first of all, this is said but not proven.

But it's easy to prove that memory safety bugs are not a significant percentage of the total number of bugs, even Google agrees.

Vulnerabilities are not the same thing as bugs, a vulnerability like spectre or meltdown are not due to a bug in the software, have an ubiquitous immediate impact on 100% of the devices and are much harder to fix or mitigate, sometimes it's could even prove impossible.

The same bias can be explained using the exact same words used in the article

"Despite most of the existing code in Android being in C/C++, most of Android’s API surface is implemented in Java. This means that Java is disproportionately represented in the OS’s attack surface that is reachable by apps."

It can be read as: of course most of the vulnerabilities are due to memory safety bugs, it's much harder to gain root privileges exploiting a bug on the colors of a specific element of the UI, assuming it would be possible.

It can also be read as: most of the userland software is based on Java, which is memory safe by default, assuming there are no bugs in the implementation of the JVM, which is entirely not Java.

Given that, the problems become

- rewriting the entire ecosystem in memory safe languages requires rewriting everything from scratch, which is a task that even Google will have huge problems to complete (reminder: Google is the number one killer of its own projects) in reasonable time or without wasting more money that it's worth on it. Is an half complete not battle tested complete rewrite actually safer? Historical data says it usually isn't.

- are the user actually safer when memory is safe? I mean, memory safety bugs gave us jailbreaking for locked devices, memory safe languages gave us bugs like CVE-2021-44832

I wouldn't classify the issue as black/white, there's a lot of grey to be considered.

Re:Memory Safe Languages in Android 13 by ilyt on Friday December 02, 2022 @06:49AM (#33829314)
> Vulnerabilities are not the same thing as bugs, a vulnerability like spectre or meltdown are not due to a bug in the software, have an ubiquitous immediate impact on 100% of the devices and are much harder to fix or mitigate, sometimes it's could even prove impossible.

Using language-independent bug example in discussion about language-caused bug vectors isn't exactly honest.

Rust would stop Heartbleed for example, and that was one of huge vulnerabilities

Re:Memory Safe Languages in Android 13 by peoplefromibiza on Friday December 02, 2022 @07:26AM (#33829643)
> Rust would stop Heartbleed for example, and that was one of huge vulnerabilities

using a low budget project with few developers maintaining one of the most used libraries in the whole World as an example of non memory safe languages perils is not exactly honest.

Heartbleed could have been easily fixed if the companies profiting from using OpenSSL donated a few more eyes to look at the code.

Similarly to what happened to Log4j bug, which had an enormous impact, similar to the heartbleed one and affected a fully memory safe language.

Re:Memory Safe Languages in Android 13 by fiedzia on Friday December 02, 2022 @10:42AM (#33831975)
> using a low budget project with few developers maintaining one of the most used libraries in the whole World as an example of non memory safe languages perils is not exactly honest

Why? That's the situation of enormous amount of code people use.

Re:Memory Safe Languages in Android 13 by peoplefromibiza on Friday December 02, 2022 @02:32PM (#33835607)
because Log4j is part of that enormous amount of code you talk about and it's probably used by much less experienced programmers on average, because Java it's safe by design, isn't it?

Anyway heartbleed was discovered after many years, let's wait the same many years and see what kind of bugs we'll find in code written today with different languages.

Full disclaimer: I do not write C code since long time ago and have no intention of going back, but dogmatic programmers that believe in "saviours" are a real mistery to me.

The same people forgetting to free a resource are the same people that will forget to sanitize some input, meaning all of us make mistakes and will keep making them, in any language and those mistakes will be abused by some malevolent actor.

Google problems are not everyone's problems.

Goggle's solutions to problems are not everyone's solutions to the same problems.

Assuming that what Google says is applicable everywhere is at best naive.

Re:Memory Safe Languages in Android 13 by fiedzia on Saturday December 03, 2022 @08:25AM (#33843279)
> all of us make mistakes and will keep making them, in any language

.. unless said language makes making those mistakes difficult or impossible. Sanitizing input for example has not been an issue for me for decades, as every framework I used handles that by default, I'd have to work extra hard to make a mistake there.

> Google problems are not everyone's problems.

In this case they are. Not only memory safety is an issue for many codebases that have at least some C somewhere, but also because Google products are used by milions.

> Goggle's solutions to problems are not everyone's solutions to the same problems. > Assuming that what Google says is applicable everywhere is at best naive

Any other time I'd agree with you, but I don't see anything Google-specific here.

Re:Memory Safe Languages in Android 13 by peoplefromibiza on Saturday December 03, 2022 @05:10PM (#33847960)
> unless said language makes making those mistakes difficult or impossible

You're missing the point [1]

(or I was unclear)

Yes, improvements in neuro surgery can save lives, but the bulk of preventable deaths it's in human mistakes [2] that are almost impossible to make impossible.

Just like the majority of the bugs are not prevented using rust, just a minority of them, which are also arguably the hardest to find and exploit, while a SQL injection can be exploid by a script kiddie with average IQ.

[1] https://portswigger.net/daily-swig/mastodon-users-vulnerable...

[2] The three risk factors most commonly leading to preventable death in the population of the United States are smoking, high blood pressure, and being overweight.

Re:Memory Safe Languages in Android 13 by fiedzia on Monday December 05, 2022 @06:58AM (#33864403)
> Just like the majority of the bugs are not prevented using rust,

"For more than a decade, memory safety vulnerabilities have consistently represented more than 65% of vulnerabilities". That's not minority. We are getting into minority territory now because of Rust and other memory-safe languages.

> while a SQL injection can be exploid by a script kiddie with average IQ.

Use any framework and it's solved problem.