From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760497AbaKAUjc (ORCPT ); Sat, 1 Nov 2014 16:39:32 -0400 Received: from www.linutronix.de ([62.245.132.108]:47514 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759300AbaKAUj3 (ORCPT ); Sat, 1 Nov 2014 16:39:29 -0400 Date: Sat, 1 Nov 2014 21:39:17 +0100 (CET) From: Thomas Gleixner To: Andy Lutomirski cc: Peter Zijlstra , Valdis Kletnieks , "linux-kernel@vger.kernel.org" , Paul Mackerras , Arnaldo Carvalho de Melo , Ingo Molnar , Kees Cook , Andrea Arcangeli , Vince Weaver , "hillf.zj" , X86 ML Subject: Re: [PATCH v2 5/8] perf: Add pmu callbacks to track event mapping and unmapping In-Reply-To: Message-ID: References: <266afcba1d1f91ea5501e4e16e94bbbc1a9339b6.1414190806.git.luto@amacapital.net> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001,URIBL_BLOCKED=0.001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 1 Nov 2014, Andy Lutomirski wrote: > On Sat, Nov 1, 2014 at 12:59 PM, Thomas Gleixner wrote: > > On Fri, 24 Oct 2014, Andy Lutomirski wrote: > > > > I'm probably missing something. > > > > Why is this tied to the mmap? If I just open a counter then I should > > be able to read the counter from user space w/o mmapping something in > > the first place. > > You can read it with read(2), which this patch shouldn't affect. If > you want to read it with rdpmc, then you need to know what rdpmc index > to use, and the API for that is to mmap the event, check the > userpage's cap_user_rdpmc, and then rdpmc on ->idx - 1 (assuming that > ->idx != 0). You can't safely make any assumptions about which rdpmc > index it will be without explicitly checking, because perf reserves > the right to change the index whenever it wants. Got it. As I expected: I was missing something :) > There's plenty of room to tighten up the restrictions further, but > this is, I think, a decent first step, and it solves the problem of > information leaking into seccomp sandboxes. In which way? Thanks, tglx