Stable kernels 2.6.27.27 and 2.6.30.2
Update: some users are reporting boot failures with both kernel
updates; there may be yet another set of updates coming in the near future.
      Posted Jul 20, 2009 13:47 UTC (Mon)
                               by kragil (guest, #34373)
                              [Link] 
       
 
 
     
      Posted Jul 20, 2009 14:05 UTC (Mon)
                               by qg6te2 (guest, #52587)
                              [Link] (13 responses)
       
I sincerely hope this isn't a permanent solution.
 
     
    
      Posted Jul 20, 2009 14:10 UTC (Mon)
                               by proski (subscriber, #104)
                              [Link] (4 responses)
       
By the way, it would be interesting to see which object files change if this option is enabled.
 
Perhaps future version of gcc should warn if they encounter NULL pointer checks that can be eliminated.
      
           
     
    
      Posted Jul 20, 2009 16:58 UTC (Mon)
                               by vonbrand (subscriber, #4458)
                              [Link] (3 responses)
       
Because leaving (unnecesary) checks in the generated code makes it worse?
      
           
     
    
      Posted Jul 20, 2009 18:46 UTC (Mon)
                               by xorbe (guest, #3165)
                              [Link] (2 responses)
       
     
    
      Posted Jul 20, 2009 23:21 UTC (Mon)
                               by qg6te2 (guest, #52587)
                              [Link] (1 responses)
       
     
    
      Posted Jul 22, 2009 15:30 UTC (Wed)
                               by nix (subscriber, #2304)
                              [Link] 
       
 
     
      Posted Jul 20, 2009 15:10 UTC (Mon)
                               by zorro (subscriber, #45643)
                              [Link] (3 responses)
       
     
    
      Posted Jul 20, 2009 15:40 UTC (Mon)
                               by nybble41 (subscriber, #55106)
                              [Link] 
       
With the recent changes this optimization is no longer performed, which--as a fix for a single obvious logic error in the code--will lead to less efficient code in general without solving the core issue, which is the failure to test for NULL before dereferencing a potentially-NULL pointer. It would make more sense to either guarantee that execution will not continue following a NULL dereference or classify all NULL dereferences as exploitable vulnerabilities (or both). 
     
      Posted Jul 20, 2009 16:33 UTC (Mon)
                               by luto (guest, #39314)
                              [Link] 
       
The reason that the kernel wants this option but userspace doesn't is because, in kernel space, an attacker might map something into address 0, so assuming that null pointer dereferences always crash is dangerous.  In userspace, on the other hand, you've already been owned by the time someone maps something at address 0. 
     
      Posted Jul 20, 2009 19:25 UTC (Mon)
                               by stevenb (guest, #11536)
                              [Link] 
       
But examples abound.  Simple one from http://lwn.net/Articles/342226/: 
inline char foo(char *p) { if (p == 0) return 0; else return *p; } 
I already see GCC bugzilla fill with complaints when it would no longer compile this (perfectly valid) piece of code with a redundant NULL pointer check... 
 
     
      Posted Jul 20, 2009 16:27 UTC (Mon)
                               by MisterIO (guest, #36192)
                              [Link] (3 responses)
       
     
    
      Posted Jul 20, 2009 17:10 UTC (Mon)
                               by cbcbcb (subscriber, #10350)
                              [Link] 
       
Consider this: When a programmer writes a function, lets call it f(), it is good practice to validate all inputs and return an error code if they are not correct. If the programmer calls f() in a loop, and the compiler decides to inline f(), then these checks for parameters may be done repeatedly and cost significant time. 
This is very important for C++ where inline functions are used more often than in C (eg when small functions are placed inside class definitions) 
[Side note: in Java it is particularly important (for performance) to remove unneeded null pointer checks, because every pointer dereference implies a null pointer and array bounds check.] 
     
      Posted Jul 20, 2009 19:28 UTC (Mon)
                               by stevenb (guest, #11536)
                              [Link] (1 responses)
       
     
    
      Posted Jul 21, 2009 4:56 UTC (Tue)
                               by MisterIO (guest, #36192)
                              [Link] 
       
     
    Stable kernels 2.6.27.27 and 2.6.30.2
      
      Eugene Teo (1): Add '-fno-delete-null-pointer-checks' to gcc CFLAGS
Stable kernels 2.6.27.27 and 2.6.30.2
      
      Why?
Stable kernels 2.6.27.27 and 2.6.30.2
      Stable kernels 2.6.27.27 and 2.6.30.2
      Stable kernels 2.6.27.27 and 2.6.30.2
      
      Say someone wants to compile the kernel with a compiler other than GCC --  what if the compiler doesn't have an equivalent to "-fno-delete-null-pointer-checks" ?
      
          Stable kernels 2.6.27.27 and 2.6.30.2
      Stable kernels 2.6.27.27 and 2.6.30.2
      
Stable kernels 2.6.27.27 and 2.6.30.2
      
Stable kernels 2.6.27.27 and 2.6.30.2
      
Stable kernels 2.6.27.27 and 2.6.30.2
      
Stable kernels 2.6.27.27 and 2.6.30.2
      
char bar(char *p) { *p = 2; return foo(p); }
int main() { char c = 0; return bar(&c); }
Stable kernels 2.6.27.27 and 2.6.30.2
      
Stable kernels 2.6.27.27 and 2.6.30.2
      
Stable kernels 2.6.27.27 and 2.6.30.2
      
Stable kernels 2.6.27.27 and 2.6.30.2
      
           