Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp554325ybp; Fri, 11 Oct 2019 00:06:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwR0AOLcm+ikf4auNYuioYoF9eWrytMzZIJP5xPV/u59ffX2c91j450lRjMEXGZ6wYQbYZd X-Received: by 2002:a50:cd17:: with SMTP id z23mr12253496edi.250.1570777609966; Fri, 11 Oct 2019 00:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570777609; cv=none; d=google.com; s=arc-20160816; b=Q4rG/RTdz6SFNezC/mJwchuoT2D7NGmmRLTVE1AqKEgOG28DXHDRw8vnTsGO/JVBuE LloUGv1IO65JVrxYOzjRl1D9Po6iFdOAmoComLM2Ds40Qczv5VMCAvNBnu4z4NmfOxrT e3p7wwmX6vnBakBYWe7qMdOT+hvCVDnEc37l6yVv4UyeMmgxjIYRacxJ+WEVnKFzYbid hWu2++m8R8QpiRrfs/FqJCYpYOKxjeCUr2bZX54P9EwpPbf5EQ3rEcPKDceW1spVUCzp iSqS9R+MlZKJV+yL2bi3OSvUV9bUtP7v0VWBcr+L4kIUty7gz7/FKHtZUY/ez55/IICB J3yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=B7tSt4++AeNClEYMJ6vFiBHpS1WJihxuciejr2hX7bs=; b=zWEPLMz9qEp3e+Q+hPNbw4c+R8wmX0GtlQ4mab/3oVHDhipQXL38CEi1SmDe+ueCxX UseA6pwRgS7BwjDy1zjI2niLX2Rs99dv0S+yAekTzfR2ZtThGATrgtshy+3HWUcAzBmn YozWqQStdL1s4vjBOn1omQAAcTEmF0BvuvQ2rDA+6Vf96WS4VOUzkE0Wa0tAjp+4E89U dHb20cCqsab0icLc+beOoX5xPvHu+cwUH2S8XPv/GWbsbu030KPAuV4cvxxEa79T4AJ2 QQzP4qxmAA/n8UPsZU/ldWoFLKBTkD+NhO9rv5pkUEUNRLw56TQ+bxPAl9knbjv6+88H kKwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=GvnBbSeR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rh23si4722563ejb.75.2019.10.11.00.06.25; Fri, 11 Oct 2019 00:06:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=GvnBbSeR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727272AbfJKHGL (ORCPT + 99 others); Fri, 11 Oct 2019 03:06:11 -0400 Received: from merlin.infradead.org ([205.233.59.134]:40260 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726679AbfJKHGK (ORCPT ); Fri, 11 Oct 2019 03:06:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=B7tSt4++AeNClEYMJ6vFiBHpS1WJihxuciejr2hX7bs=; b=GvnBbSeRL2D7Djol5QJK4MqT+ f5pua78F2o9VGO8YAmoQv16DV8cOvHSqAM9e+4JIHcuJk2nKDeKvCJgnjYK3SQmzdBKk/2cWLMjoP pqAr/BidNI3as9nX/sJ7HaZqkEUiPCJGbFRFWV43iqClh+ek5Zjd5NrBpLm9I3OBWbx3fFeSgpjPZ 3HFr+5JoDrvRlwuZm1pms3rRyfSGcNJfzUjfRAw364CFb46QXZD81LBxKBMsyJSDD+zBjU7daKMVD 1mOylo3pTqay0R17ca4hZEsnO/6nJZdOUAJMyDqQ3vsoeecqLMGUu0QG3I3eSmhNIyAVAAMK79Ql9 tk4BJxQ0w==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1iIozh-0004C0-Du; Fri, 11 Oct 2019 07:05:45 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id C6927301224; Fri, 11 Oct 2019 09:04:50 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4FEF021492B15; Fri, 11 Oct 2019 09:05:43 +0200 (CEST) Date: Fri, 11 Oct 2019 09:05:43 +0200 From: Peter Zijlstra To: Joel Fernandes Cc: linux-kernel@vger.kernel.org, rostedt@goodmis.org, primiano@google.com, rsavitski@google.com, jeffv@google.com, kernel-team@android.com, Alexei Starovoitov , Arnaldo Carvalho de Melo , bpf@vger.kernel.org, Daniel Borkmann , Ingo Molnar , James Morris , Jiri Olsa , Kees Cook , linux-security-module@vger.kernel.org, Matthew Garrett , Namhyung Kim , selinux@vger.kernel.org, Song Liu , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , Yonghong Song Subject: Re: [PATCH RFC] perf_event: Add support for LSM and SELinux checks Message-ID: <20191011070543.GV2328@hirez.programming.kicks-ass.net> References: <20191009203657.6070-1-joel@joelfernandes.org> <20191010081251.GP2311@hirez.programming.kicks-ass.net> <20191010151333.GE96813@google.com> <20191010170949.GR2328@hirez.programming.kicks-ass.net> <20191010183114.GF96813@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191010183114.GF96813@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 10, 2019 at 02:31:14PM -0400, Joel Fernandes wrote: > On Thu, Oct 10, 2019 at 07:09:49PM +0200, Peter Zijlstra wrote: > > Yes, I did notice, I found it weird. > > > > If you have CAP_IPC_LIMIT you should be able to bust mlock memory > > limits, so I don't see why we should further relate that to paranoid. > > > > The way I wrote it, we also allow to bust the limit if we have disabled > > all paranoid checks. Which makes some sense I suppose. > > > > The original commit is this: > > > > 459ec28ab404 ("perf_counter: Allow mmap if paranoid checks are turned off") > > I am thinking we can just a new function perf_is_paranoid() that has nothing > to do with the CAP_SYS_ADMIN check and doesn't have tracepoint wording: > > static inline int perf_is_paranoid(void) > { > return sysctl_perf_event_paranoid > -1; > } > > And then call that from the mmap() code: > if (locked > lock_limit && perf_is_paranoid() && !capable(CAP_IPC_LOCK)) { > return -EPERM; > } > > I don't think we need to add selinux security checks here since we are > already adding security checks earlier in mmap(). This will make the code and > its intention more clear and in line with the commit 459ec28ab404 you > mentioned. Thoughts? Mostly that I'm confused by the current code ;-) Like I said, CAP_IPC_LIMIT on its own should already allow busting the limit, I don't really see why we should make it conditional on paranoid. But if you want to preserve behaviour (arguably a sane thing for your patch) then yes, feel free to do as you propose.