History

Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull perf updates from Ingo Molnar: "The main kernel side changes in this cycle were: - Various Intel-PT updates and optimizations (Alexander Shishkin) - Prohibit kprobes on Xen/KVM emulate prefixes (Masami Hiramatsu) - Add support for LSM and SELinux checks to control access to the perf syscall (Joel Fernandes) - Misc other changes, optimizations, fixes and cleanups - see the shortlog for details. There were numerous tooling changes as well - 254 non-merge commits. Here are the main changes - too many to list in detail: - Enhancements to core tooling infrastructure, perf.data, libperf, libtraceevent, event parsing, vendor events, Intel PT, callchains, BPF support and instruction decoding. - There were updates to the following tools: perf annotate perf diff perf inject perf kvm perf list perf maps perf parse perf probe perf record perf report perf script perf stat perf test perf trace - And a lot of other changes: please see the shortlog and Git log for more details" * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (279 commits) perf parse: Fix potential memory leak when handling tracepoint errors perf probe: Fix spelling mistake "addrees" -> "address" libtraceevent: Fix memory leakage in copy_filter_type libtraceevent: Fix header installation perf intel-bts: Does not support AUX area sampling perf intel-pt: Add support for decoding AUX area samples perf intel-pt: Add support for recording AUX area samples perf pmu: When using default config, record which bits of config were changed by the user perf auxtrace: Add support for queuing AUX area samples perf session: Add facility to peek at all events perf auxtrace: Add support for dumping AUX area samples perf inject: Cut AUX area samples perf record: Add aux-sample-size config term perf record: Add support for AUX area sampling perf auxtrace: Add support for AUX area sample recording perf auxtrace: Move perf_evsel__find_pmu() perf record: Add a function to test for kernel support for AUX area sampling perf tools: Add kernel AUX area sampling definitions perf/core: Make the mlock accounting simple again perf report: Jump to symbol source view from total cycles view ...

Linus Torvalds committed 6 years ago

Commit 3f59dbc2 parents df28204 ceb9e77297 files · +32874 −23281Browse files

Showing the changes to include/linux (3 of 297 files). Show all

Unified · Split

3 files
  1. include/linux/lsm_hooks.h +15 −0
  2. include/linux/perf_event.h +59 −5
  3. include/linux/security.h +38 −1
