All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Avi Kivity <avi@redhat.com>
Cc: "Ingo Molnar" <mingo@elte.hu>,
	"Pekka Enberg" <penberg@cs.helsinki.fi>,
	"Tom Zanussi" <tzanussi@gmail.com>,
	"Frédéric Weisbecker" <fweisbec@gmail.com>,
	"Arnaldo Carvalho de Melo" <acme@redhat.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	linux-perf-users@vger.kernel.org,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: disabling group leader perf_event
Date: Tue, 07 Sep 2010 12:02:24 -0400	[thread overview]
Message-ID: <1283875344.5133.123.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <4C864281.2020907@redhat.com>

On Tue, 2010-09-07 at 16:47 +0300, Avi Kivity wrote:

> > Now here's some of my concerns for any of this. Using the kvm tracepoint
> > as an example:
> >
> > slot->base_gfn + ((hva - slot->userspace_addr)>>  PAGE_SHIFT)
> 
> We can't allow untrusted access to random kernel memory.
> 
> Let's take netfilter as an example.  Userspace downloads bytecode to 
> determine whether to allow a packet or not, or to mangle it.  The kernel 
> exposes APIs to read and write the packet, access the conntrack hash, 
> and whatever else is needed.  The bytecode reads the packet, allows, 
> denies or mangles to taste, and exits.
> 
> > If we were given "slot" and now we need to dereference it to get
> > base_gfn or userspace_addr, how would the kernel know this is a valid
> > address that can be read? Seems to me that this may allow userspace to
> > trivially see parts of the kernel that was never meant to be seen.
> 
> I don't understand this example.  Why would you need such bytecode?

I was just using this as if we were to use this bytecode for filtering
on parameters and we wanted to look at the same stuff that goes into the
buffers, but before we touch the buffer code.

> 
> For untrusted filters, you only allow access to tracepoint arguments.  
> For trusted filters, perhaps, you can allow arbitrary memory access at 
> the user's own risk.

I was thinking this too.

> 
> > One reason that ftrace only allows root access, is that the kernel is
> > best a black box for most userspace.  Letting userspace see how SELinux
> > is treating it, and finding addresses that SELinux is using, can give a
> > large arsenal to black hats that are writing tools to circumvent Linux
> > security.
> >
> > Unless we only let this interpreter access the inputs and its own
> > allocated memory, it will be very difficult to verify what the
> > interpreter is doing. I guess one thing we could do is to have a table
> > of places in the kernel that we let userspace see. This table will need
> > strict scrutinizing to verify that it can't be used to exploit other
> > parts of the kernel.
> 
> The way I see it, we expose a function pointer vector to the untrusted 
> code, similar to the syscall vector.  Trusted code may also see 
> functions to access kernel memory (or we just loosen up the validation 
> rules).

Ah, kind of what the tracepoints already do. Taking the same example:

        TP_fast_assign(
                __entry->hva            = hva;
                __entry->gfn            =
                  slot->base_gfn + ((hva - slot->userspace_addr) >> PAGE_SHIFT);
                __entry->referenced     = ref;
        ),

Have a function does the slot->base_gfn... work for us. It would also be
required that the only input is indeed the slot pointer, otherwise you
could dereference any tracepoint argument. So the arguments to the
tracepoint may get a list of helper functions that allow filtering on
dereferences to them.

This is getting a bit over-engineered IMO. If we want to do something
with the tracepoints, it should start out with simply taking the
arguments that are passed in, and then manipulating them and testing
them. Perhaps we allow a single page of heap to let the algorithms work
with.

Later, we could add functionality that could be triggered with a
condition. The first thing that comes to mind is a way to trigger the
start of tracing or stopping a trace.

-- Steve



  reply	other threads:[~2010-09-07 16:02 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-06  9:12 disabling group leader perf_event Avi Kivity
2010-09-06 11:24 ` Peter Zijlstra
2010-09-06 11:34   ` Avi Kivity
2010-09-06 11:54     ` Peter Zijlstra
2010-09-06 11:58       ` Avi Kivity
2010-09-06 12:29         ` Peter Zijlstra
2010-09-06 12:40           ` Ingo Molnar
2010-09-06 13:16             ` Steven Rostedt
2010-09-06 16:42               ` Tom Zanussi
2010-09-07 12:53                 ` Steven Rostedt
2010-09-07 14:16                   ` Tom Zanussi
2010-09-06 12:49           ` Avi Kivity
2010-09-06 12:43         ` Ingo Molnar
2010-09-06 12:45           ` Avi Kivity
2010-09-06 12:59             ` Ingo Molnar
2010-09-06 13:41               ` Pekka Enberg
2010-09-06 13:54                 ` Ingo Molnar
2010-09-06 14:57               ` Avi Kivity
2010-09-06 15:30                 ` Alan Cox
2010-09-06 15:20                   ` Avi Kivity
2010-09-06 15:48                     ` Alan Cox
2010-09-06 17:50                       ` Avi Kivity
2010-09-06 15:47                 ` Ingo Molnar
2010-09-06 17:55                   ` Avi Kivity
2010-09-07  3:44                     ` Ingo Molnar
2010-09-07  8:33                       ` Stefan Hajnoczi
2010-09-07  9:13                         ` Avi Kivity
2010-09-07 22:43                         ` Ingo Molnar
2010-09-07 15:55                       ` Alan Cox
2010-09-08  1:44                       ` Paul Mackerras
2010-09-08  6:16                         ` Pekka Enberg
2010-09-08  6:44                           ` Ingo Molnar
2010-09-08  7:30                             ` Peter Zijlstra
2010-09-08 19:30                             ` Frank Ch. Eigler
2010-09-09  7:38                               ` Ingo Molnar
2010-09-08  6:19                         ` Avi Kivity
2010-09-06 20:31                   ` Pekka Enberg
2010-09-06 20:37                     ` Pekka Enberg
2010-09-07  4:03                     ` Ingo Molnar
2010-09-07  9:30                       ` Pekka Enberg
2010-09-07 22:27                         ` Ingo Molnar
2010-09-07 10:57                     ` KOSAKI Motohiro
2010-09-07 12:14                       ` Pekka Enberg
2010-09-07 13:35                   ` Steven Rostedt
2010-09-07 13:47                     ` Avi Kivity
2010-09-07 16:02                       ` Steven Rostedt [this message]
2010-09-12  6:46                   ` Pavel Machek
2010-09-12 17:54                     ` Avi Kivity
2010-09-12 18:48                       ` Ingo Molnar
2010-09-12 19:14                         ` Pavel Machek
2010-09-12 20:32                           ` Ingo Molnar
2010-09-12 21:06                             ` Pavel Machek
2010-09-12 22:19                               ` Ingo Molnar

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=1283875344.5133.123.camel@gandalf.stny.rr.com \
    --to=rostedt@goodmis.org \
    --cc=acme@redhat.com \
    --cc=avi@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=penberg@cs.helsinki.fi \
    --cc=peterz@infradead.org \
    --cc=tzanussi@gmail.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.