6 ms·
Strict memcpy() bounds checking for the Linux kernel
- pjmlp 5y agoThe only way it will really work, is as Solaris SPARC has been doing for years, and Google is in the process of adopting for ARM based Android devices, hardware memory tagging. Unfortunately Intel keeps borking their attempts to do the same.
- usr1106 5y agoFor those who like myself wonder what this hardware tagging is: https://lwn.net/Articles/834289/ https://lwn.net/Articles/834289/
- tialaramex 5y agoA bunch of the cases covered here are far too niche for memory tagging. For example if a routine wants to quickly zero fields pkt.mask pkt.sent pkt.copied pkt.recvd, pkt.ackd, and pkt.ready but "obviously" not the other members of the pkt structure, somebody will write code that zeroes out the whole stretch of the pkt structure from "mask" to "ready" inclusive, and then comment in the structure definition that it's important not to re-arrange these members. And that's faster, and it works. Now, suppose I'm a bad guy & I'm able to fool a routine into calling the zero-out function with any range I like instead of just the range from "mask" to "ready". Memory tagging might prevent me clearing the adjacent structure, but all I want to do is smash pkt.uid to zero so that I can become root and that's just part of pkt...
- pjmlp 5y agoNaturally given C's nature as pseudo-macro assembler, there will always ways to work around the mitigations, see iOS PAC exploits, however them not being there is even worse as proven by the numbers from Google and Microsoft security reports.
- notorandit 5y ago> The C programming language is famously prone to memory-safety problems. I thought it was the programmer to make mistakes, not the language to be error prone.
- masklinn 5y agoA language which is not error prone will usually lead to a combination of the programmer making less mistakes and the language catching those mistakes the programmer makes (whether at compile-time or runtime, or more problematically attempting to DWIM those mistakes thankfully language design has rather moved away from that very bad idea). Programmers making mistakes is a fact of life, that C is error-prone is what makes those mistakes into significant and recurring issues.
- fragbait65 5y agoWell, I do think a programming language is a tool and it is kind of wrong to blame the tool for the mistakes made by the one wielding it. The problem with C is that it's a tool where you have no safety and I don't think there's a programmer alive that can actually use it in a safe manner. I guess some are close, but they will still end up with the occasional wound here and there on their bodies... I would probably avoid using C for anything I put in production today, I still love the language though. It still feels special, sitting down with all that power at your fingertips knowing that you'll have a built in buffer overflow if you lose focus for a second, gets (no pun intended) my blood flowing! :-)
- adwn 5y ago> it is kind of wrong to blame the tool for the mistakes made by the one wielding it I strongly disagree. I think it is absolutely legitimate to blame a tool which is practically impossible to use correctly [1]. Some of C's design decisions were justified in its historical context, and some – like zero-terminated strings – were indefensible even back then. [1] Alternatively, you could blame its creators, but that's not very useful.
- flohofwoe 5y ago
- kortex 5y agoRelevant in 2009, relevant today: C's biggest mistake: https://www.digitalmars.com/articles/C-biggest-mistake.html https://www.digitalmars.com/articles/C-biggest-mistake.html C uses (pseudo)fat pointers all the time, any time an array(pointer) is passed with size (as a second argument). It's just not as hygienic. Just think of all the dev hours, all the painful debugging, all the exploits prevented, if in the 80's they put out a stdlib with a fat pointer buffer type. Can't argue they didn't know better, as plenty of languages had them by then.
- pjmlp 5y agoLanguages already had them in 1950's, e.g. JOVIAL, but is was more fun to create their own.