All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boqun Feng <boqun.feng@gmail.com>
To: Kees Cook <keescook@chromium.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	David Windsor <dwindsor@gmail.com>,
	"Reshetova, Elena" <elena.reshetova@intel.com>,
	"kernel-hardening@lists.openwall.com"
	<kernel-hardening@lists.openwall.com>,
	Greg KH <gregkh@linuxfoundation.org>,
	"will.deacon@arm.com" <will.deacon@arm.com>,
	Hans Liljestrand <ishkamiel@gmail.com>,
	"aik@ozlabs.ru" <aik@ozlabs.ru>,
	"david@gibson.dropbear.id.au" <david@gibson.dropbear.id.au>
Subject: [kernel-hardening] Re: Conversion from atomic_t to refcount_t: summary of issues
Date: Fri, 2 Dec 2016 09:17:59 +0800	[thread overview]
Message-ID: <20161202011759.GA28026@tardis.cn.ibm.com> (raw)
In-Reply-To: <CAGXu5jLHLoPPPSEiHq-faWHDxJQWEnfc=HeC=RJ=umaqWX2Yiw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2515 bytes --]

On Thu, Dec 01, 2016 at 03:20:29PM -0800, Kees Cook wrote:
> On Thu, Dec 1, 2016 at 3:03 PM, Peter Zijlstra <peterz@infradead.org> wrote:
> > On Thu, Dec 01, 2016 at 04:31:16PM -0500, David Windsor wrote:
> >> Also, I'd like to point out that while identifying stats_t instances, I
> >> have found a similar distribution of non-standard functions (as agreed upon
> >> for the stats_t API).
> >
> >> First, usage of atomic_long_wrap_t (there currently isn't a stats_long_t
> >> planned for implementation):
> >
> > There isn't even a stats_t planned. I'm still very much not convinced
> > stats_t is needed or even makes sense.
> >
> > It wouldn't have any different semantics from atomic_t, and the only
> > argument Kees made was that reduced atomic_t usage would make it easier
> > to spot refcounts, but you're already building tools to find those.
> >
> > Once the tools work, who cares.
> 
> The tool is only part of the whole thing. By distinctly splitting the
> other major atomic_t usage pattern away from atomic_t, it solidifies a
> stats_t as NOT a reference counter. It's the slow feature-creep or bad
> example situations that I'd like to avoid. Also, tools won't catch
> everything, and doing manual inspection is much easier if we know a
> stats_t cannot be misused.
> 
> There doesn't seem to be a good reason NOT to have stats_t, beyond the
> work needed to create it and audit the places it should be used.
> 

So we currently don't have a clear semantics for stats_t, do we? What
kind of atomic_t should be replaced with stats_t? In the link David
pointed out, there are a few cases where a stats_t is put on a
correctness-related variable. I don't think that's a good place to use
stats_t.

Besides, there are many statistics-purpose variables in kernel which are
not atomic, given those, only calling atomic statistic variables stats_t
seems inappropriate and misleading.

How about provide a modifier, say __stats, like __rcu, __percpu. We can
add it to the types of the variables that are only for
statistics-purpose. I think it won't be difficult to find all related
callsites of a __stats with the help of some compiler frontend tools, we
can then detect a possible problem if we do a cmpxchg on a __stats,
which is unlikely a proper usage for a statistic variable. And we don't
need to change or use special APIs, we just need to mark variables and
fields.

Thoughts?

Regards,
Boqun

> -Kees
> 
> -- 
> Kees Cook
> Nexus Security

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

  parent reply	other threads:[~2016-12-02  1:17 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28 11:56 [kernel-hardening] Conversion from atomic_t to refcount_t: summary of issues Reshetova, Elena
2016-11-28 12:13 ` [kernel-hardening] " Peter Zijlstra
2016-11-28 12:44   ` Peter Zijlstra
2016-11-28 12:48   ` Peter Zijlstra
2016-11-28 14:12   ` [kernel-hardening] " Reshetova, Elena
2016-11-29  3:19   ` [kernel-hardening] " Alexey Kardashevskiy
2016-11-29  9:31     ` Peter Zijlstra
2016-11-30  0:23       ` Alexey Kardashevskiy
2016-11-29 15:35   ` [kernel-hardening] " Reshetova, Elena
2016-11-29 15:47     ` Peter Zijlstra
2016-12-01 19:15     ` [kernel-hardening] " Peter Zijlstra
2016-12-01 21:31       ` David Windsor
2016-12-01 23:03         ` Peter Zijlstra
2016-12-01 23:20           ` Kees Cook
2016-12-01 23:29             ` David Windsor
2016-12-02  1:17             ` Boqun Feng [this message]
2016-12-02 20:25               ` David Windsor
2016-12-07 13:24                 ` Peter Zijlstra
2016-12-07 19:03                   ` David Windsor
2016-12-09 14:48                     ` David Windsor
2016-12-07 13:36             ` Peter Zijlstra
2016-12-01 23:20           ` David Windsor
2016-12-07 13:21             ` Peter Zijlstra
2016-12-02 15:44       ` Liljestrand Hans
2016-12-02 16:14         ` Greg KH
2016-12-07 13:52         ` Peter Zijlstra
2016-12-07 15:59           ` David Windsor
2016-12-07 16:26             ` Peter Zijlstra
2016-12-07 16:31               ` David Windsor
2016-12-16 12:10           ` [kernel-hardening] " Reshetova, Elena
2016-12-16 14:01             ` [kernel-hardening] " Peter Zijlstra
2016-12-19  7:55               ` [kernel-hardening] " Reshetova, Elena
2016-12-19 10:12                 ` [kernel-hardening] " Peter Zijlstra
2016-12-20  9:13                   ` [kernel-hardening] " Reshetova, Elena
2016-12-20  9:30                     ` [kernel-hardening] " Greg KH
2016-12-20  9:40                       ` [kernel-hardening] " Reshetova, Elena
2016-12-20  9:51                         ` [kernel-hardening] " Greg KH
2016-12-20  9:55                           ` [kernel-hardening] " Reshetova, Elena
2016-12-20 10:26                             ` [kernel-hardening] " Greg KH
2016-12-20  9:41                     ` Peter Zijlstra
2016-12-20  9:58                       ` [kernel-hardening] " Reshetova, Elena
2016-12-20 10:55                       ` [kernel-hardening] " Liljestrand Hans
2016-12-20 13:13                         ` Peter Zijlstra
2016-12-20 13:35                           ` Reshetova, Elena
2016-12-20 15:20                           ` Liljestrand Hans
2016-12-20 15:52                             ` Peter Zijlstra
2017-01-10 14:58                             ` Peter Zijlstra
2016-12-07 14:13     ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161202011759.GA28026@tardis.cn.ibm.com \
    --to=boqun.feng@gmail.com \
    --cc=aik@ozlabs.ru \
    --cc=david@gibson.dropbear.id.au \
    --cc=dwindsor@gmail.com \
    --cc=elena.reshetova@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=ishkamiel@gmail.com \
    --cc=keescook@chromium.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=peterz@infradead.org \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.