linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vincent Donnefort <vdonnefort@google.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org,
	mathieu.desnoyers@efficios.com, kernel-team@android.com,
	rdunlap@infradead.org, rppt@kernel.org, david@redhat.com,
	linux-mm@kvack.org
Subject: Re: [PATCH v22 2/5] ring-buffer: Introducing ring-buffer mapping functions
Date: Thu, 9 May 2024 12:05:30 +0100	[thread overview]
Message-ID: <Zjyt-nX3el5nnDPm@google.com> (raw)
In-Reply-To: <20240507223402.206d6ddc@rorschach.local.home>

On Tue, May 07, 2024 at 10:34:02PM -0400, Steven Rostedt wrote:
> On Tue, 30 Apr 2024 12:13:51 +0100
> Vincent Donnefort <vdonnefort@google.com> wrote:
> 
> > +#ifdef CONFIG_MMU
> > +static int __rb_map_vma(struct ring_buffer_per_cpu *cpu_buffer,
> > +			struct vm_area_struct *vma)
> > +{
> > +	unsigned long nr_subbufs, nr_pages, vma_pages, pgoff = vma->vm_pgoff;
> > +	unsigned int subbuf_pages, subbuf_order;
> > +	struct page **pages;
> > +	int p = 0, s = 0;
> > +	int err;
> > +
> > +	/* Refuse MP_PRIVATE or writable mappings */
> > +	if (vma->vm_flags & VM_WRITE || vma->vm_flags & VM_EXEC ||
> > +	    !(vma->vm_flags & VM_MAYSHARE))
> > +		return -EPERM;
> > +
> > +	/*
> > +	 * Make sure the mapping cannot become writable later. Also tell the VM
> > +	 * to not touch these pages (VM_DONTCOPY | VM_DONTEXPAND). Finally,
> > +	 * prevent migration, GUP and dump (VM_IO).
> > +	 */
> > +	vm_flags_mod(vma, VM_DONTCOPY | VM_DONTEXPAND | VM_IO, VM_MAYWRITE);
> 
> Do we really need the VM_IO?
> 
> When testing this in gdb, I would get:
> 
> (gdb) p tmap->map->subbuf_size
> Cannot access memory at address 0x7ffff7fc2008
> 
> It appears that you can't ptrace IO memory. When I removed that flag,
> gdb has no problem reading that memory.

Yeah, VM_IO indeed implies DONTDUMP. VM_IO was part of Linus recommendations.
But perhaps, VM_DONTEXPAND and MIXEDMAP (implicitely set by vm_insert_pages) are
enough protection?

I don't see how anything could use GUP there and as David pointed-out on the
previous version, it doesn't event prevent the GUP-fast path.

> 
> I think we should drop that flag.
> 
> Can you send a v23 with that removed, Shuah's update, and also the
> change below:

Ack.

[...]

  reply	other threads:[~2024-05-09 11:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-30 11:13 [PATCH v22 0/5] Introducing trace buffer mapping by user-space Vincent Donnefort
2024-04-30 11:13 ` [PATCH v22 1/5] ring-buffer: Allocate sub-buffers with __GFP_COMP Vincent Donnefort
2024-05-02 13:18   ` David Hildenbrand
2024-04-30 11:13 ` [PATCH v22 2/5] ring-buffer: Introducing ring-buffer mapping functions Vincent Donnefort
2024-05-02 13:30   ` David Hildenbrand
2024-05-02 13:38     ` Vincent Donnefort
2024-05-02 13:46       ` Steven Rostedt
2024-05-08  2:34   ` Steven Rostedt
2024-05-09 11:05     ` Vincent Donnefort [this message]
2024-05-10  9:15       ` David Hildenbrand
2024-05-10 10:57         ` Vincent Donnefort
2024-05-10  9:19     ` David Hildenbrand
2024-05-10 11:03       ` Vincent Donnefort
2024-05-10 18:42         ` Steven Rostedt
2024-04-30 11:13 ` [PATCH v22 3/5] tracing: Allow user-space mapping of the ring-buffer Vincent Donnefort
2024-04-30 11:13 ` [PATCH v22 4/5] Documentation: tracing: Add ring-buffer mapping Vincent Donnefort
2024-04-30 11:13 ` [PATCH v22 5/5] ring-buffer/selftest: Add ring-buffer mapping test Vincent Donnefort
2024-05-03 19:12   ` Shuah Khan
2024-05-07 23:35     ` Steven Rostedt
2024-05-10 11:04       ` Vincent Donnefort
2024-05-10 18:44         ` Steven Rostedt
2024-05-10 18:50           ` Steven Rostedt

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=Zjyt-nX3el5nnDPm@google.com \
    --to=vdonnefort@google.com \
    --cc=david@redhat.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=rppt@kernel.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;
as well as URLs for NNTP newsgroup(s).