LWN: Comments on "Cook: security things in Linux v5.0" https://lwn.net/Articles/782889/ This is a special feed containing comments posted to the individual LWN article titled "Cook: security things in Linux v5.0". en-us Fri, 24 Oct 2025 15:48:41 +0000 Fri, 24 Oct 2025 15:48:41 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Fixing programmers https://lwn.net/Articles/783961/ https://lwn.net/Articles/783961/ Wol <div class="FormattedComment"> I know it's well past, but I'll add that this convention long predates modern computers.<br> <p> It was the convention on old green screen terminals. It was the convention on teletypes before that. Heck, it's the convention that first came about two centuries ago with the early typewriters!<br> <p> Just changing the convection won't fix two centuries of training to do the opposite - since when did hitting "return" change the paper for you?<br> <p> Cheers,<br> Wol<br> </div> Mon, 25 Mar 2019 15:45:45 +0000 Fixing programmers https://lwn.net/Articles/783523/ https://lwn.net/Articles/783523/ Cyberax <div class="FormattedComment"> The Pascal dialect that I used back in 1995 definitely had it. I'm not sure about the Standard Pascal.<br> <p> Ada has had integer overflow checking since forever (as you would expect).<br> </div> Wed, 20 Mar 2019 01:18:36 +0000 Fixing programmers https://lwn.net/Articles/783516/ https://lwn.net/Articles/783516/ neilbrown <div class="FormattedComment"> <font class="QuotedText">&gt; By that definition, the Therac-25 "correctly" killed three people.</font><br> <p> Sorry to correct you, but I think you mean "It is correct that 'The Therac-25 killed three people' ".<br> <p> And this is the point - when people start using broad terms like "intent" and "correct" without ensuring that all corespondents are using them in the same sense, you can hardly expect a useful conversation to result.<br> <p> (wouldn't it be great if people would think about what they write, instead of just writing about what they think).<br> </div> Tue, 19 Mar 2019 23:24:33 +0000 Fixing programmers https://lwn.net/Articles/783512/ https://lwn.net/Articles/783512/ pizza <div class="FormattedComment"> By that definition, the Therac-25 "correctly" killed three people.<br> <p> <p> </div> Tue, 19 Mar 2019 22:03:11 +0000 Fixing programmers https://lwn.net/Articles/783509/ https://lwn.net/Articles/783509/ neilbrown <div class="FormattedComment"> <font class="QuotedText">&gt; Let's say I have this code snippet: a = b + c; Is it correct? </font><br> <p> Yes it is. <br> Your statement "I have this code snippet: a = b + c" is self-evidently correct.<br> <p> </div> Tue, 19 Mar 2019 21:44:39 +0000 Fixing programmers https://lwn.net/Articles/783502/ https://lwn.net/Articles/783502/ mpr22 <div class="FormattedComment"> I ask in all sincerity: which programming languages of vaguely similar vintage to C do any significantly better a job of accommodating integer overflow than C does?<br> </div> Tue, 19 Mar 2019 19:36:59 +0000 Fixing programmers https://lwn.net/Articles/783500/ https://lwn.net/Articles/783500/ Cyberax <div class="FormattedComment"> Integer overflow could easily be prevented in hardware (by causing a hardware trap). It doesn't even need any serious amount of silicon, integer overflow traps existed in lots of pre-x86 hardware.<br> <p> Unfortunately, C made that useless and so it fell by the wayside.<br> <p> </div> Tue, 19 Mar 2019 19:13:52 +0000 Fixing programmers https://lwn.net/Articles/783482/ https://lwn.net/Articles/783482/ mathstuf <div class="FormattedComment"> Granted, but I feel that the intent that matters is a much higher-level construct in black hat hacking than "should this case statement have a break statement?".<br> </div> Tue, 19 Mar 2019 14:59:15 +0000 Fixing programmers https://lwn.net/Articles/783481/ https://lwn.net/Articles/783481/ NAR <I>that allows you access to something else that you normally wouldn't be able to access.</I> <P> You're making the assumption that this particular access was not intended. So intent matters. Tue, 19 Mar 2019 14:55:44 +0000 Fixing programmers https://lwn.net/Articles/783455/ https://lwn.net/Articles/783455/ NAR <I>"why haven't we changed the way we work so that buffer overflows don't happen? "</I> <P> According to <A HREF="https://doi.org/10.6028/NIST.TN.1860">this</A> study, checks for buffer overflows in C can lead to 0-7% percent performance loss. Checking for integer overflow could lead to 50% slowdown. I guess those who still want to work in C don't want to accept this performance degradation. Tue, 19 Mar 2019 14:43:07 +0000 Fixing programmers https://lwn.net/Articles/783457/ https://lwn.net/Articles/783457/ mathstuf <div class="FormattedComment"> For zero-day hacking, the intent doesn't matter. All that matters is that you can thread your special arguments through to some internal state that allows you access to something else that you normally wouldn't be able to access. In *fixing* the issue, intent again enters the picture since just closing the hole naïvely can block some use case that is supposed to be intended (or break some subtle backwards compatibility). Static analysis is similar. It's goal is to detect what the actual code does, match it against code smells and flag such code. Intent then comes in when you either suppress the notice or change the code to make the code not wrong.<br> </div> Tue, 19 Mar 2019 14:43:04 +0000 Fixing programmers https://lwn.net/Articles/783454/ https://lwn.net/Articles/783454/ NAR <I>what the intent was actually doesn't matter and correctness is all that counts.</I> <P> How can you check correctness when you don't know what that code is supposed to do? Tue, 19 Mar 2019 14:31:38 +0000 Fixing programmers https://lwn.net/Articles/783451/ https://lwn.net/Articles/783451/ mathstuf <div class="FormattedComment"> There are a few fields where I can see the actual behavior of the code is of utmost importance, damn the intent. Static analysis and zero day hunting to name a few. In these cases, what the intent was actually doesn't matter and correctness is all that counts. However, these fields usually result in changes to the analyzed code when something "interesting" is found, so intent can matter again at that point.<br> </div> Tue, 19 Mar 2019 14:14:25 +0000 Fixing programmers https://lwn.net/Articles/783440/ https://lwn.net/Articles/783440/ anselm <p> The goal of computer programming is to write code that does what it is supposed to be doing. You can use the code itself to figure out what it does, but you can't use the code itself to figure out whether it does what it is supposed to be doing. </p> <p> It's very easy to write code that does something. Writing code that does what it it supposed to do is a lot harder, and requires outside context so you can determine when you're done. This is why in Real Life™ we have comments, specifications, unit tests, and so on – all to be able to figure out whether code does what it is supposed to do. </p> Tue, 19 Mar 2019 12:24:11 +0000 Fixing programmers https://lwn.net/Articles/783438/ https://lwn.net/Articles/783438/ HelloWorld <div class="FormattedComment"> <font class="QuotedText">&gt; There's no more reason to assume that two cases with fallthrough are correct or incorrect than two cases seprated by a break;. I've actually written code where I forgot to omit the break in the past :-).</font><br> There are actually two reasons:<br> – the case where you want to use break is vastly more common than the case where you want to fall through<br> – it's easier to forget adding the break keyword than it is to accidentally add the fall-through attribute<br> <p> <font class="QuotedText">&gt; I've actually written code where I forgot to omit the break in the past :-).</font><br> The article mentions 20 cases of missing break statements that were uncovered by this work, while it doesn't mention any cases like the one you describe. It's safe to say that missing break statements are a much more frequent occurrence.<br> </div> Tue, 19 Mar 2019 10:37:20 +0000 Fixing programmers https://lwn.net/Articles/783435/ https://lwn.net/Articles/783435/ NAR <I>Intent doesn't matter. Correctness does.</I> <P> Let's say I have this code snippet: <CODE> a = b + c; </CODE> Is it correct? Tue, 19 Mar 2019 10:02:55 +0000 Fixing programmers https://lwn.net/Articles/783411/ https://lwn.net/Articles/783411/ sfeam I believe you have this backwards. What the code <i>does</i> can be determined in the absence of comments. The <i>intent</i>, not so much. That is why comments are valuable for bug-finding. Any place where the documented intent does not match the observed actual behavior is candidate for causing problems. Mon, 18 Mar 2019 22:39:40 +0000 Fixing programmers https://lwn.net/Articles/783412/ https://lwn.net/Articles/783412/ Cyberax <div class="FormattedComment"> <font class="QuotedText">&gt; I need to know what the code does, not what someone believed it should be doing.</font><br> So you need to know the intent. Duh. You're just deluding yourself at this point.<br> <p> Correctness checking is TRIVIAL, it's not even worthy of mentioning. Checking of intent is anything but. And that's exactly why modern computer languages try to make it easier for developers to express their intent through code.<br> </div> Mon, 18 Mar 2019 22:33:28 +0000 Fixing programmers https://lwn.net/Articles/783410/ https://lwn.net/Articles/783410/ rweikusat2 <div class="FormattedComment"> If you think so, that's your opinion and not mine.<br> <p> As person who spends a seriously lot of time working with other people's code (and has done so for about 15 years), I can assure you that I don't give $random_small_quantity_of_money for documentation of "programmer intent", especially not in form of otherwise uninformative comments. I need to know what the code does, not what someone believed it should be doing.<br> <p> <p> <p> </div> Mon, 18 Mar 2019 22:29:30 +0000 Fixing programmers https://lwn.net/Articles/783409/ https://lwn.net/Articles/783409/ Cyberax <div class="FormattedComment"> Actually you got it wrong. Correctness doesn’t matter. The intent does.<br> </div> Mon, 18 Mar 2019 22:11:23 +0000 Fixing programmers https://lwn.net/Articles/783406/ https://lwn.net/Articles/783406/ rweikusat2 <div class="FormattedComment"> As I've already explained: Intent doesn't matter. Correctness does. YMMV.<br> <p> </div> Mon, 18 Mar 2019 21:46:42 +0000 Fixing programmers https://lwn.net/Articles/783398/ https://lwn.net/Articles/783398/ mathstuf <div class="FormattedComment"> As a reviewer, I would want a positive indication of intent for either behavior. A lack of either break or a fallthrough comment/attribute is an automatic request for "please clarify". The goal isn't to make code writer's jobs easier, but those who have yet to come and read the code.<br> </div> Mon, 18 Mar 2019 19:53:54 +0000 Fixing programmers https://lwn.net/Articles/783395/ https://lwn.net/Articles/783395/ rweikusat2 <div class="FormattedComment"> I don't understand what that's supposed to mean in the given context.<br> <p> I was trying to express two things:<br> <p> 1) Noting that a break is absent isn't sufficient grounds to assume that this must have been an oversight unless there's an a priori conviction that this is a very likely cause for an absent break. Considering the "99% false positives", such a conviction doesn't seem sensible to me.<br> <p> 2) Computers execute code as it was written, not as it was intended to be written. An absent break which was an oversight isn't necessarily an error. And neither is a conscious omission or a present break necessarily correct.<br> <p> </div> Mon, 18 Mar 2019 19:40:58 +0000 Fixing programmers https://lwn.net/Articles/783391/ https://lwn.net/Articles/783391/ farnz <p>I don't disagree that a lot of the issues are down to maritime law - but that's precisely the sort of thing that needs to be fixed if maritime is to catch up on aviation w.r.t. safety errors. And (to circle back round) both aviation law and maritime law are government regulations on the way their respective industries are run, complete with liability control; however, one has a strong record of ratcheting up safety over time, and the other continues to blame individuals rather than address the many ways in which changes to the law would result in better safety for all. <p>Hence my belief that regulation, in itself, is not sufficient to improve software - it needs to be good regulation like aviation, where the emphasis is on changing the regulation to prevent repeats, not like maritime law where flag administrators are slow to change regulations in response to known deficiencies. Mon, 18 Mar 2019 19:09:59 +0000 Fixing programmers https://lwn.net/Articles/783384/ https://lwn.net/Articles/783384/ pizza <div class="FormattedComment"> Unfortunately, many of the answers to your questions are "because maritime law."<br> <p> BTW, here is the 181-page official investigation report:<br> <p> <a href="http://3kbo302xo3lg2i1rj8450xje-wpengine.netdna-ssl.com/wp-content/uploads/2013/05/Costa_Concordia_-_Full_Investigation_Report.pdf">http://3kbo302xo3lg2i1rj8450xje-wpengine.netdna-ssl.com/w...</a><br> <p> <p> </div> Mon, 18 Mar 2019 17:20:37 +0000 Fixing programmers https://lwn.net/Articles/783378/ https://lwn.net/Articles/783378/ farnz <p>Exactly my point - there are two things that matter and are different in aviation as opposed to maritime regulation: <ol> <li>Overriding the captain when they are making a mistake is expected in aviation, and praised; it is punished in maritime regulation. <li>The questions being asked of the captain are not "what could we have changed to stop this from happening", but "why did you not do the right things". </ol> <p>It's that blame culture that prevents maritime rules from moving on - we have a scapegoat for the incident, we don't need to consider anything other than Captain Schettino's bad behaviour. In the aviation world, there would be more significant changes expected; why does Captain Schettino claim he was asked to do a sail-past salute? Why can't a more junior officer order preparations to abandon ship? Why couldn't Captain De Falco hand command of the ship over to Mr Bosio when Captain Schettino refused to return onboard? Why is it possible for the alarm system to be off on captain's orders alone? <p>And I'm not a professional investigator - those are just four things raised by the public record on the disaster that should be understood and should lead to changes to the way ships are run, if it's managed the way aviation is. Human error happens, and the <a href="http://panko.shidler.hawaii.edu/HumanErr/Basic.htm">rates at which it happens are well understood</a>, so why do we accept that the disaster was Captain Schettino's fault, and leave it at that, when we should be trying to ensure that the next Captain Schettino cannot make the same set of mistakes? Mon, 18 Mar 2019 16:50:36 +0000 Fixing programmers https://lwn.net/Articles/783377/ https://lwn.net/Articles/783377/ jezuch <div class="FormattedComment"> I do that too, *and* I do the initial commit using git commit -p as a kind of self-review. Catches plenty of stuff I wanted to do or did temporarily but forgot etc.<br> </div> Mon, 18 Mar 2019 16:14:21 +0000 Fixing programmers https://lwn.net/Articles/783341/ https://lwn.net/Articles/783341/ pizza <div class="FormattedComment"> <font class="QuotedText">&gt; In an aviation equivalent, the setup would allow any bridge officer to override the captain on a risky manoeuvre like this; it simply wouldn't be just the captain's fault as the Concordia was suggested to be. </font><br> <p> (FYI, under maritime law, "overriding the captain" is called mutiny, something that tends to go quite badly for all involved..)<br> <p> Meanwhile, the book wasn't thrown at the captain (and his senior staff) for merely running aground. Instead, it was for grossly mismanaging what happened next. To top it all off, the captain *abandoned his post* well before evacuation was complete.<br> <p> </div> Mon, 18 Mar 2019 15:56:52 +0000 Fixing programmers https://lwn.net/Articles/783330/ https://lwn.net/Articles/783330/ mathstuf <div class="FormattedComment"> Depends. Sometimes "uninteresting" parts of a patch are done at a late (or early) hour and is just more prone to typos and errors. Reviews are invaluable to every coder, from those learning anew all the way up to Linus. One of the first things I do after opening a merge request is do another look over the code. I've lost count of how many 5-minute-later pushes I've made because of that. Or if I find a bigger issue, I at least leave a comment that something looks weird and might need more thought.<br> </div> Mon, 18 Mar 2019 13:49:33 +0000 Fixing programmers https://lwn.net/Articles/783327/ https://lwn.net/Articles/783327/ farnz <p>The Costa Concordia is a good example, because it <em>had</em> a near-miss doing a similar manoevure at company request under the same captain a few months earlier, but no formal investigation happened - it was just one of those things - and even now, the effort is to claim that the captain was at fault. <p>In an aviation equivalent, the setup would allow any bridge officer to override the captain on a risky manoevure like this; it simply wouldn't be just the captain's fault as the Concordia was suggested to be. <p>Plus, there are plenty of design issues with the cruise ships in general, which are being completely ignored in favour of minor tweaks to the way they operate - despite knowing that the requirement for active stability assist to stay upright is part of what caused the Concordia to crash. Mon, 18 Mar 2019 13:20:28 +0000 Fixing programmers https://lwn.net/Articles/783326/ https://lwn.net/Articles/783326/ pizza <div class="FormattedComment"> I'm not sure that the Costa Concordia is a good example here, as the company was based in Italy, the ship flew an Italian flag, and the accident happened in Italian waters -- it's rare for two to be true, much less the trifecta! -- and its Captain demonstrated astonishing (not to mention criminal) levels of gross incompetence.<br> <p> That said, the cruise industry as a whole also made changes (notably requiring safety drills prior to leaving port instead of "within 24 hours" as the governing treaties require) and much stricter rules about non-essential personnel on the bridge -- eg if you're going to sneak your mistress on board without a ticket, at least keep her off the bridge during offshore manoeuvres.<br> <p> I might postulate that the "maritime industry" is learning the lesson that poor safety practices will severely hurt them in the market -- both in lower passenger booking and drastically higher insurance premiums. (Indeed, insurance company requirements probably do more to effect industry-wide changes than governments ever do..)<br> <p> </div> Mon, 18 Mar 2019 12:46:19 +0000 Fixing programmers https://lwn.net/Articles/783325/ https://lwn.net/Articles/783325/ farnz <p>That's not sufficient - maritime transport is regulated in the same way as aviation, and yet is as generally disasterous as programming. In particular, maritime accidents can be blamed on human error and the captain or their crew prosecuted in a way that does not happen in aviation - see the Costa Concordia disaster for example, where no lessons are being learnt by the industry because they can push the blame onto the captain. Mon, 18 Mar 2019 11:43:33 +0000 Fixing programmers https://lwn.net/Articles/783323/ https://lwn.net/Articles/783323/ pizza <div class="FormattedComment"> <font class="QuotedText">&gt; In contrast, in software, we had the Morris Worm of 1988 (over 30 years ago), which exploited buffer overflows in C code. 30 years later, we're still seeing new buffer overflow attacks on maintained software written in C; why haven't we changed the way we work so that buffer overflows don't happen? </font><br> <p> Because, unlike both Surgery and Aviation, "programming" (C or otherwise) as a profession has little to no formal quality, training or certification requirements, and zero government oversight. Which is just they way the industry likes it.<br> <p> You want this to change? Make software vendors directly liable (civilly and/or criminally) for software defects -- no more hiding behind "the software is provided with no warranty; not even implied merchantability or fitness for a particular purpose" disclaimers.<br> </div> Mon, 18 Mar 2019 11:18:56 +0000 Fixing programmers https://lwn.net/Articles/783321/ https://lwn.net/Articles/783321/ farnz <p>The thing that really changed both aviation and surgery is not checklists themselves, but three shifts in attitude that result in changes (including checklists) that improve on today's situation. <p>Change 1 is the idea that unforced human error is not an explanation - it's just a way of shifting blame onto the operator. All incidents have to be investigated, and at each point where a reasonable change to procedure or device implementation could have prevented an incident, that change should be identified. Once you have a list of changes that could have prevented this incident, <em>then</em> you do a risk/benefit assessment of each change and decide which ones are worth having, and which ones just add complexity for complexity's sake. <p>Change 2 is that there's no such thing as a lucky near miss - instead, there are near misses that . Whenever someone has a "lucky near miss", record what happened, and classify it with other lucky near misses. Someone looks for patterns of lucky near misses, and anything that recurs is treated as an incident and investigated with a view to stopping it happening again. <p>Finally, change 3 is the idea that seniority should not imply deference. The world's greatest experts all make mistakes, and when a junior calls you out on a possible error, you either fix it and graciously acknowledge their input (if they've called you on a real error like operating on the wrong limb), or you treat it as a teachable moment if they've misunderstood something (e.g. if they're asking you why you put the nose down and cut the throttle when trying to descend). <p>None of this is a panacea - mistakes still get made - but it means that you don't repeatedly make the same class of error, nor do you depend on "experience" and "expertise" to remove classes of mistake, because the changes you make (be it checklists, talking to the patient before operating, gauges rotated so that "perfect" is straight up, sign in/out sheets for everything that's used in an operation, making it normal for juniors to critique seniors) all change the working environment such that fewer mistakes are made. <p>In contrast, in software, we had the Morris Worm of 1988 (over 30 years ago), which exploited buffer overflows in C code. 30 years later, we're still seeing new buffer overflow attacks on maintained software written in C; why haven't we changed the way we work so that buffer overflows don't happen? Mon, 18 Mar 2019 10:18:56 +0000 The art of checklists https://lwn.net/Articles/783307/ https://lwn.net/Articles/783307/ rickmoen Cyberax wrote: <p><em>Aviation? The same issue. Solved by checklists that HAVE to be followed.</em></p> <p>Sadly, there have been some painful (and fatal) lessons in effective use of checklists in the airline industry, as also in other industries where they're critical (marine transportation. weapons systems, spaceflight, medical care, etc.) Making a <a href="https://ti.arc.nasa.gov/m/profile/adegani/Cockpit%20Checklists.pdf">long story</a> short, checklist design and implementation has had subtle aspects that are difficult to get right, and just saying they HAVE to be followed isn't nearly enough.</p> <p>What happens when airlines get it wrong is <a href="https://en.wikipedia.org/wiki/Elmendorf_Air_Force_Base#Aviation_accidents">what happened</a> to my father, Pan Am Captain Arthur Moen, and his crew. (Upon finally reading the NTSB report, I was obliged to change my saying 'A checklist will have your life' to 'A well-debugged checklist will save your life'.)</p> <p>Rick Moen<br> rick@linuxmafia.com Mon, 18 Mar 2019 00:58:01 +0000 Fixing programmers https://lwn.net/Articles/783295/ https://lwn.net/Articles/783295/ rweikusat2 <div class="FormattedComment"> <font class="QuotedText">&gt; A fallthrough comment is not trying to tell you whether or not the code will fall through. Obviously it will, there's no break! The </font><br> <font class="QuotedText">&gt; comment is telling you that someone thought about it and INTENDED the fallthrough to happen.</font><br> <p> It's usually safe to assume that code came to be in a certain form because someone was convinced it would be the right way to solve a particular problem. But that's not particularly interesting. Interestsing is "is it the right way".<br> </div> Sun, 17 Mar 2019 20:29:41 +0000 Fixing programmers https://lwn.net/Articles/783281/ https://lwn.net/Articles/783281/ madscientist <div class="FormattedComment"> GCC provides options that allow the preprocessor to leave comments in its output files.<br> <p> However, using attributes is probably a better way to go in general.<br> </div> Sun, 17 Mar 2019 12:30:35 +0000 Fixing programmers https://lwn.net/Articles/783274/ https://lwn.net/Articles/783274/ HelloWorld <div class="FormattedComment"> gcc also supports using an attribute instead of a comment, that will not be removed by the preprocessor.<br> </div> Sun, 17 Mar 2019 10:49:54 +0000 Fixing programmers https://lwn.net/Articles/783273/ https://lwn.net/Articles/783273/ farnz <p>It was formalised in <a href="https://en.wikipedia.org/wiki/IBM_Common_User_Access">IBM's CUA guidelines in 1987</a>, which was adopted by Motif. I can't find references for where IBM took that behaviour from, but the fact it was adopted as part of CUA suggests it was in use before 1987. Sun, 17 Mar 2019 09:11:47 +0000 Fixing programmers https://lwn.net/Articles/783266/ https://lwn.net/Articles/783266/ ABCD <p>Among possibly other languages, Java allows this:</p> <pre> labela: for (int i = 1; i &lt;= 10; i++) { labelb: for (int j = 10; j &gt;= 1; j--) { do_something(i, j); if (x) continue labela; } } </pre> Sun, 17 Mar 2019 00:28:17 +0000