On Thu, Nov 17, 2016 at 07:30:29AM -0500, David Windsor wrote:
> On Thu, Nov 17, 2016 at 3:34 AM, Peter Zijlstra <pet...@infradead.org> wrote:
> > No, its not a statistic. Also, I'm far from convinced stats_t is an 
> > actually useful thing to have.
> >
> 
> Regarding this, has there been any thought given as to how stats_t 
> will meaningfully differ from atomic_t?  If refcount_t is semantically 
> "atomic_t with reference counter overflow protection," what 
> services/guarantees does stats_t provide?  I cannot think of any that 
> don't require implementing overflow detection of some sort, which 
> incurs a performance hit.

>Afaict the whole point of stats_t was to allow overflow, since its only stats, 
>nobody cares etc..

>I think the sole motivator is a general distaste of atomic_t, which isn't a 
>good reason at all.

I don't think anyone has this as motivation. But atomic_t is so powerful and 
flexible that easily ends up being misused (as past CVEs shown). 
Even if we now find all occurrences of atomic_t used as refcounter (which we 
cannot actually guarantee in any case unless someone manually reads every line)
and convert it to refcount_t, we still have atomic_t type present and new usage 
of it as refount will crawl in. It is just a matter of time IMO. 

So, this approach still doesn't solve the main problem: abuse of atomic_t a 
refcounter and  security vulnerabilities as result.  
What other mechanisms can we think we can utilize to prevent it? 
- Checkpatch? Would be hard to write enough rules to find all possible patterns 
how creative people might use atomic as refcounter. 
- People reviewing the code? Many kernel vulnerabilities live outside of core 
kernel, where maintainers are careful about what gets in and what's not. 
Further you go from core kernel (especially when you reach non-upstream 
drivers), code review quality is less, possibility of mistake is higher, and on 
average this code has more vulnerabilities. We can't say "this is not upstream 
code, who cares", because we want Linux kernel to follow "secure by default" 
principle: to provide enough mechanisms in kernel itself to minimize risk of 
mistakes and vulnerabilities. I think atomic is a great example of such case. 
We need to make it hard for people to make mistakes with overflows when 
overflows actually matter. 
This was really a reason for our initial approach that provided "security by 
default". Certainly it had some issues (we all agree on this), but let's think 
how else can we provide "secure by default" protection for this.  

 

Reply via email to