include/linux/lsm_hooks.h+15−0
@@ -1818,6 +1818,14 @@ union security_list_options { · 1817 unmodified lines
18181818 void (*bpf_prog_free_security)(struct bpf_prog_aux *aux);
18191819 #endif /* CONFIG_BPF_SYSCALL */
18201820 int (*locked_down)(enum lockdown_reason what);
1821+#ifdef CONFIG_PERF_EVENTS
1822+ int (*perf_event_open)(struct perf_event_attr *attr, int type);
1823+ int (*perf_event_alloc)(struct perf_event *event);
1824+ void (*perf_event_free)(struct perf_event *event);
1825+ int (*perf_event_read)(struct perf_event *event);
1826+ int (*perf_event_write)(struct perf_event *event);
1827+
1828+#endif
18211829 };
18221830
18231831 struct security_hook_heads {
@@ -2060,6 +2068,13 @@ struct security_hook_heads { · 236 unmodified lines
20602068 struct hlist_head bpf_prog_free_security;
20612069 #endif /* CONFIG_BPF_SYSCALL */
20622070 struct hlist_head locked_down;
2071+#ifdef CONFIG_PERF_EVENTS
2072+ struct hlist_head perf_event_open;
2073+ struct hlist_head perf_event_alloc;
2074+ struct hlist_head perf_event_free;
2075+ struct hlist_head perf_event_read;
2076+ struct hlist_head perf_event_write;
2077+#endif
20632078 } __randomize_layout;
20642079
20652080 /*
include/linux/perf_event.h+59−5
@@ -56,6 +56,7 @@ struct perf_guest_info_callbacks { · 55 unmodified lines
5656 #include <linux/perf_regs.h>
5757 #include <linux/cgroup.h>
5858 #include <linux/refcount.h>
59+#include <linux/security.h>
5960 #include <asm/local.h>
6061
6162 struct perf_callchain_entry {
@@ -248,6 +249,8 @@ struct perf_event; · 186 unmodified lines
248249 #define PERF_PMU_CAP_NO_EXCLUDE 0x80
249250 #define PERF_PMU_CAP_AUX_OUTPUT 0x100
250251
252+struct perf_output_handle;
253+
251254 /**
252255 * struct pmu - generic performance monitoring unit
253256 */
@@ -409,6 +412,15 @@ struct pmu { · 155 unmodified lines
409412 */
410413 size_t task_ctx_size;
411414
415+ /*
416+ * PMU specific parts of task perf event context (i.e. ctx->task_ctx_data)
417+ * can be synchronized using this function. See Intel LBR callstack support
418+ * implementation and Perf core context switch handling callbacks for usage
419+ * examples.
420+ */
421+ void (*swap_task_ctx) (struct perf_event_context *prev,
422+ struct perf_event_context *next);
423+ /* optional */
412424
413425 /*
414426 * Set up pmu-private data structures for an AUX area
@@ -422,6 +434,19 @@ struct pmu { · 7 unmodified lines
422434 */
423435 void (*free_aux) (void *aux); /* optional */
424436
437+ /*
438+ * Take a snapshot of the AUX buffer without touching the event
439+ * state, so that preempting ->start()/->stop() callbacks does
440+ * not interfere with their logic. Called in PMI context.
441+ *
442+ * Returns the size of AUX data copied to the output handle.
443+ *
444+ * Optional.
445+ */
446+ long (*snapshot_aux) (struct perf_event *event,
447+ struct perf_output_handle *handle,
448+ unsigned long size);
449+
425450 /*
426451 * Validate address range filters: make sure the HW supports the
427452 * requested configuration and number of filters; return 0 if the
@@ -721,6 +746,9 @@ struct perf_event { · 293 unmodified lines
721746 struct perf_cgroup *cgrp; /* cgroup event is attach to */
722747 #endif
723748
749+#ifdef CONFIG_SECURITY
750+ void *security;
751+#endif
724752 struct list_head sb_list;
725753 #endif /* CONFIG_PERF_EVENTS */
726754 };
@@ -960,6 +988,7 @@ struct perf_sample_data { · 233 unmodified lines
960988 u32 reserved;
961989 } cpu_entry;
962990 struct perf_callchain_entry *callchain;
991+ u64 aux_size;
963992
964993 /*
965994 * regs_user may point to task_pt_regs or to regs_user_copy, depending
@@ -1241,19 +1270,41 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write, · 275 unmodified lines
12411270 int perf_event_max_stack_handler(struct ctl_table *table, int write,
12421271 void __user *buffer, size_t *lenp, loff_t *ppos);
12431272
1244−static inline bool perf_paranoid_tracepoint_raw(void)
1273+/* Access to perf_event_open(2) syscall. */
1274+#define PERF_SECURITY_OPEN 0
1275+
1276+/* Finer grained perf_event_open(2) access control. */
1277+#define PERF_SECURITY_CPU 1
1278+#define PERF_SECURITY_KERNEL 2
1279+#define PERF_SECURITY_TRACEPOINT 3
1280+
1281+static inline int perf_is_paranoid(void)
12451282 {
12461283 return sysctl_perf_event_paranoid > -1;
12471284 }
12481285
1249−static inline bool perf_paranoid_cpu(void)
1286+static inline int perf_allow_kernel(struct perf_event_attr *attr)
12501287 {
1251− return sysctl_perf_event_paranoid > 0;
1288+ if (sysctl_perf_event_paranoid > 1 && !capable(CAP_SYS_ADMIN))
1289+ return -EACCES;
1290+
1291+ return security_perf_event_open(attr, PERF_SECURITY_KERNEL);
12521292 }
12531293
1254−static inline bool perf_paranoid_kernel(void)
1294+static inline int perf_allow_cpu(struct perf_event_attr *attr)
12551295 {
1256− return sysctl_perf_event_paranoid > 1;
1296+ if (sysctl_perf_event_paranoid > 0 && !capable(CAP_SYS_ADMIN))
1297+ return -EACCES;
1298+
1299+ return security_perf_event_open(attr, PERF_SECURITY_CPU);
1300+}
1301+
1302+static inline int perf_allow_tracepoint(struct perf_event_attr *attr)
1303+{
1304+ if (sysctl_perf_event_paranoid > -1 && !capable(CAP_SYS_ADMIN))
1305+ return -EPERM;
1306+
1307+ return security_perf_event_open(attr, PERF_SECURITY_TRACEPOINT);
12571308 }
12581309
12591310 extern void perf_event_init(void);
@@ -1327,6 +1378,9 @@ extern unsigned int perf_output_copy(struct perf_output_handle *handle, · 67 unmodified lines
13271378 const void *buf, unsigned int len);
13281379 extern unsigned int perf_output_skip(struct perf_output_handle *handle,
13291380 unsigned int len);
1381+extern long perf_output_copy_aux(struct perf_output_handle *aux_handle,
1382+ struct perf_output_handle *handle,
1383+ unsigned long from, unsigned long to);
13301384 extern int perf_swevent_get_recursion_context(void);
13311385 extern void perf_swevent_put_recursion_context(int rctx);
13321386 extern u64 perf_swevent_set_period(struct perf_event *event);
include/linux/security.h+38−1
@@ -1895,5 +1895,42 @@ static inline void security_bpf_prog_free(struct bpf_prog_aux *aux) · 1894 unmodified lines
18951895 #endif /* CONFIG_SECURITY */
18961896 #endif /* CONFIG_BPF_SYSCALL */
18971897
1898−#endif /* ! __LINUX_SECURITY_H */
1898+#ifdef CONFIG_PERF_EVENTS
1899+struct perf_event_attr;
1900+struct perf_event;
1901+
1902+#ifdef CONFIG_SECURITY
1903+extern int security_perf_event_open(struct perf_event_attr *attr, int type);
1904+extern int security_perf_event_alloc(struct perf_event *event);
1905+extern void security_perf_event_free(struct perf_event *event);
1906+extern int security_perf_event_read(struct perf_event *event);
1907+extern int security_perf_event_write(struct perf_event *event);
1908+#else
1909+static inline int security_perf_event_open(struct perf_event_attr *attr,
1910+ int type)
1911+{
1912+ return 0;
1913+}
1914+
1915+static inline int security_perf_event_alloc(struct perf_event *event)
1916+{
1917+ return 0;
1918+}
1919+
1920+static inline void security_perf_event_free(struct perf_event *event)
1921+{
1922+}
1923+
1924+static inline int security_perf_event_read(struct perf_event *event)
1925+{
1926+ return 0;
1927+}
18991928
1929+static inline int security_perf_event_write(struct perf_event *event)
1930+{
1931+ return 0;
1932+}
1933+#endif /* CONFIG_SECURITY */
1934+#endif /* CONFIG_PERF_EVENTS */
1935+
1936+#endif /* ! __LINUX_SECURITY_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t