Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp504505ybb; Fri, 3 Apr 2020 06:57:45 -0700 (PDT) X-Google-Smtp-Source: APiQypJs31zp1xrka4DlKFePC7IxvoKE9kQojQEKT9J9g/metRtSMQAtz59ztBmJIYgLfgsgO40y X-Received: by 2002:a9d:3b6:: with SMTP id f51mr6819846otf.255.1585922265810; Fri, 03 Apr 2020 06:57:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585922265; cv=none; d=google.com; s=arc-20160816; b=udv9R+B/Z48YQfkM7W4S6bSgXBNn1Ebx+Xyo6zlcDihAc8Q3Awn8Gcq/6knC2955k0 PWTxRz1XZJ9HWvUEL4YUIVgqWDFPKX2ejLJ/3L0JabsPy2cHxoxzJ3dQnGJjppxmzLOM YDAK7yU5Z+GKjxAkmtDopyKFkw+nWzE/vtZxWuj/5V9O6LtKuuIkVpl/RAKjIUmZfmbo eC8aIiwgJZxjYltArh8YfEI8LIlvt/NR6sssVEpT2JEjOqbg5eduqmXWP5aMaLJphGsA lrHUZaMSDpF/c24Y/Peglwf+zhe3j+rXZ/8+YTfCUijMR10otky1wO4wCUQ9Ca16ROrw azbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:references:cc:to:from:subject:ironport-sdr :ironport-sdr; bh=06R/0wdmgI1iKcrrQXykG0hoYpEQi5qiowcK+w1l7bo=; b=Z8LnZo1ZMTCudtdAf+jLb7KTpxhtfPcAjpytqzRZcSftqai/30qPTR5IqVcXdcbqg5 89KkI/1AXDQdKIYqqmSbwUVgZFBByzfvJqnumv7R23dx73wRu6QsO7+IyrSKFsCn63WM Oi6jAFWKWUZhFmySeOVhNqebPfrGkCmD/ThPs6vlFbLxtUo5UMzK3tbaZxO4Urns3oyk qwGMrDCWFMre08/2sSxGkn5iebv1a+XymQr3CtejZdNy/JdPKBbO3DttOZN5VqhHTwDV y4B6WrrFGHDaCBO4YeYl6yGUOF0N8EcnfBOvXMIsEXM63G808RMJ7Tx1e2O5bbD2jeOJ 8iHQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w14si3215905otl.175.2020.04.03.06.57.31; Fri, 03 Apr 2020 06:57:45 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391005AbgDCN4u (ORCPT + 99 others); Fri, 3 Apr 2020 09:56:50 -0400 Received: from mga12.intel.com ([192.55.52.136]:54582 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390883AbgDCN4t (ORCPT ); Fri, 3 Apr 2020 09:56:49 -0400 IronPort-SDR: flEouXuH0PyoTBVneQUKeYeAB/YyK0Qos4o5kKZMbEd3486T4z0trc59S5Y9avwane7faXPgep pffrscfTyYyA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Apr 2020 06:56:48 -0700 IronPort-SDR: sg/BjNhR9EPaUobM7/48I3JxZw/KmrC8Aq4/WNwtGT1eUOuEuvoYSJ4igirXB08rZO+HN27WLt P0imZBIZJ91w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,339,1580803200"; d="scan'208";a="253373358" Received: from linux.intel.com ([10.54.29.200]) by orsmga006.jf.intel.com with ESMTP; 03 Apr 2020 06:56:48 -0700 Received: from [10.249.254.224] (abudanko-mobl.ccr.corp.intel.com [10.249.254.224]) by linux.intel.com (Postfix) with ESMTP id 8DE9E5802C8; Fri, 3 Apr 2020 06:56:45 -0700 (PDT) Subject: Re: [PATCH v4 2/9] perf/core: open access for CAP_SYS_PERFMON privileged process From: Alexey Budankov To: Alexei Starovoitov Cc: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , James Morris , Jiri Olsa , Andi Kleen , Alexander Shishkin , Namhyung Kim , linux-kernel References: <20200108160713.GI2844@hirez.programming.kicks-ass.net> <20200110140234.GO2844@hirez.programming.kicks-ass.net> <20200111005213.6dfd98fb36ace098004bde0e@kernel.org> <20200110164531.GA2598@kernel.org> <20200111084735.0ff01c758bfbfd0ae2e1f24e@kernel.org> <2B79131A-3F76-47F5-AAB4-08BCA820473F@fb.com> <5e191833.1c69fb81.8bc25.a88c@mx.google.com> <158a4033-f8d6-8af7-77b0-20e62ec913b0@linux.intel.com> <20200114122506.3cf442dc189a649d4736f86e@kernel.org> <81abaa29-d1be-a888-8b2f-fdf9b7e9fde8@linux.intel.com> <257a949a-b7cc-5ff1-6f1a-34bc44b1efc5@linux.intel.com> <687dc836-4d86-c281-75b3-c4df451e7cd1@linux.intel.com> Organization: Intel Corp. Message-ID: <6dfd7ded-3294-6ec5-dcc0-92303a5cecb5@linux.intel.com> Date: Fri, 3 Apr 2020 16:56:44 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <687dc836-4d86-c281-75b3-c4df451e7cd1@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01.04.2020 23:50, Alexey Budankov wrote: > Hi Alexei, > > On 15.01.2020 4:52, Alexei Starovoitov wrote: >> On Tue, Jan 14, 2020 at 10:50 AM Alexey Budankov >> wrote: >>> >>> >>> On 14.01.2020 21:06, Alexei Starovoitov wrote: >>>> On Tue, Jan 14, 2020 at 1:47 AM Alexey Budankov >>>> wrote: >>>>>>> >>>>>>> As we talked at RFC series of CAP_SYS_TRACING last year, I just expected >>>>>>> to open it for enabling/disabling kprobes, not for creation. >>>>>>> >>>>>>> If we can accept user who has no admin priviledge but the CAP_SYS_PERFMON, >>>>>>> to shoot their foot by their own risk, I'm OK to allow it. (Even though, >>>>>>> it should check the max number of probes to be created by something like >>>>>>> ulimit) >>>>>>> I think nowadays we have fixed all such kernel crash problems on x86, >>>>>>> but not sure for other archs, especially on the devices I can not reach. >>>>>>> I need more help to stabilize it. >>>>>> >>>>>> I don't see how enable/disable is any safer than creation. >>>>>> If there are kernel bugs in kprobes the kernel will crash anyway. >>>>>> I think such partial CAP_SYS_PERFMON would be very confusing to the users. >>>>>> CAP_* is about delegation of root privileges to non-root. >>>>>> Delegating some of it is ok, but disallowing creation makes it useless >>>>>> for bpf tracing, so we would need to add another CAP later. >>>>>> Hence I suggest to do it right away instead of breaking >>>>>> sys_perf_even_open() access into two CAPs. >>>>>> >>>>> >>>>> Alexei, Masami, >>>>> >>>>> Thanks for your meaningful input. >>>>> If we know in advance that it still can crash the system in some cases and on >>>>> some archs, even though root fully controls delegation thru CAP_SYS_PERFMON, >>>>> such delegation looks premature until the crashes are avoided. So it looks like >>>>> access to eBPF for CAP_SYS_PERFMON privileged processes is the subject for >>>>> a separate patch set. >>>> >>>> perf_event_open is always dangerous. sw cannot guarantee non-bugginess of hw. >>> >>> Sure, software cannot guarantee, but known software bugs could still be fixed, >>> that's what I meant. >>> >>>> imo adding a cap just for pmc is pointless. >>>> if you add a new cap it should cover all of sys_perf_event_open syscall. >>>> subdividing it into sw vs hw counters, kprobe create vs enable, etc will >>>> be the source of ongoing confusion. nack to such cap. >>>> >>> >>> Well, as this patch set already covers complete perf_event_open functionality, >>> and also eBPF related parts too, could you please review and comment on it? >>> Does the patches 2/9 and 5/9 already bring all required extentions? >> >> yes. the current patches 2 and 5 look good to me. > > Could this have you explicit Reviewed-by or Acked-by tag so > the changes could be driven into the kernel? > Latest v7 is here: https://lore.kernel.org/lkml/c8de937a-0b3a-7147-f5ef-69f467e87a13@linux.intel.com/ Posted v8 with all acquired tags so far: https://lore.kernel.org/lkml/f96f8f8a-e65c-3f36-dc85-fc3f5191e8c5@linux.intel.com/ Thanks, Alexey