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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 3 Aug 2011 13:00:12 -0400
From:	Vince Weaver <vweaver1@...s.utk.edu>
To:	<linux-kernel@...r.kernel.org>
CC:	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Paul Mackerras <paulus@...ba.org>, Ingo Molnar <mingo@...e.hu>,
	Arnaldo Carvalho de Melo <acme@...stprotocols.net>
Subject: Re: [perf] enable raw OFFCORE_EVENTS for non-perf userspace


and in case we don't want to be nice to userspace and want to brutally 
suppress anyone not using the "perf" tool, here's a patch that 
returns EINVAL for any raw access that sets config1.

I actually tested to make sure the patch doesn't break PAPI, unlike my 
last attempt.

Currently we "block" access to setting the config1 value from userspace
by silently failing.  This can cause unexpected behavior (especially if
the kernel is using the OFFCORE_RSP_0 msr internally) and also makes it 
impossible to test if OFFCORE_RESPONSE events are being blocked or not.

This hackish patch causes an EINVAL to propogate back to userspace
by setting an invalid value to the config1 field.

I personally think this patch is a step backward, and the right thing to 
do is give users full access to their own hardware.  But the current state 
of affairs is bad for tools like PAPI too.



diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 4ee3abf..72baf25 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -608,8 +608,11 @@ static int x86_setup_perfctr(struct perf_event *event)
 	 * Do not allow config1 (extended registers) to propagate,
 	 * there's no sane user-space generalization yet:
 	 */
-	if (attr->type == PERF_TYPE_RAW)
-		return 0;
+	if (attr->type == PERF_TYPE_RAW) {
+		/* I HATE THIS PATCH AND EVERYTHING IT STANDS FOR.  --  VMW */
+		event->attr.config1=0xffffffff;  /* invalid, will be caught */
+		return x86_pmu_extra_regs(event->attr.config, event);
+	}
 
 	if (attr->type == PERF_TYPE_HW_CACHE)
 		return set_ext_hw_attr(hwc, event);

--
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