lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1345139123-15212-3-git-send-email-bp@amd64.org>
Date:	Thu, 16 Aug 2012 19:45:21 +0200
From:	Borislav Petkov <bp@...64.org>
To:	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...nel.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Frederic Weisbecker <fweisbec@...il.com>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Borislav Petkov <borislav.petkov@....com>
Subject: [RFC PATCH -v2 2/4] perf: Add persistent events

From: Borislav Petkov <borislav.petkov@....com>

Add the needed pieces for persistent events which are process-agnostic.
Also, make their buffers read-only when mmaping them from userspace.
Add a descriptor struct collecting all that is needed for a persistent
event, for ease of handling in the code later.

Signed-off-by: Borislav Petkov <borislav.petkov@....com>
---
 include/linux/perf_event.h | 17 ++++++++++++++++-
 kernel/events/core.c       |  5 ++++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 7602ccb3f40e..252aab74e64d 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -254,8 +254,9 @@ struct perf_event_attr {
 
 				exclude_host   :  1, /* don't count in host   */
 				exclude_guest  :  1, /* don't count in guest  */
+				persistent     :  1, /* always-on event */
 
-				__reserved_1   : 43;
+				__reserved_1   : 42;
 
 	union {
 		__u32		wakeup_events;	  /* wakeup every n events */
@@ -1078,6 +1079,20 @@ struct perf_output_handle {
 	int				page;
 };
 
+/*
+ * perf event descriptor to collect all attributes belonging to an event
+ */
+struct perf_event_desc {
+	struct perf_event *event;
+	struct perf_event_attr *pattr;
+	const struct file_operations *fops;
+	/* debugfs entry */
+	struct dentry *dentry;
+	const char *dir_name;
+	const char *fname;
+	int fd;
+};
+
 #ifdef CONFIG_PERF_EVENTS
 
 extern int perf_pmu_register(struct pmu *pmu, char *name, int type);
diff --git a/kernel/events/core.c b/kernel/events/core.c
index b7935fcec7d9..95026f2b3d55 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -3589,7 +3589,10 @@ static int perf_mmap(struct file *file, struct vm_area_struct *vma)
 	if (event->cpu == -1 && event->attr.inherit)
 		return -EINVAL;
 
-	if (!(vma->vm_flags & VM_SHARED))
+	if (!(vma->vm_flags & VM_SHARED) && !event->attr.persistent)
+		return -EINVAL;
+
+	if (event->attr.persistent && (vma->vm_flags & VM_WRITE))
 		return -EINVAL;
 
 	vma_size = vma->vm_end - vma->vm_start;
-- 
1.7.11.rc1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