From: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
To: Elena Reshetova <elena.reshetova@intel.com>
Cc: rostedt@goodmis.org, peterz@infradead.org, mingo@redhat.com,
akpm@linux-foundation.org, acme@kernel.org,
alexander.shishkin@linux.intel.com, jolsa@redhat.com,
linux-kernel@vger.kernel.org, keescook@chromium.org
Subject: Re: [PATCH] uprobes: convert uprobe.ref to refcount_t
Date: Fri, 1 Feb 2019 22:51:50 +0530 [thread overview]
Message-ID: <20190201172150.GA1853@linux.vnet.ibm.com> (raw)
In-Reply-To: <1547637627-29526-1-git-send-email-elena.reshetova@intel.com>
* Elena Reshetova <elena.reshetova@intel.com> [2019-01-16 13:20:27]:
> atomic_t variables are currently used to implement reference
> counters with the following properties:
> - counter is initialized to 1 using atomic_set()
> - a resource is freed upon counter reaching zero
> - once counter reaches zero, its further
> increments aren't allowed
> - counter schema uses basic atomic operations
> (set, inc, inc_not_zero, dec_and_test, etc.)
>
> Such atomic variables should be converted to a newly provided
> refcount_t type and API that prevents accidental counter overflows
> and underflows. This is important since overflows and underflows
> can lead to use-after-free situation and be exploitable.
>
> The variable uprobe.ref is used as pure reference counter.
> Convert it to refcount_t and fix up the operations.
>
> **Important note for maintainers:
>
> Some functions from refcount_t API defined in lib/refcount.c
> have different memory ordering guarantees than their atomic
> counterparts.
> The full comparison can be seen in
> https://lkml.org/lkml/2017/11/15/57 and it is hopefully soon
> in state to be merged to the documentation tree.
> Normally the differences should not matter since refcount_t provides
> enough guarantees to satisfy the refcounting use cases, but in
> some rare cases it might matter.
> Please double check that you don't have some undocumented
> memory guarantees for this variable usage.
>
> For the uprobe.ref it might make a difference
> in following places:
> - put_uprobe(): decrement in refcount_dec_and_test() only
> provides RELEASE ordering and control dependency on success
> vs. fully ordered atomic counterpart
>
> Suggested-by: Kees Cook <keescook@chromium.org>
> Reviewed-by: David Windsor <dwindsor@gmail.com>
> Reviewed-by: Hans Liljestrand <ishkamiel@gmail.com>
> Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
> ---
> kernel/events/uprobes.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
Looks good to me.
Reviewed-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
--
Thanks and Regards
Srikar Dronamraju
next prev parent reply other threads:[~2019-02-01 17:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-16 11:20 [PATCH] uprobes: convert uprobe.ref to refcount_t Elena Reshetova
2019-01-16 13:44 ` Steven Rostedt
2019-01-21 3:57 ` Masami Hiramatsu
2019-01-31 10:12 ` Reshetova, Elena
2019-01-31 17:34 ` Oleg Nesterov
2019-02-01 17:21 ` Srikar Dronamraju [this message]
2019-02-04 6:50 ` Reshetova, Elena
2019-02-11 20:21 ` Kees Cook
2019-02-11 20:27 ` Steven Rostedt
2019-02-11 20:28 ` Steven Rostedt
2019-02-11 21:49 ` Kees Cook
2019-02-11 22:10 ` Steven Rostedt
2019-02-12 8:38 ` Reshetova, Elena
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=20190201172150.GA1853@linux.vnet.ibm.com \
--to=srikar@linux.vnet.ibm.com \
--cc=acme@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=elena.reshetova@intel.com \
--cc=jolsa@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox