[RFC PATCH 01/17] perf: Allow mmapping only user page
From: Alexander Shishkin
Date: Tue Sep 05 2017 - 09:30:51 EST
The 'user page' contains offsets and sizes of data and aux areas of the
ring buffer. If a user wants to mmap a pre-existing buffer, they need to
know these in order to issue mmap()s with correct offsets and sizes.
This enables mmapping of the user page if the ring buffer already exists.
Signed-off-by: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
---
kernel/events/core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index cb7eaf0f91..9389e27cb0 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5366,7 +5366,7 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
again:
mutex_lock(&event->mmap_mutex);
if (event->rb) {
- if (event->rb->nr_pages != nr_pages) {
+ if (nr_pages && event->rb->nr_pages != nr_pages) {
ret = -EINVAL;
goto unlock;
}
--
2.14.1