diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-24 19:16:55 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-24 19:16:55 -0400 |
commit | 44744bb344abe032b387d361209038d2956e8c75 (patch) | |
tree | e5b4eec5a313c9ee9b7b0f22ce3ba77970ea17e0 /kernel | |
parent | 959dc2587d69f77af9de63199bd2dc468a736595 (diff) | |
parent | b3f207855f57b9c8f43a547a801340bb5cbc59e5 (diff) |
Merge branch 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull perf fixes from Ingo Molnar:
"A kprobes and a perf compat ioctl fix"
* 'perf-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
perf: Handle compat ioctl
kprobes: Skip kretprobe hit in NMI context to avoid deadlock
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/events/core.c | 23 | ||||
-rw-r--r-- | kernel/kprobes.c | 13 |
2 files changed, 34 insertions, 2 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index 1cf24b3e42ec..f9c1ed002dbc 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/cgroup.h> | 41 | #include <linux/cgroup.h> |
42 | #include <linux/module.h> | 42 | #include <linux/module.h> |
43 | #include <linux/mman.h> | 43 | #include <linux/mman.h> |
44 | #include <linux/compat.h> | ||
44 | 45 | ||
45 | #include "internal.h" | 46 | #include "internal.h" |
46 | 47 | ||
@@ -3717,6 +3718,26 @@ static long perf_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
3717 | return 0; | 3718 | return 0; |
3718 | } | 3719 | } |
3719 | 3720 | ||
3721 | #ifdef CONFIG_COMPAT | ||
3722 | static long perf_compat_ioctl(struct file *file, unsigned int cmd, | ||
3723 | unsigned long arg) | ||
3724 | { | ||
3725 | switch (_IOC_NR(cmd)) { | ||
3726 | case _IOC_NR(PERF_EVENT_IOC_SET_FILTER): | ||
3727 | case _IOC_NR(PERF_EVENT_IOC_ID): | ||
3728 | /* Fix up pointer size (usually 4 -> 8 in 32-on-64-bit case */ | ||
3729 | if (_IOC_SIZE(cmd) == sizeof(compat_uptr_t)) { | ||
3730 | cmd &= ~IOCSIZE_MASK; | ||
3731 | cmd |= sizeof(void *) << IOCSIZE_SHIFT; | ||
3732 | } | ||
3733 | break; | ||
3734 | } | ||
3735 | return perf_ioctl(file, cmd, arg); | ||
3736 | } | ||
3737 | #else | ||
3738 | # define perf_compat_ioctl NULL | ||
3739 | #endif | ||
3740 | |||
3720 | int perf_event_task_enable(void) | 3741 | int perf_event_task_enable(void) |
3721 | { | 3742 | { |
3722 | struct perf_event *event; | 3743 | struct perf_event *event; |
@@ -4222,7 +4243,7 @@ static const struct file_operations perf_fops = { | |||
4222 | .read = perf_read, | 4243 | .read = perf_read, |
4223 | .poll = perf_poll, | 4244 | .poll = perf_poll, |
4224 | .unlocked_ioctl = perf_ioctl, | 4245 | .unlocked_ioctl = perf_ioctl, |
4225 | .compat_ioctl = perf_ioctl, | 4246 | .compat_ioctl = perf_compat_ioctl, |
4226 | .mmap = perf_mmap, | 4247 | .mmap = perf_mmap, |
4227 | .fasync = perf_fasync, | 4248 | .fasync = perf_fasync, |
4228 | }; | 4249 | }; |
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 734e9a7d280b..3995f546d0f3 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
@@ -1778,7 +1778,18 @@ static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs) | |||
1778 | unsigned long hash, flags = 0; | 1778 | unsigned long hash, flags = 0; |
1779 | struct kretprobe_instance *ri; | 1779 | struct kretprobe_instance *ri; |
1780 | 1780 | ||
1781 | /*TODO: consider to only swap the RA after the last pre_handler fired */ | 1781 | /* |
1782 | * To avoid deadlocks, prohibit return probing in NMI contexts, | ||
1783 | * just skip the probe and increase the (inexact) 'nmissed' | ||
1784 | * statistical counter, so that the user is informed that | ||
1785 | * something happened: | ||
1786 | */ | ||
1787 | if (unlikely(in_nmi())) { | ||
1788 | rp->nmissed++; | ||
1789 | return 0; | ||
1790 | } | ||
1791 | |||
1792 | /* TODO: consider to only swap the RA after the last pre_handler fired */ | ||
1782 | hash = hash_ptr(current, KPROBE_HASH_BITS); | 1793 | hash = hash_ptr(current, KPROBE_HASH_BITS); |
1783 | raw_spin_lock_irqsave(&rp->lock, flags); | 1794 | raw_spin_lock_irqsave(&rp->lock, flags); |
1784 | if (!hlist_empty(&rp->free_instances)) { | 1795 | if (!hlist_empty(&rp->free_instances)) { |