LWN: Comments on "Trying to get STACKLEAK into the kernel" https://lwn.net/Articles/764325/ This is a special feed containing comments posted to the individual LWN article titled "Trying to get STACKLEAK into the kernel". en-us Sun, 02 Nov 2025 19:32:32 +0000 Sun, 02 Nov 2025 19:32:32 +0000 https://www.rssboard.org/rss-specification lwn@lwn.net Trying to get STACKLEAK into the kernel https://lwn.net/Articles/789524/ https://lwn.net/Articles/789524/ a13xp0p0v <div class="FormattedComment"> [resurrecting an old thread]<br> <p> <font class="QuotedText">&gt; Moreover, I have previously stated that different exception stacks have different</font><br> <font class="QuotedText">&gt; size at x86_64. All of them are 4K, except the debug stack which is 8K:</font><br> <font class="QuotedText">&gt; static unsigned long exception_stack_sizes[N_EXCEPTION_STACKS] = {</font><br> <font class="QuotedText">&gt; [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STKSZ,</font><br> <font class="QuotedText">&gt; [DEBUG_STACK - 1] = DEBUG_STKSZ</font><br> <font class="QuotedText">&gt; };</font><br> <p> This particular statement was wrong - my mistake!<br> Brad has revealed (thanks to him) why calculating the stack size from grsecurity was correct:<br> "The debug IST stack is actually two separate debug stacks to handle #DB recursion"<br> <a href="https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=2a594d4ccf3f10f80b77d71bd3dad10813ac0137">https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.g...</a><br> Great!<br> <p> I will *not* make a patch for the upstream kernel since alloca() checking didn't get to the mainline - <br> all VLA (Variable Length Arrays) should be removed instead.<br> <p> Best regards,<br> Alexander<br> <p> </div> Mon, 27 May 2019 15:27:19 +0000 individuals, and robustness in the face of extreme diversity thereof https://lwn.net/Articles/766436/ https://lwn.net/Articles/766436/ Garak <blockquote>It's disingenuous to refer to Linus as just "an individual" in the community.</blockquote> lkundrak was clearly enough describing a general logical proof involving sets and individuals. Extrapolating the situation to the general, not referring to the specific instance. Thus not disingenuous.<br/> <br/> I too think that a significant aspect of this is the 'specialness' of the 'supreme leader'(core trademark holder). At the end of the day, anyone is free to fork linux, call it anything else, and do whatever they want. It's not like anything Linus Torvalds does or does not do interferes with anyone's freedom to do that. Given that dynamic (the core dynamic of FOSS), this doesn't seem very important to me (given the context of billions if not trillions of processors out there running 'linux' and keeping the world turning) Mon, 24 Sep 2018 05:18:57 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/765759/ https://lwn.net/Articles/765759/ Wol <div class="FormattedComment"> <font class="QuotedText">&gt; Since two persons are asserting opposite things about a matter, we know that at least one of them is lying, whether voluntarily or not.</font><br> <p> From personal experience I can assure you that you're wrong. And I'm pretty certain the correct conclusion in policing is that if two people assert the SAME thing about a matter, then they are probably lying (colluding).<br> <p> Firstly there is the law of relativity - two observers in two different places will see the same event in two different ways.<br> <p> And secondly, I have had plenty of experience of friends describing things to me - where I have the same personal experience as them - and I beg to differ strongly with what they see. That doesn't mean one of us is lying. It means one of us is *wrong*, but that's a very different matter - chances are *both* of us are wrong.<br> <p> Cheers,<br> Wol<br> </div> Thu, 20 Sep 2018 11:14:16 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/765179/ https://lwn.net/Articles/765179/ ThinkRob <blockquote> Linus' abusive behaviour is unnecessary theatrics, a curable condition. I hope one day it is so, rehabilitation is better than isolation.</blockquote> <p> I think part of why Linus doesn't get called out on it as much is that it's not always obvious from the various quotes and excerpts that make it into the mainstream trade press. (And they certainly make for attention-getting headlines, so I get why they're reprinted.) Before I followed kernel dev that closely I would have been surprised if this were the case. But after having gotten more into kernel dev in the last year or two now, it's obvious that yeah, it is. Why? Because he often leads in to a rejection with a flame, but then [frequently] has solid technical critiques... later on in the thread. <p> There's some argument to be made that "you have to be blunt or exceptions start getting made". And I get, and am even sympathetic to that... to some degree. But that doesn't mean that you have to 1) go in all-guns-blazing every single time 2) make the attacks personal. You can still have an honest response to a bad patch that rips the code apart [1] and that doesn't come off as condescending or malicious or personal, but far too often I've read flames from him that make it sound like he dislikes the <i>coder</i> rather than the code. And that makes it a problem, whether that's his intent or not. <p> He doesn't even have to stop calling bad code bad! We've probably all ranted to a friend or coworker about some busted, oddball library we were forced to use. And most of us probably get a kick out of things like that infamous rant on the PSD file format or some of JWZ's musings on "the Xwindows disaster". But this isn't the same, because Linus's screeds often aren't aimed at the code, they're about people. And that takes it from a potential solution to a technical problem to serious problem for people trying to write technical solutions. <p><sup>[1] although whether or not such a blunt response is necessary or appropriate is situation dependent</sup> Mon, 17 Sep 2018 23:41:37 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/765055/ https://lwn.net/Articles/765055/ shemminger <div class="FormattedComment"> This is great technical feedback. And it is why security fixes should be done in the open on mailing lists instead of flame wars and twitter storms.<br> </div> Mon, 17 Sep 2018 15:31:41 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764866/ https://lwn.net/Articles/764866/ nilsmeyer <div class="FormattedComment"> Thus offending the French ;)<br> </div> Sat, 15 Sep 2018 15:14:20 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764863/ https://lwn.net/Articles/764863/ flussence <div class="FormattedComment"> The grsec code does add some security from what I've observed second-hand, but it goes about it like windows antivirus vendors: sticking hooks in random places and doing many things to cause userspace breakage (one of the reasons it never got upstreamed) and worse, kernel breakage (a normal user should never be able to hang the kernel with `cat`).<br> <p> The way they respond to criticism of those things, you'd think they were malware authors.<br> </div> Sat, 15 Sep 2018 12:40:09 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764860/ https://lwn.net/Articles/764860/ meyert <div class="FormattedComment"> 👏 for your work mr. Poppov! please keep on pushing this to the mainline kernel!<br> <p> </div> Sat, 15 Sep 2018 08:25:38 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764858/ https://lwn.net/Articles/764858/ pabs <div class="FormattedComment"> Re RANDSTRUCT, any idea if PaX/grsec folks have evaluated multicompiler?<br> <p> <a href="http://ssllab.org/#multic">http://ssllab.org/#multic</a><br> <a href="https://github.com/securesystemslab/multicompiler">https://github.com/securesystemslab/multicompiler</a><br> </div> Sat, 15 Sep 2018 05:40:42 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764845/ https://lwn.net/Articles/764845/ hkario <div class="FormattedComment"> you could look at it the other way, as Linus degrading himself and putting the person "attacked" as the King Arthur while himself as the french buffoon that won't let the king to enter for entirely petty reasons<br> </div> Fri, 14 Sep 2018 17:29:58 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764844/ https://lwn.net/Articles/764844/ nix <div class="FormattedComment"> I doubt that. People have been much more offensive than Linus without being banned here. It *is* possible to be so offensive you get banned, but it's hard. (Linus levels of offensiveness would probably only get a warning.)<br> </div> Fri, 14 Sep 2018 17:13:10 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764840/ https://lwn.net/Articles/764840/ a13xp0p0v <div class="FormattedComment"> Ok, Brad Spengler has replied with a very detailed post about STACKLEAK:<br> <a href="https://grsecurity.net/~spender/stackleak_response.txt">https://grsecurity.net/~spender/stackleak_response.txt</a><br> <p> Cool, I appreciate that! Normally such discussions happen at the Linux Kernel<br> Mailing List (LKML), but in our case I have to reply here at LWN.<br> <p> I also see that Brad is desperately trying to be always right. Actually he can relax:<br> he is genius, he is always right, I'm not protesting :)<br> <p> I just do my work: I'm pushing this feature into the mainline.<br> <p> Let me reply Brad.<br> <p> ============<br> <p> <font class="QuotedText">&gt; RE: the assertion in track_stack, the flaw in it (the added ~) was found by Tycho Andersen,</font><br> <font class="QuotedText">&gt; not Alex (though it's not claimed directly, it's implied as Alex is taking credit for the STACKLEAK</font><br> <font class="QuotedText">&gt; upstreaming work). This was properly credited below:</font><br> <font class="QuotedText">&gt; commit 12927d314b2763dd791ef11e56c42184fba4d3f8</font><br> <font class="QuotedText">&gt; Author: Brad Spengler &lt;spender@grsecurity.net&gt;</font><br> <font class="QuotedText">&gt; Date: Tue Aug 15 07:11:47 2017 -0400</font><br> <font class="QuotedText">&gt; </font><br> <font class="QuotedText">&gt; Fix 32bit stackleak stack_left test present in grsec only, as spotted</font><br> <font class="QuotedText">&gt; by Tycho Andersen</font><br> <p> Oh, Brad, come on! Tycho is my good friend, he supports my upstreaming efforts very<br> much, I always praise his work. Yes, he was the first who spotted your mistake with '~':<br> <a href="https://www.openwall.com/lists/kernel-hardening/2017/08/15/1">https://www.openwall.com/lists/kernel-hardening/2017/08/15/1</a><br> <p> And then later I've investigated the recursive BUG() trouble caused by this check and finally<br> dropped it in v6:<br> <a href="https://www.openwall.com/lists/kernel-hardening/2017/12/05/18">https://www.openwall.com/lists/kernel-hardening/2017/12/0...</a><br> <p> <p> <font class="QuotedText">&gt; This test however doesn't have to do with PAX_STACKLEAK as mentioned there -- you can look</font><br> <font class="QuotedText">&gt; at any PaX patch and see that the test doesn't exist. What the check in grsecurity (tried) to do was</font><br> <font class="QuotedText">&gt; piggy-back off being called in useful places throughout the entire kernel and in the lack of</font><br> <font class="QuotedText">&gt; KSTACKOVERFLOW wanted to avoid a recursion-based stack overflow from being able to cleanly</font><br> <font class="QuotedText">&gt; overwrite its intended target. In fact, the same day I made the above change I added an #ifndef</font><br> <font class="QuotedText">&gt; to make this explicit:</font><br> <font class="QuotedText">&gt; commit 16e1332faabc9f270fde9787ddb23e95cb2aad9c</font><br> <font class="QuotedText">&gt; Author: Brad Spengler &lt;spender@grsecurity.net&gt;</font><br> <font class="QuotedText">&gt; Date: Tue Aug 15 07:16:30 2017 -0400</font><br> <font class="QuotedText">&gt; </font><br> <font class="QuotedText">&gt; Make 32bit stack_left check depend on !KSTACKOVERFLOW to improve performance a bit</font><br> <font class="QuotedText">&gt; </font><br> <font class="QuotedText">&gt; So it is correct that there was a bug in the check I added that caused it to be a no-op, but it's</font><br> <font class="QuotedText">&gt; not part of the STACKLEAK defense and I don't believe we ever advertised that particular added check.</font><br> <p> Ok, I see. I know that it is your code, not PaX Team's.<br> <p> But I didn't know that it is NOT a part of STACKLEAK feature. That's because all we have<br> is a single giant grsecurity patch and NOT the git history which you quote here.<br> N.B. I don't blame you.<br> <p> <p> <font class="QuotedText">&gt; A further claim was "STACKLEAK was missing PLACES where the stack needed erasing" (emphasis mine).</font><br> <font class="QuotedText">&gt; Alex identified one location in ret_from_fork which in our 4.9 patch was missing instrumentation</font><br> <font class="QuotedText">&gt; for x86_32. This instrumentation wasn't missing in the original STACKLEAK code, nor in our stable</font><br> <font class="QuotedText">&gt; patches for 3.2 or 3.14. Alex is free to verify this as we have done. It was introduced during</font><br> <font class="QuotedText">&gt; some upstream churn in the entry code via the following commit:</font><br> <font class="QuotedText">&gt; commit 39e8701f33d65c7f51d749a5d12a1379065e0926</font><br> <font class="QuotedText">&gt; Author: Andy Lutomirski &lt;luto@kernel.org&gt;</font><br> <font class="QuotedText">&gt; Date: Mon Oct 5 17:48:13 2015 -0700</font><br> <font class="QuotedText">&gt; </font><br> <font class="QuotedText">&gt; x86/entry/32: Open-code return tracking from fork and kthreads</font><br> <font class="QuotedText">&gt; </font><br> <font class="QuotedText">&gt; This open-coding changed ret_from_fork from following a path that would perform the stack clearing</font><br> <font class="QuotedText">&gt; to one that would not, and since we didn't have any comment-based guards in place there, it slipped</font><br> <font class="QuotedText">&gt; our notice. As mentioned, this only affected i386, and would be rendered benign by having</font><br> <font class="QuotedText">&gt; RANDKSTACK enabled (as it is by default in autoconfig) which would clear the full stack on entry to</font><br> <font class="QuotedText">&gt; the following syscall (as the lowest_stack field is set to the end of the stack for the new</font><br> <font class="QuotedText">&gt; process). Further, the newly-created process' stack would already be cleared in the presence of</font><br> <font class="QuotedText">&gt; CONFIG_DEBUG_STACK_USAGE or in any kernel with commit e01e80634ecdde1dd113ac43b3adad21b47f3957</font><br> <font class="QuotedText">&gt; "fork: unconditionally clear stack on fork". Further, it is likely (possibly guaranteed, I'd have</font><br> <font class="QuotedText">&gt; to confirm this) that the presence of PAX_MEMORY_SANITIZE (which would be auto-enabled in every</font><br> <font class="QuotedText">&gt; instance where STACKLEAK was auto-enabled) would ensure the newly-allocated stack would be cleared</font><br> <font class="QuotedText">&gt; with the SANITIZE poison value.</font><br> <p> Ok, so it's evil Andy Lutomirski who has broken your patch :)<br> Ok, it's not security relevant, that is good.<br> <p> <p> <font class="QuotedText">&gt; There was no other location identified by Alex (and I went ahead and confirmed with v14 that no</font><br> <font class="QuotedText">&gt; other location has been identified), so the claim that "places" (a plural) were missing</font><br> <font class="QuotedText">&gt; instrumentation is false.</font><br> <p> Oh, I'm sorry for 'PLACES', it's definitely my fault...<br> In v6 I added two missing erase_kstack() calls:<br> <a href="https://www.openwall.com/lists/kernel-hardening/2017/12/05/18">https://www.openwall.com/lists/kernel-hardening/2017/12/0...</a><br> But later one of them turned out to be surplus (kudos to Dmitry V. Levin).<br> <p> So let me sum up:<br> - it is not your mistake, it is evil upstream which has broken your patch :)<br> - there was only ONE erase_kstack() missing, which I fixed.<br> <p> <p> <font class="QuotedText">&gt; Regarding errors in the alloca() checking, Alex's claims there are false. get_stack_info didn't</font><br> <font class="QuotedText">&gt; exist when STACKLEAK was first written, but when it was introduced we did convert to using it.</font><br> <font class="QuotedText">&gt; We don't needlessly duplicate functionality of get_stack_info, we only have some additional code</font><br> <font class="QuotedText">&gt; for correctly computing the amount of stack space left, and our checks there are correct.</font><br> <p> Hm... Let's compare the code. That's funny to do it here and not at LKML.<br> <p> Here is my version (ouch, lwn breaks the identation):<br> <p> +void __used stackleak_check_alloca(unsigned long size)<br> +{<br> + unsigned long sp = (unsigned long)&amp;sp;<br> + struct stack_info stack_info = {0};<br> + unsigned long visit_mask = 0;<br> + unsigned long stack_left;<br> +<br> + BUG_ON(get_stack_info(&amp;sp, current, &amp;stack_info, &amp;visit_mask));<br> +<br> + stack_left = sp - (unsigned long)stack_info.begin;<br> +<br> + if (size &gt;= stack_left) {<br> + /*<br> + * Kernel stack depth overflow is detected, let's report that.<br> + * If CONFIG_VMAP_STACK is enabled, we can safely use BUG().<br> + * If CONFIG_VMAP_STACK is disabled, BUG() handling can corrupt<br> + * the neighbour memory. CONFIG_SCHED_STACK_END_CHECK calls<br> + * panic() in a similar situation, so let's do the same if that<br> + * option is on. Otherwise just use BUG() and hope for the best.<br> + */<br> +#if !defined(CONFIG_VMAP_STACK) &amp;&amp; defined(CONFIG_SCHED_STACK_END_CHECK)<br> + panic("alloca() over the kernel stack boundary\n");<br> +#else<br> + BUG();<br> +#endif<br> + }<br> +}<br> <p> And here is grsecurity code for x86_64 from the last public patch (there is a<br> separate implementation for x86_32):<br> <p> +void __used pax_check_alloca(unsigned long size)<br> +{<br> + struct stack_info stack_info = {0};<br> + unsigned long visit_mask = 0;<br> + unsigned long sp = (unsigned long)&amp;sp;<br> + unsigned long stack_left;<br> +<br> + BUG_ON(get_stack_info(&amp;sp, current, &amp;stack_info, &amp;visit_mask));<br> +<br> + switch (stack_info.type) {<br> + case STACK_TYPE_TASK:<br> + stack_left = sp &amp; (THREAD_SIZE - 1);<br> + break;<br> +<br> + case STACK_TYPE_IRQ:<br> + stack_left = sp &amp; (IRQ_STACK_SIZE - 1);<br> + break;<br> +<br> + case STACK_TYPE_EXCEPTION ... STACK_TYPE_EXCEPTION_LAST:<br> + stack_left = sp &amp; (EXCEPTION_STKSZ - 1);<br> + break;<br> +<br> + case STACK_TYPE_SOFTIRQ:<br> + default:<br> + BUG();<br> + }<br> +<br> + BUG_ON(stack_left &lt; 256 || size &gt;= stack_left - 256);<br> +}<br> <p> First, I think there is no reason for this 'switch', since get_stack_info() calculates<br> the stack size itself, so we can simply do:<br> + stack_left = sp - (unsigned long)stack_info.begin;<br> <p> Moreover, I have previously stated that different exception stacks have different<br> size at x86_64. All of them are 4K, except the debug stack which is 8K:<br> static unsigned long exception_stack_sizes[N_EXCEPTION_STACKS] = {<br> [0 ... N_EXCEPTION_STACKS - 1] = EXCEPTION_STKSZ,<br> [DEBUG_STACK - 1] = DEBUG_STKSZ<br> };<br> <p> Maybe it's not critical for alloca check... Anyway, I prefer to rely on get_stack_info()<br> to follow "Don't Repeat Yourself" rule. And if it changes, we don't have to patch<br> check_alloca().<br> <p> <p> Now the second difference: grsecurity code uses this '256' magic value in BUG_ON().<br> <p> Mark Rutland and I had a long discussion about it in this thread:<br> <a href="http://openwall.com/lists/kernel-hardening/2018/05/11/12">http://openwall.com/lists/kernel-hardening/2018/05/11/12</a><br> <p> I think that this '256' is useless here, since we don't know how much of stack space<br> the BUG_ON() handling consumes. So it can overflow these 256 bytes and corrupt the<br> neighbour memory.<br> <p> And here is our solution:<br> <p> + if (size &gt;= stack_left) {<br> + /*<br> + * Kernel stack depth overflow is detected, let's report that.<br> + * If CONFIG_VMAP_STACK is enabled, we can safely use BUG().<br> + * If CONFIG_VMAP_STACK is disabled, BUG() handling can corrupt<br> + * the neighbour memory. CONFIG_SCHED_STACK_END_CHECK calls<br> + * panic() in a similar situation, so let's do the same if that<br> + * option is on. Otherwise just use BUG() and hope for the best.<br> + */<br> +#if !defined(CONFIG_VMAP_STACK) &amp;&amp; defined(CONFIG_SCHED_STACK_END_CHECK)<br> + panic("alloca() over the kernel stack boundary\n");<br> +#else<br> + BUG();<br> +#endif<br> <p> <p> At the same time I see one tricky aspect in my code.<br> We don't know in which order the compiler puts the local variables on the stack.<br> So calculating the stack pointer with this:<br> + unsigned long sp = (unsigned long)&amp;sp;<br> can make alloca size check incorrect (but 256 magic value mitigates that).<br> <p> If one day I will come up with the "check_alloca() add-on" to my v15, I will use<br> 'current_stack_pointer' instead to avoid that aspect.<br> <p> <font class="QuotedText">&gt; If Alex would like us to explain to him how his change there is incorrect and our checks are correct,</font><br> <p> Brad, you perfectly know all my arguments, I've already posted them at LKML,<br> and I always put you in CC. My development process is completely open.<br> <p> <font class="QuotedText">&gt; I'd be happy to explain it in full provided he agree to donate $1000 to a charity of my choosing.</font><br> <font class="QuotedText">&gt; Now that I've stated he's wrong, he's able to either figure out the reason on his own and correct</font><br> <font class="QuotedText">&gt; his statement publicly, or if he's so certain he's correct, has nothing to lose by entering</font><br> <font class="QuotedText">&gt; into this challenge. In the case that we're wrong (not possible as we re-confirmed it prior to</font><br> <font class="QuotedText">&gt; writing this), I'll be happy to admit defeat and donate $1000 to charity, providing full proof to</font><br> <font class="QuotedText">&gt; the public and correcting this statement.</font><br> <p> Huh. Organizing such a bet to donate money to charity?<br> We do it on a regular basis without such bets. I'm sure, Grsecurity is a company with<br> social responsibility, which regularly donates to charity, doesn't it?<br> <p> Anyway, let me thank you once again for all the information that you've already shared with us.<br> All my arguments and patches are open, feel free to use them for your version of STACKLEAK.<br> <p> By the way, you keep silence about my fixes in the gcc plugin... Didn't you apply them?<br> <p> <font class="QuotedText">&gt; So to sum up:</font><br> <font class="QuotedText">&gt; Yes there was a bug in an added check in grsecurity that depended on STACKLEAK being enabled, but</font><br> <font class="QuotedText">&gt; which wasn't advertised and wasn't part of the STACKLEAK defense. This was found by Tycho</font><br> <font class="QuotedText">&gt; Andersen, not Alex, and credited properly in our changelogs.</font><br> <p> You are absolutely right. I should only add that your check also causes the recursive BUG()<br> which corrupts the memory below the stack bottom or hits the guard page.<br> <p> <font class="QuotedText">&gt; Yes, in some newer versions of grsecurity (after the commit mentioned above) we were missing</font><br> <font class="QuotedText">&gt; explicit STACKLEAK clearing in returning from fork on i386 in a newly-forked process. Due to the</font><br> <font class="QuotedText">&gt; other factors mentioned above, this likely had 0 real-life impact.</font><br> <p> I absolutely agree. I've fixed this SINGLE flaw.<br> <p> <font class="QuotedText">&gt; No, our alloca() tests aren't wrong and don't needlessly duplicate code. We have made a public</font><br> <font class="QuotedText">&gt; offer to donate $1000 to charity if we're wrong on this point (with us offering to provide all the</font><br> <font class="QuotedText">&gt; details to easily determine the truth of the statement) provided that Alex agrees to the same</font><br> <font class="QuotedText">&gt; terms, as we won't do the KSPP's work for free.</font><br> <p> Sorry Brad, I don't like this idea. I'm not going to donate to charity because of such a bet.<br> I've already described all my technical arguments above.<br> But I'm also not going to force you "do the KSPP's work for free".<br> <p> I sincerely thank you for such an interesting discussion!<br> Maybe later I will post the link or digest to LKML, since discussing Linux kernel patches<br> in twitter-lwn-something doesn't work well.<br> <p> Best regards,<br> Alexander<br> <p> </div> Fri, 14 Sep 2018 14:48:34 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764819/ https://lwn.net/Articles/764819/ excors <div class="FormattedComment"> Perhaps the issue is that Linux's original culture has become a victim of its own success. Nowadays Linux is so big and so important that it would be irresponsible to leave its development to just a bunch of hackers having fun. Maintaining it and extending it requires thousands of developers working together, because of the sheer amount of work involved, and getting that many people to cooperate productively requires boring management and professional communication etc to minimise interpersonal conflicts - the kind of culture that has helped Microsoft and IBM successfully develop software over decades with thousands of developers. It's not fun or efficient, but it works.<br> <p> If you want to work in a culture like Linux had when it was small and unimportant, there are plenty of other projects that are small and unimportant that you could work on. And hopefully you will help those to become large and successful and boring, and then can move on to another one.<br> </div> Fri, 14 Sep 2018 13:40:10 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764809/ https://lwn.net/Articles/764809/ deater <div class="FormattedComment"> I would argue that Linux devel has become toxic, but for the complete opposite reason that you think.<br> <p> Linux devel used to be fun, exciting, risky, interesting. But the big push has come in to make it corporate. And the more corporate it becomes, it's mostly now indistinguishable for coding for IBM or Microsoft or similar.<br> <p> So despite years and years of being a committed Linux user and developer, I find myself caring less and less. Because with the limited free time I have to code, why volunteer that time to a project that has become bland and boring.<br> <p> But anyway, feel free to keep up your push to stamp out what little flame there is left in the community.<br> </div> Fri, 14 Sep 2018 12:35:44 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764806/ https://lwn.net/Articles/764806/ seyman <div class="FormattedComment"> <font class="QuotedText">&gt; But Bruce Perens contributing negative things [...] might not have been a smart thing to do for the progress of mankind.</font><br> <p> Bruce Perens warning people that using Grsecurity's Linux kernel security could invite legal trouble is indeed a smart thing to do, contrary to what you claim. <br> <p> <font class="QuotedText">&gt; There would have been no reason to make a suit against him without that trigger.</font><br> <p> There was no reason to sue him even with that trigger, as a judge has ruled.<br> </div> Fri, 14 Sep 2018 12:26:14 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764794/ https://lwn.net/Articles/764794/ roc <div class="FormattedComment"> It's disingenuous to refer to Linus as just "an individual" in the community.<br> <p> As Cyberax says, it's the toleration, defense and even sometimes celebration of this behaviour that is toxic.<br> </div> Fri, 14 Sep 2018 11:35:31 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764788/ https://lwn.net/Articles/764788/ Lionel_Debroux As long as the PaX and grsecurity patchsets were publicly downloadable at no extra cost (beyond some form of Internet connection, that is), until April 2017:<br> <ul><li><i>about community support</i>: they did have a loyal following of users aware of the insecurity of mainline kernels, and willing to go through limited extra pain (especially after multiple large distros gained linux-grsec packages, at the cost of slightly reduced security because it nullifies RANDSTRUCT) to use more secure kernels than the default.<br> Unfortunately, too many people trust words by Linus and friends more than words by the real security experts PaXTeam and spender. Many people - including subsystem and driver maintainers - didn't even bother to dig deeper into the huge security benefits of PaX / grsecurity + the hundreds of small, scattered bugfixes relevant to subsystem maintainers + the many additional stable backports (see Twitter thread about hundreds more patches being backported in grsecurity than in mainline) relevant to, well, pretty much everyone not trying to run mainline kernels all the time, i.e. lots of users. Instead of making their informed opinion by themselves, some of these people based their decisions on hearsay...<br> The insecurity of mainline kernels is technically alleviable, as shown by PaX / grsecurity, but politically unfixable as shown by Linus rejecting some useful features and watering others down - as reported in this article and other earlier articles.</li> <li><i>about supporting their business model</i>: I can agree with that part of your post. It's a fact that the corporate customers, and community supporters, paying spender's company used not to be enough for PaXTeam + spender to be able to work on PaX / grsecurity near-full-time (assuming they wished to be able to do that anyway - I simply don't know). Most people just used the free version even in professional setups, few of them contributed money.<br> The KSPP made their business model even more unsustainable by creating <i>more</i> work for them by integrating buggy, watered down derivatives of outdated versions of small PaX / grsecurity subsets: PaXTeam and spender had to fix conflicts, debug issues, review mainline changes which often turned out to be more bugs than fixes they should reintegrate.</li> <li><i>good reporting, facts and sunlight</i>: it's not clear to me how good reporting / facts / sunlight would be real enemies to PaX/grsecurity. If "reporters" pretend to provide good information, based on facts, and shine some sunlight, then they have no choice but point the <a href="https://grsecurity.net/features.php">large feature set</a>. I found the earlier version clearer, with its single table full of ticks for grsecurity and missing features for mainline, but it was less detailed.<br> Maybe on the communication style front, as spender's style is known to be abrasive ? Sure, but then Linus' style is also well documented as repeatedly offensive, turning some developers away from the kernel community (see multiple posts in the sub-thread above the sub-thread I started - I'll add a mention of Sarah Sharp, who created the USB 3 stack in Linux, making Linux the first kernel with decent USB 3 support). Good reporting needs to point it too.<br> The defamation suit ? Indeed, that wasn't a step in the right direction, and definitely earned them negative publicity... But Bruce Perens contributing negative things against a technically unmatched product - from a relatively famous and supposedly trusted person, that other people can use to justify more FUD against grsecurity - might not have been a smart thing to do for the progress of mankind. There would have been no reason to make a suit against him without that trigger.</li></ul> <br> Now that they only provide the PaX and grsecurity patchsets behind a paywall accessible only to corporations (AFAIK): <ul><li>they have lost their community of individual users, obviously;</li> <li>however, they have gained customers (more logos on their web page, at least, but...), so the state of the world does support their business model to some extent, at least better than it used to when nearly everyone was free-riding. The defamation suit probably alienated them some potential customers, but the increased visibility might have unexpected benefits, who knows.</li> <li>no change on good reporting, facts and sunlight: they obviously need to mention the defamation suit and the abrasiveness, but they also have to mention the technical advantages of the product, the severe systemic insecurity of the product it is based on, and the toxicity of mainline development, starting with Linus' abrasiveness.</li></ul> <br> TL;DR: I tried to imagine what you meant in multiple areas, but I partially failed. Are you willing to give more details on what you meant ? :) Fri, 14 Sep 2018 10:23:23 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764798/ https://lwn.net/Articles/764798/ blackwood <div class="FormattedComment"> Linus and Linux are fairly regularly used in keynotes as _the_ example of a toxic/dysfunctional community. e.g. rust just recently:<br> <p> <a href="https://www.youtube.com/watch?v=J9OFQm8Qf1I&amp;feature=youtu.be&amp;t=2425">https://www.youtube.com/watch?v=J9OFQm8Qf1I&amp;feature=y...</a><br> <p> (jumps directly to the right spot)<br> </div> Fri, 14 Sep 2018 09:36:37 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764793/ https://lwn.net/Articles/764793/ Cyberax <div class="FormattedComment"> It's the tolerance of this behavior that makes it toxic.<br> </div> Fri, 14 Sep 2018 08:34:03 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764792/ https://lwn.net/Articles/764792/ lkundrak <div class="FormattedComment"> <font class="QuotedText">&gt; Is there a consensus that the Linux community is toxic?</font><br> <p> What would justify calling the whole community toxic? Is a couple of individuals who occasionally say something that insults someone else's feelings sufficient?<br> <p> If so, then any sufficiently large community is guaranteed to get toxic.<br> </div> Fri, 14 Sep 2018 07:21:33 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764786/ https://lwn.net/Articles/764786/ seyman <div class="FormattedComment"> <font class="QuotedText">&gt; Is there a consensus that the Linux community is toxic?</font><br> <p> I believe there's a consensus that a number of former kernel devs are now working on other projects because they did not appreciate the Linux community mindset. There's also consensus that a number of people have chosen to not get involved with kernel development in the first place for the same reason.<br> <p> As roc said, the kernel community itself probably disagrees and I suspect only legal action will change their minds.<br> </div> Fri, 14 Sep 2018 06:00:10 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764777/ https://lwn.net/Articles/764777/ roc <div class="FormattedComment"> I assume a lot of developers in the kernel community itself would disagree, though selection effects must partially explain that.<br> <p> But I don't think there are many other open-source projects where Linus' behaviour would be tolerated. In that sense, I think there is a consensus.<br> </div> Fri, 14 Sep 2018 00:50:02 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764776/ https://lwn.net/Articles/764776/ curtis3389 <div class="FormattedComment"> <font class="QuotedText">&gt; There are plenty of other interesting projects with non-toxic communities.</font><br> <p> This struck me.<br> <p> Is there a consensus that the Linux community is toxic?<br> </div> Fri, 14 Sep 2018 00:23:52 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764771/ https://lwn.net/Articles/764771/ sjfriedl <div class="FormattedComment"> <font class="QuotedText">&gt; grsecurity's abusive behaviour on the other hand is sincere, unwavering, and part of their business model.</font><br> <p> Not having any of the history, I'm trying to figure out what led the universe here. Everything I've seen about grsecurity is that it's real-deal security, but my review has been extremely superficial (and I'm not a user).<br> <p> Is this a case of some really smart people doing yeoman security work on the kernel, but nobody wants to pay for security, so they react badly when their business model doesn't pan out?<br> <p> Or is this something else?<br> <p> I really don't know the answer (and I have no dog in this fight). <br> </div> Thu, 13 Sep 2018 22:29:54 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764766/ https://lwn.net/Articles/764766/ seyman <div class="FormattedComment"> <font class="QuotedText">&gt; grsecurity is pretty much SCO at this point, lawsuits included.</font><br> <p> Speaking at which, did grsecurity ever refile the defamation suit they had going against Bruce Perens? Last I heard, the case had been thrown out by the judge. <br> </div> Thu, 13 Sep 2018 22:14:17 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764755/ https://lwn.net/Articles/764755/ GennaroReinger <div class="FormattedComment"> The thing is he wasn't chatting with his buddies while drinking in the pub. He was communicating with people which have only professional relationship with him. Some of them may don't even know (in-person) or like him.<br> <p> It also tells something that those "jokes" and other rude comments are traveling only the one way.<br> <p> <p> </div> Thu, 13 Sep 2018 21:33:08 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764751/ https://lwn.net/Articles/764751/ roc <div class="FormattedComment"> <font class="QuotedText">&gt; Linus' abusive behaviour is unnecessary theatrics, a curable condition. I hope one day it is so, rehabilitation is better than isolation.</font><br> <p> I agree, but he needs help. It's unclear from the outside whether anyone he respects is willing to call him on it.<br> <p> Maybe the LWN editors? They surely appreciate the problem, given that if someone repeated Linus' behaviour in these LWN comments, they'd be banned.<br> </div> Thu, 13 Sep 2018 20:09:12 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764747/ https://lwn.net/Articles/764747/ josh <div class="FormattedComment"> Once the community no longer supports you and the current state of the world no longer supports your business model, and you start building your business on FUD, then good reporting, facts, and sunlight become your enemy. (Sunlight is the best disinfectant, which is good news unless you're building your business around the infection.) grsecurity is pretty much SCO at this point, lawsuits included.<br> </div> Thu, 13 Sep 2018 19:53:26 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764746/ https://lwn.net/Articles/764746/ patrick_g <div class="FormattedComment"> <font class="QuotedText">&gt; The correct answer here is to apologize and maybe try to explain yourself.</font><br> <p> IMHO Linus tried to explain the joke because he wrote : "just google for it if you haven't seen the Holy Grail".<br> </div> Thu, 13 Sep 2018 18:56:11 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764743/ https://lwn.net/Articles/764743/ Cyberax <div class="FormattedComment"> Doesn't matter. In this case one person clearly indicated that Linus had crossed the line. The correct answer here is to apologize and maybe try to explain yourself.<br> <p> </div> Thu, 13 Sep 2018 18:41:16 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764742/ https://lwn.net/Articles/764742/ patrick_g <div class="FormattedComment"> <font class="QuotedText">&gt;in some cultures "your mom" jokes are especially EXTREMELY offensive. </font><br> <p> Problem is you'll always find a culture in which a specific referential joke is offensive. <br> The only realistic solution is to accept jokes depending on the work environment and sub-culture you are in. And Monty Python references/jokes are an important part of the hacker culture so I don't see Linus' mail crossing the line.<br> </div> Thu, 13 Sep 2018 18:34:53 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764740/ https://lwn.net/Articles/764740/ seyman <div class="FormattedComment"> <font class="QuotedText">&gt; I'm mystified as to why grsecurity is attacking LWN for the patch's supposed failings.</font><br> <p> I share that sentiment. One of the tweets pointed out by Lionel criticizes LWN for requiring quoted information to be public but I view that as a good thing.<br> </div> Thu, 13 Sep 2018 18:15:11 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764738/ https://lwn.net/Articles/764738/ Cyberax <div class="FormattedComment"> I normally do not care about Linus' behavior, but this really starts to cross the line: <a href="https://lkml.org/lkml/2018/8/15/510">https://lkml.org/lkml/2018/8/15/510</a><br> <p> No. The correct reply here would not be:<br> <font class="QuotedText">&gt; "Is there someone else up there we can talk to?"</font><br> <p> It would be an apology with a reference to Monty Python to explain it. And thinking the next time that in some cultures "your mom" jokes are especially EXTREMELY offensive. <br> </div> Thu, 13 Sep 2018 17:43:59 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764726/ https://lwn.net/Articles/764726/ flussence <div class="FormattedComment"> Linus' abusive behaviour is unnecessary theatrics, a curable condition. I hope one day it is so, rehabilitation is better than isolation.<br> <p> grsecurity's abusive behaviour on the other hand is sincere, unwavering, and part of their business model.<br> <p> I see this work, and similar efforts, as a long term project to extinguish the latter. With no more unique product to sell and a bit of patience, the company will perish and we'll suffer no more of them; they bring no skills to the table besides public trolling of anyone in the same field as them (= burnout, less security work being done, more for them to charge for), and code that takes a herculean effort every time to be hammered into fit-for-upstream condition (I don't think Hanlon's Razor applies here).<br> <p> It seems to be worth money to some companies, and it's a lot more bang for the buck in that regard than trying to kick Linus out.<br> </div> Thu, 13 Sep 2018 16:48:24 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764701/ https://lwn.net/Articles/764701/ jake <div class="FormattedComment"> <font class="QuotedText">&gt; STACKLEAK has nothing to do with Spectre and retpolines.</font><br> <p> ah, sorry about that ... my brain badly wanted to turn 'return trampoline' into 'retpoline' for some reason ... i have adjusted the article ...<br> <p> thanks,<br> <p> jake<br> </div> Thu, 13 Sep 2018 14:02:46 +0000 GCC stack_erase function attribute https://lwn.net/Articles/764699/ https://lwn.net/Articles/764699/ mjw <div class="FormattedComment"> It looks like the video of the talk isn't there yet, but I found the slides already here: <a href="https://gmarkall.files.wordpress.com/2018/09/secure_and_gcc.pdf">https://gmarkall.files.wordpress.com/2018/09/secure_and_g...</a><br> <p> The suggested attribute name was actually "stack_erase".<br> </div> Thu, 13 Sep 2018 13:52:34 +0000 GCC stackleak function attribute https://lwn.net/Articles/764697/ https://lwn.net/Articles/764697/ a13xp0p0v <div class="FormattedComment"> Nice! Thanks for the link.<br> </div> Thu, 13 Sep 2018 13:45:38 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764691/ https://lwn.net/Articles/764691/ sjfriedl <div class="FormattedComment"> <font class="QuotedText">&gt; [jkingweb] Where's the hostility coming from?</font><br> <p> No kidding. I knew nothing about this issue before this article, and the responses don't give a very good impression.<br> <p> <font class="QuotedText">&gt; [Lionel_Debroux] Since two persons are asserting opposite things about a matter, we know that at least one of them is lying, whether voluntarily or not.</font><br> <p> Uh, "involuntarily lying"? Maybe an alternate explanation is that one of them is merely mistaken?<br> </div> Thu, 13 Sep 2018 13:14:10 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764685/ https://lwn.net/Articles/764685/ a13xp0p0v <div class="FormattedComment"> Thanks for the article, Jake!<br> You've done a very good job since grsecurity doesn't complain about crediting them right.<br> <p> Let me correct this:<br> <p> <font class="QuotedText">&gt; In January 2018, he was alerted to the page-table isolation (PTI) patches, so he rebased on top</font><br> <font class="QuotedText">&gt; of those and, once Meltdown and Spectre were announced, changed STACKLEAK to deal with</font><br> <font class="QuotedText">&gt; return trampolines (retpolines).</font><br> <p> STACKLEAK has nothing to do with Spectre and retpolines.<br> <p> PTI patches introduced the trampoline stack on x86_64. Kernel switches to<br> this stack from a thread stack just before returning to the userspace. However<br> there are cases when we return to the userspace directly from the thread stack,<br> without switching to this trampoline stack.<br> <p> So during rebasing I adjusted the stack erasing. It detects which stack is used and:<br> - if it is called from the trampoline stack, erasing goes up to the thread stack top,<br> - if it is called from the thread stack, erasing goes up to the stack pointer. <br> <p> ----<br> <p> Now let me give the technical details according to Brad Spengler's comments in twitter.<br> <p> First, I should say that having any technical feedback from him about my patches<br> is a VERY rare event. So I'm glad that he posted it, let's talk about that.<br> <p> <font class="QuotedText">&gt; 'Some false quotes from LWN's regurgibloid article on STACKLEAK: "some assertions</font><br> <font class="QuotedText">&gt; in the stack tracking and alloca() checks were wrong and have been corrected" </font><br> <p> 1. The original assertion in track_stack() for detecting stack exhaustion<br> looks like that:<br> + if (unlikely((sp &amp; ~(THREAD_SIZE - 1)) &lt; (THREAD_SIZE / 16)))<br> + BUG();<br> <p> After a careful look you can see that this check will never work because of erroneous '~'.<br> <p> But if we remove this '~', we get into another trouble: when kernel stack is exhausted<br> and this check is hit, we get into recursive BUG(), since the functions which handle<br> BUG() are instrumented and call track_stack() themselves. <br> <p> As a result, this recursive BUG() handling hits the guard page below the thread stack or<br> corrupts the neighbor memory (if CONFIG_VMAP_STACK or similar feature is disabled).<br> <p> That's why I say that the original assertion in stack tracking was wrong.<br> <p> 2. Now about assertion in check_alloca().<br> In v4 I also fixed the surplus and erroneous code for calculating stack_left in check_alloca()<br> on x86_64. That code repeats the work which is already done in get_stack_info() and it<br> misses the fact that different exception stacks on x86_64 have different size.<br> <a href="https://www.openwall.com/lists/kernel-hardening/2017/10/04/68">https://www.openwall.com/lists/kernel-hardening/2017/10/0...</a><br> <p> <font class="QuotedText">&gt; "STACKLEAK was missing places where the stack needed erasing"</font><br> <p> I added missing erase_kstack() call at ret_from_fork() for x86_32.<br> <p> Anyway, if Brad will prove that I'm wrong, I'll be only happy to learn it.<br> By the way, he never thanked me for the STACKLEAK fixes which I shared with him.<br> <p> <font class="QuotedText">&gt; In fact, the current upstream-proposed STACKLEAK is weaker in a number</font><br> <font class="QuotedText">&gt; of areas where it matters</font><br> <p> I absolutely agree with Brad. Linus and Ingo made me do several changes<br> which I'm not happy about. It's the price for our compromise. In fact, Linus<br> doesn't want STACKLEAK at all, but I fight for it.<br> <p> <font class="QuotedText">&gt; (It's also slower for reasons that serve no security purpose at all,</font><br> <p> Yes, technically that's true. However, I didn't see the noticeable difference during<br> performance tests. Original stack erasing in assembly language and my stack erasing<br> in C show the same numbers.<br> <p> <font class="QuotedText">&gt; and their manual VLA removal has resulted in slower/buggier code in general</font><br> <font class="QuotedText">&gt; -- what's faster, a simple check inserted by the compiler to make sure a VLA use</font><br> <font class="QuotedText">&gt; is safe, or a whole kmalloc/kfree in a function?)'</font><br> <p> I don't have a strong opinion on that.<br> Please see Kees' talk at Linux Security Summit, which gives more details:<br> <a href="https://www.youtube.com/watch?v=XfNt6MsLj0E">https://www.youtube.com/watch?v=XfNt6MsLj0E</a><br> <p> Anyway, I don't like dropping check_alloca() forced by Linus.<br> Let's imagine that all VLAs are removed from the mainline kernel.<br> But how about VLAs in non-upstream code? STACKLEAK with check_alloca()<br> could protect it from Stack Clash!<br> <p> ----<br> <p> Let's see what will happen with my patches in the next merge window.<br> The current v15 fits Linus' requirements.<br> I wish Kees Cook the best of luck to negotiate with Linus.<br> <p> <p> </div> Thu, 13 Sep 2018 12:56:08 +0000 Trying to get STACKLEAK into the kernel https://lwn.net/Articles/764688/ https://lwn.net/Articles/764688/ jkingweb <div class="FormattedComment"> I'm mystified as to why grsecurity is attacking LWN for the patch's supposed failings. Is Jake supposed to know the patch better than its author does? Where's the hostility coming from?<br> </div> Thu, 13 Sep 2018 12:50:37 +0000