LWN: Comments on "Stagefrightening" https://lwn.net/Articles/652728/ This is a special feed containing comments posted to the individual LWN article titled "Stagefrightening". en-us Sun, 05 Oct 2025 02:43:14 +0000 Sun, 05 Oct 2025 02:43:14 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Stagefrightening https://lwn.net/Articles/653439/ https://lwn.net/Articles/653439/ ortalo <div class="FormattedComment"> IMHO, we need much more work like yours.<br> I have tried to be an advocate of this need for several years now (possibly decades), but not very successfully to say the least. The fact that it is a difficult technical topic (arcane for the general public) and that many people in (or more precisely around) computer security either dream of or claim impossible things certainly does not help.<br> <p> But anyway, Coccinelle + Smatch, even if you factor in the compiler writers efforts, Coverity and one time research things like Astree, that's not enough (it spans a decade...).<br> <p> Note that while thinking about it, that's a pretty general problem wrt computer security: investment is extremely ill-managed. Look at all those ordinay users happily paying every month for antivirus software (now for their Android smartphone also), at governemental or private funding for legal study of the cyberspace or cyberwarfare attack tools and all the difficulties you have actually funding decently security communication libraries, static analysers development, compilers enhancement, etc.<br> <p> We lack some public authority with the capability to evaluate objectively these state of facts on computer security issues at macro levels. (Similar to what CERTs do at the elementary vulnerability level or maybe IETF on Internet issues.)<br> <p> Governance is our problem now in this field. (Which is the elegant way to say that the people who have the money are inadequate.)<br> <p> </div> Tue, 04 Aug 2015 09:11:51 +0000 Stagefrightening https://lwn.net/Articles/653418/ https://lwn.net/Articles/653418/ kleptog <div class="FormattedComment"> <font class="QuotedText">&gt; &gt; It's not these these features don't exist, it's that (a) they're not standardised</font><br> <p> <font class="QuotedText">&gt;Why would this matter for, at least, the kernel?</font><br> <p> For the kernel it doesn't matter so much, other than it's new (GCC 5.0 new to be precise). But you could probably whip these up in an afternoon in assembly if you wanted to, I think it's telling that this hasn't happened. You don't need compiler support to make these functions, it just makes it easier. The kernel devs could have implemented it years ago if they wanted to.<br> <p> For all user space applications not being standardised makes it hard because you'd really rather not rely on special compiler features.<br> <p> </div> Mon, 03 Aug 2015 21:08:18 +0000 Stagefrightening https://lwn.net/Articles/653294/ https://lwn.net/Articles/653294/ jezuch <div class="FormattedComment"> My experience with static analyzers is that they protect you from silly mistakes. Like using instanceof on a variable that can never refer to an object of this type. Or that this field is accessed from these methods but is inconsistently synchronized. Which is great but kind of underwhelming. I don't think I've seen anything that would detect serious architectural problems.<br> </div> Mon, 03 Aug 2015 07:51:40 +0000 Stagefrightening https://lwn.net/Articles/653264/ https://lwn.net/Articles/653264/ mathstuf <div class="FormattedComment"> Yep, much better interface there since you don't waste the computation.<br> <p> <font class="QuotedText">&gt; It's not these these features don't exist, it's that (a) they're not standardised</font><br> <p> Why would this matter for, at least, the kernel?<br> </div> Sun, 02 Aug 2015 13:03:19 +0000 Stagefrightening https://lwn.net/Articles/653258/ https://lwn.net/Articles/653258/ PaXTeam <div class="FormattedComment"> how about something like these instead:<br> <p> <a href="http://clang.llvm.org/docs/LanguageExtensions.html#checked-arithmetic-builtins">http://clang.llvm.org/docs/LanguageExtensions.html#checke...</a><br> <a href="https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html">https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Built...</a><br> <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61129">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61129</a><br> </div> Sun, 02 Aug 2015 11:31:40 +0000 Stagefrightening https://lwn.net/Articles/653257/ https://lwn.net/Articles/653257/ kleptog <div class="FormattedComment"> In gcc you can just say: if(__builtin_add_overflow(foo, bar, &amp;sum)) { error("Overflow"); }<br> <p> See: <a href="https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html">https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Built...</a><br> <p> Other compilers have similar features: <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ff521693%28v=vs.85%29.aspx">https://msdn.microsoft.com/en-us/library/windows/desktop/...</a><br> <p> It's not these these features don't exist, it's that (a) they're not standardised and (b) people aren't using them.<br> </div> Sun, 02 Aug 2015 11:14:14 +0000 Stagefrightening https://lwn.net/Articles/653252/ https://lwn.net/Articles/653252/ peter-b <div class="FormattedComment"> <font class="QuotedText">&gt; Also we often use integer overflows to test for integer overflows like this "if (foo + bar &lt; foo)".</font><br> <p> When doing code reviews, I usually like to see "if (foo &gt; UINT32_MAX - bar)", for example, because it detects overflows a priori rather than a posteriori. On the other hand, it requires you to use the correct limit macro. I agree with mathstuff that a "__builtin_will_overflow()" in the compiler would be nice to have.<br> </div> Sun, 02 Aug 2015 08:43:36 +0000 Stagefrightening https://lwn.net/Articles/653246/ https://lwn.net/Articles/653246/ spender <div class="FormattedComment"> Another big problem (maybe added under the "safe" overflow category) when dealing with integer overflows via GCC plugins is dealing with the various translation units in GCC that introduce (intentional) integer overflows not present in the source code. This has been the main source of false-positives in the past for PaX's size_overflow plugin.<br> <p> -Brad<br> </div> Sun, 02 Aug 2015 02:59:02 +0000 Stagefrightening https://lwn.net/Articles/653241/ https://lwn.net/Articles/653241/ mathstuf <div class="FormattedComment"> <font class="QuotedText">&gt; Also we often use integer overflows to test for integer overflows like this "if (foo + bar &lt; foo)".</font><br> <p> Sounds like something worth a __builtin_will_overflow function to explicitly denote such uses.<br> </div> Sat, 01 Aug 2015 23:56:32 +0000 Stagefrightening https://lwn.net/Articles/653024/ https://lwn.net/Articles/653024/ error27 <div class="FormattedComment"> The article suggests that this bug was probably an integer overflow. If you yse the `git log --all-match --grep integer --grep overflow --no-merges` on the kernel source then I am among the winners (Dan Carpenter).<br> <p> 1 25 Author: Thomas Meyer &lt;thomas@m3y3r.de&gt;<br> 2 25 Author: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;<br> 3 24 Author: Xi Wang &lt;xi.wang@gmail.com&gt;<br> 4 9 Author: Dan Carpenter &lt;error27@gmail.com&gt;<br> 5 7 Author: Guenter Roeck &lt;linux@roeck-us.net&gt;<br> 6 5 Author: Wenliang Fan &lt;fanwlexca@gmail.com&gt;<br> 7 5 Author: Paul E. McKenney &lt;paulmck@linux.vnet.ibm.com&gt;<br> 8 4 Author: Haogang Chen &lt;haogangchen@gmail.com&gt;<br> 9 4 Author: Brian Norris &lt;computersforpeace@gmail.com&gt;<br> 10 4 Author: Andrey Ryabinin &lt;a.ryabinin@samsung.com&gt;<br> <p> Thomas Meyer used a Coccinelle script to switch calls from kzalloc() to kcalloc(), it's a good thing to do for code hardening, but it's not bug fixes. Xi Wang was doing PHD work at MIT (<a href="http://pdos.csail.mit.edu/~xi/">http://pdos.csail.mit.edu/~xi/</a>).<br> <p> I used custom Smatch (<a href="http://smatch.sf.net">http://smatch.sf.net</a>) checks to find my integer overflow bugs. Even though the Smatch checks were useful, I haven't released them because they have too many false positives. Of course, a bad person could easily spend a week looking through false positives and feel good if he found one real bug, but for a normal dev that would be a waste of time. These things are asymmetric. :/<br> <p> Basically, there are few static checkers which can find integer overflows. It's harder than finding buffer overflows. You have to know which data can be trusted an which comes from untrusted sources. You have to track two variables instead of one. You have to do cross function analysis. There are a lot of integer overflows which we don't care about. There are some integer overflows which are safe. Also we often use integer overflows to test for integer overflows like this "if (foo + bar &lt; foo)".<br> <p> Out of open source static checkers, Smatch comes the closest, but it is still too rough and it has only been tuned for the linux kernel. Btw, there are some runtime integer detection tools. PaX has done some work with this and Xi Wang.<br> </div> Sat, 01 Aug 2015 09:57:28 +0000 Stagefrightening https://lwn.net/Articles/653078/ https://lwn.net/Articles/653078/ ortalo <div class="FormattedComment"> Kudos to you. And when you become the master, do not forget to impose on all your padawans the rules needed to share this excitement.<br> After all, programs writing programs are at the heart of our art... ;-)<br> </div> Fri, 31 Jul 2015 15:46:16 +0000 immoral or amoral? It's all about perspective https://lwn.net/Articles/653015/ https://lwn.net/Articles/653015/ pr1268 <p>I dunno... Myself, not knowing there was a difference in the two words' meaning, looked each up. Slightly bending the definition of <a href="https://en.wiktionary.org/wiki/amoral">amoral</a> from &quot;neither <a href="https://en.wiktionary.org/wiki/moral">moral</a> nor <a href="https://en.wiktionary.org/wiki/immoral">immoral</a>&quot; to being <i>both</i>, then amoral would fit just fine.</p> <p>Granted, from the device user's perspective, intentionally neglecting to patch a vulnerability in the interest of new device sales would surely be considered immoral. From Google's senior management team, it could be considered <i>moral</i>.</p> <p>Of course, this could also be extended to the wireless providers&mdash;their complicity in this matter is certainly <strike>moral</strike> I mean <strike>immoral</strike> Er, <strike>amoral</strike> just pick one! &#9786;</p> Fri, 31 Jul 2015 12:38:16 +0000 Stagefrightening https://lwn.net/Articles/653012/ https://lwn.net/Articles/653012/ jezuch <div class="FormattedComment"> <font class="QuotedText">&gt; If I were more cynical, I might make suggestions that a lot of the "engineers" writing this code would consider such tools to "get in their way" and are even an affront to their "programming prowess".</font><br> <p> I am not one of those "engineers". I get excited every time findbugs (static analysis tool for Java) adds a new detector and immediately start scanning all of the code under my care :) The same for pedantic warning settings in the compiler.<br> </div> Fri, 31 Jul 2015 09:45:36 +0000 Stagefrightening https://lwn.net/Articles/653000/ https://lwn.net/Articles/653000/ NAR <div class="FormattedComment"> The problem is that static analyzers don't make the code flawless. I remember a "sales pitch" for an Erlang product, they said that practically all of the reported bugs were the kind of "software did what the developer wanted to do, not what the user wanted to do". Static analyzers may decrease the number of some kind of bugs, but definitely not eliminate all bugs. So the choice is between "slower development, less features, (hopefully) less bugs" and "faster development, more features, (probably) more bugs".<br> </div> Fri, 31 Jul 2015 07:56:41 +0000 Stagefrightening https://lwn.net/Articles/652962/ https://lwn.net/Articles/652962/ ms <div class="FormattedComment"> Why is that a poor story? Tools are awkward and tricky to use until they get regular use and get polished by that. Remember how awful the first editors were?<br> The tools will get better once they are mandated for any code that is ever fed untrusted inputs. I'd rather have fewer features and slower code but code that is flawless than a billion insecure and badly implemented features. Slowly, more people may come to agree with this.<br> </div> Thu, 30 Jul 2015 18:34:54 +0000 Stagefrightening https://lwn.net/Articles/652953/ https://lwn.net/Articles/652953/ jhoblitt <div class="FormattedComment"> There's no shortage of static analysis tools out there. However, it's a pretty poor story to tell developers if you just run these 10+ tools, and manually pick through the massive number of false positives, your code is _less likely_ to have a major security issue.<br> <p> <a href="https://en.wikipedia.org/wiki/List_of_tools_for_static_code_analysis#C.2FC.2B.2B">https://en.wikipedia.org/wiki/List_of_tools_for_static_co...</a><br> <p> The analysis tools and languages need to evolve significantly to keep the development work-flow at a reasonable level of complexity. Start holding your breath...<br> </div> Thu, 30 Jul 2015 16:58:01 +0000 Corporations only understand liability https://lwn.net/Articles/652941/ https://lwn.net/Articles/652941/ brugolsky <div class="FormattedComment"> The solution to the problem of embedded firmware is liability throughout the manufacturing and distribution chain. The only safe harbor should be independently buildable open source, subject to a "standard of care" that requires little more than a USB/Bluetooth/WiFi/... connection to the device and "git clone ... &amp;&amp; cd ... &amp;&amp; make build install push" or similar. That should include fully user-replaceable keys for all secured components. Manufacturers that are fond of putting DRM in their products should state in appropriate documentation and marketing literature that user-modified software that impairs DRM will disable specific functionality.<br> </div> Thu, 30 Jul 2015 16:04:33 +0000 Stagefrightening https://lwn.net/Articles/652881/ https://lwn.net/Articles/652881/ ortalo <div class="FormattedComment"> It's also heavily uneffective: you *may* get some corrections but you *probably* get more new vulnerabilities too.<br> <p> In fact, sometimes it seems the sure-fire way to get a security improvement is to downgrade to an old dumb phone; though this does nothing to try to solve the problem of course.<br> <p> </div> Thu, 30 Jul 2015 13:24:40 +0000 Stagefrightening https://lwn.net/Articles/652880/ https://lwn.net/Articles/652880/ ortalo <div class="FormattedComment"> I am not as optimistic as you. (Seriously!)<br> <p> It seems to me massive problems have already occurred but culprits consistently manage to get out of harm and, sooner or later, secure computer systems may become luxury equipment.<br> Not that model checking cannot be done for yachting in the Carribean but it would leave me with a sense of guilt. ;-)<br> <br> </div> Thu, 30 Jul 2015 13:18:35 +0000 Stagefrightening https://lwn.net/Articles/652879/ https://lwn.net/Articles/652879/ ms <div class="FormattedComment"> s/amoral/immoral/. Learn something new every day...<br> </div> Thu, 30 Jul 2015 12:59:44 +0000 Stagefrightening https://lwn.net/Articles/652877/ https://lwn.net/Articles/652877/ ms <div class="FormattedComment"> Cute idea :) Struggling to think of one western government where &gt; 1% of the ministers know what Android is though...<br> </div> Thu, 30 Jul 2015 12:41:35 +0000 Stagefrightening https://lwn.net/Articles/652874/ https://lwn.net/Articles/652874/ magnus <div class="FormattedComment"> Maybe the manufacturers are hoping that Android is "too big to fail" and that they then get their costs for patching all old devices (or replacing with new ones) covered by a govenment contract. :)<br> <p> </div> Thu, 30 Jul 2015 12:37:08 +0000 Stagefrightening https://lwn.net/Articles/652872/ https://lwn.net/Articles/652872/ ms <div class="FormattedComment"> It certainly benefits them and their partners that one of the only sure-fire ways to get a security update is to have to drop $500 on a new phone. The extent to which this is unethical and amoral beggars belief.<br> </div> Thu, 30 Jul 2015 11:49:55 +0000 Stagefrightening https://lwn.net/Articles/652871/ https://lwn.net/Articles/652871/ Fowl <div class="FormattedComment"> Many fuzzers actually are much closer to "compile" time, eg. <a href="http://lcamtuf.coredump.cx/afl/">http://lcamtuf.coredump.cx/afl/</a><br> <p> The update model for Android is just broken. Decades of experience in hardware independent software has been thrown out the window in the name of expediency. Worse is better, eh?<br> </div> Thu, 30 Jul 2015 11:41:17 +0000 Stagefrightening https://lwn.net/Articles/652857/ https://lwn.net/Articles/652857/ ms <div class="FormattedComment"> If I were more cynical, I might make suggestions that a lot of the "engineers" writing this code would consider such tools to "get in their way" and are even an affront to their "programming prowess". The fact peer review didn't apparently catch this stuff either is terrifying. But I'm sure they probably did TDD or at least have 95%+ code coverage in their tests. So that makes everything OK.<br> <p> As the produce of our industry becomes ever more critical in maintaining every aspect of civilisation, we have *got* to get better at *proving* correctness, or at the very least vast model checking. People who don't understand tools like quickcheck or similar are going to rapidly find themselves unemployable. As the recent Jeep issue shows (cars could be rooted and controlled remotely), sooner or later there are going to be massive financial consequences to getting this stuff wrong.<br> </div> Thu, 30 Jul 2015 10:03:51 +0000 Stagefrightening https://lwn.net/Articles/652854/ https://lwn.net/Articles/652854/ ortalo <div class="FormattedComment"> I wonder if such things cannot be discovered by directly using the static analysis functions of compilers...<br> I am always surprised that fuzzing is the most popular tool nowadays, even when you have access to the source code.<br> In some sense, fuzzing is just "instrumented luck" no? As opposed to static analysis, which would be "rigorous verification". (Yes, I am deliberately polemic.)<br> <p> Anyway when privileged libraries get deployed to a billion device, I would expect the supplier to request controls in the build system. (I imagine Linux is not built with gcc -w.) Brown paper bag for Google &amp; co. IMHO.<br> Unless all those smartphones are really disposable devices and all their users knowingly agree...<br> <p> </div> Thu, 30 Jul 2015 09:31:37 +0000