Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3322956pxk; Mon, 21 Sep 2020 10:35:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxe0Rk2kIb9TxM5eI3Vt3fmTqKcrdCNxR3bc/BvrBlSrmnLgnp+guUXGgJV5tkFmnhByUQ1 X-Received: by 2002:a17:906:914b:: with SMTP id y11mr564814ejw.145.1600709744490; Mon, 21 Sep 2020 10:35:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600709744; cv=none; d=google.com; s=arc-20160816; b=Iu3tK342gdihSjCde+WUJrHjq/5/FoPeVFgliJ2hWIH/7nQj+jArIKbfmwhWygwbSp CBDRZ7wYGzJRfYk25y+a7bTKyTfzh5RllX+AXlGVlFMRptVbwAjDqJyc8HY6tYZGkFdg LmfN5ioqmG+mD83IG1QYxn9KjPz/UCA1x9vmtLi4RPCrr6mSyTit5+A+u1NOIqjSy1xg X8MlO/809JFJ4W1KODeIGZW/byypqVsB7DG5dxwQCm8iV/5WnsMmRRRdnTk4BlC2s3ff g15B4y7+zd2weR5hyPm9VBXanbMmlLo6DwL5fGFRmooiqA5SnkVgF7jnYakawTSlRlxm kEkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=bZxTQM+y7VCL30HjHBeKSPnidXAdXQgBZuNpKs1pbS8=; b=Ojxp5mn4KZqqn4soVS8sJhHMqW3knvt435trxLomlEaU4hX8VDjqIWLv7AuBO0nAW9 lGqL/FU2UNfsTP2WDj5DyVy9efWomEQm5QI3oS5OCnw6h4otkIKoCMXh4eI5orDU/IrR CsBtnhk24qFhgmNXaZ4oHRzCSFNKWdpkHlV9Rv9tVZwEMAjPfk8MtpHZNVLUAH0HHEM9 U0qgXUmemxZWrZHyQheD5iW/jEvbmSjxyIrtydEWrZdX4ovHPtjJfsEWEIoUOqwFIg+1 8b9RQeMpd925b0Sx+d33A3HiGojzpkdCYOSGokaf3XP4G6nW/hyo6XSAFjOKFq8N291K SpkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eT2I07jM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id re18si8584188ejb.684.2020.09.21.10.35.18; Mon, 21 Sep 2020 10:35:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eT2I07jM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727453AbgIUReE (ORCPT + 99 others); Mon, 21 Sep 2020 13:34:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726419AbgIUReE (ORCPT ); Mon, 21 Sep 2020 13:34:04 -0400 Received: from mail-io1-xd44.google.com (mail-io1-xd44.google.com [IPv6:2607:f8b0:4864:20::d44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E984C061755; Mon, 21 Sep 2020 10:34:04 -0700 (PDT) Received: by mail-io1-xd44.google.com with SMTP id y13so16310684iow.4; Mon, 21 Sep 2020 10:34:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bZxTQM+y7VCL30HjHBeKSPnidXAdXQgBZuNpKs1pbS8=; b=eT2I07jM9PMeyjSl/Te6a5BL5oucfVWd7/hkhTLvZwRxrGvJD8bC1xmLDS76suwdSc Y42cscC4DD+H8ZBIf+MP7A2iKQ2rZJAdSSVs25Exz+bTJ0I9punJG3/QpuCyr7hYZrbg go5eyVVhZjAA2BVKgKx9WZGAlmxoKfK4ozXBRdCvYJyNVVbgq5pQxuYNiI8B1scmaqsz R8w8H29Mwt91cgQH6HMMzmPITXATbXbZeayLh7zE6rMyF2Tty/9rhtsKPq6/BXzQa9sh SpahehdegJ1qal2j5+g2hvcHo46ua/hVn8+dDHDeNkMCMweR94ZQV0rU3oaKbGpZ017M 5gig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bZxTQM+y7VCL30HjHBeKSPnidXAdXQgBZuNpKs1pbS8=; b=BqCV3qTkSjkeEmO1+97TIBUDSfQajx51RiWw2gCdZdxi7cZQvBC51J37cPYf80WN7W oOIjbYLU9fBpbRawsPznwKemR1CcSR7X8869bndEyjHXJJSH5l3wZIG6ncNmu0WvfetQ ev8M8kqP0chVSrcHIgieQVmDgdxCc3h+9Bl0ih+gBhl16aR7+e5QKfP8EjQU8+LsxohZ OGyKm2/DoTQoQCOFOib8tzvvEJIIu6gawNViGz3rz25+HW8XTCqD+WFRl5cFKlD0oncQ i8T/UraJaUsdZCqPVD7OjTkKRI9gQOvrANDz+HLzuz+35fZmXMfGPRNkWCWhpI6D/JpM IB6Q== X-Gm-Message-State: AOAM5303S/Nub8GgFMCQnEK4OMxNM0rp1SnbZkJGLKh8SlpN/Iru9YRX l84g15xTyIvcmvZcKJKeFRQWfaLqJTpvqf91D74= X-Received: by 2002:a6b:7a41:: with SMTP id k1mr364011iop.187.1600709643569; Mon, 21 Sep 2020 10:34:03 -0700 (PDT) MIME-Version: 1.0 References: <20200911194549.12780-1-david.e.box@linux.intel.com> <20200911194549.12780-4-david.e.box@linux.intel.com> <0ec64bdc-66fd-4be1-03cf-561a7c42de68@linux.intel.com> <69a7e595-1b5c-bfb3-f3e6-16cf5fcc9999@linux.intel.com> In-Reply-To: <69a7e595-1b5c-bfb3-f3e6-16cf5fcc9999@linux.intel.com> From: Alexander Duyck Date: Mon, 21 Sep 2020 10:33:52 -0700 Message-ID: Subject: Re: [PATCH 3/3] platform/x86: Intel PMT Crashlog capability driver To: Alexey Budankov Cc: "David E. Box" , Lee Jones , dvhart@infradead.org, Andy Shevchenko , Alexander Duyck , LKML , platform-driver-x86@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 21, 2020 at 9:07 AM Alexey Budankov wrote: > > > On 21.09.2020 16:36, Alexander Duyck wrote: > > On Sat, Sep 19, 2020 at 1:01 AM Alexey Budankov > > wrote: > >> > >> Hi, > >> > >> Thanks for the patches. > >> > >> On 11.09.2020 22:45, David E. Box wrote: > >>> From: Alexander Duyck > >>> > >>> Add support for the Intel Platform Monitoring Technology crashlog > >>> interface. This interface provides a few sysfs values to allow for > >>> controlling the crashlog telemetry interface as well as a character driver > >>> to allow for mapping the crashlog memory region so that it can be accessed > >>> after a crashlog has been recorded. > >>> > >>> This driver is meant to only support the server version of the crashlog > >>> which is identified as crash_type 1 with a version of zero. Currently no > >>> other types are supported. > >>> > >>> Signed-off-by: Alexander Duyck > >>> Signed-off-by: David E. Box > >>> --- > >>> .../ABI/testing/sysfs-class-pmt_crashlog | 66 ++ > >>> drivers/platform/x86/Kconfig | 10 + > >>> drivers/platform/x86/Makefile | 1 + > >>> drivers/platform/x86/intel_pmt_crashlog.c | 588 ++++++++++++++++++ > >>> 4 files changed, 665 insertions(+) > >>> create mode 100644 Documentation/ABI/testing/sysfs-class-pmt_crashlog > >>> create mode 100644 drivers/platform/x86/intel_pmt_crashlog.c > >> > >> > >> > >>> + > >>> +/* > >>> + * devfs > >>> + */ > >>> +static int pmt_crashlog_open(struct inode *inode, struct file *filp) > >>> +{ > >>> + struct crashlog_entry *entry; > >>> + struct pci_driver *pci_drv; > >>> + struct pmt_crashlog_priv *priv; > >>> + > >>> + if (!capable(CAP_SYS_ADMIN)) > >>> + return -EPERM; > >> > >> Will not this above still block access to /dev/crashlogX for admin_group users > >> in case root configured access e.g. similar to this: > >> > >> ls -alh /dev/ > >> crw-rw----. 1 root admin_group 1, 9 Sep 15 18:28 crashlogX > >> > >> If yes then that capable() check is probably superfluous and > >> should be avoided in order not to block access to PMT data. > >> > >> Could you please clarify or comment? > >> > >> Thanks, > >> Alexei > > > > Actually this should probably be updated to "if (!perfmon_capable())" > > instead. The telemetry driver code originally had the CAP_SYS_ADMIN > > check and it probably makes more sense to limit this user-wise to the > > same users who have access to performon. > > Indeed, it is currently perfmon_capable() for performance part but it is unclear > if it should be the same for crashlog since it's more like a debugging thing. > It appears it all depends on usage models implemented in a user space tools e.g. Perf. > > However there is an important use case that is not covered > neither by perfmon_capable() nor by capable(CAP_SYS_ADMIN). > > It is access and usage of PMT features in cluster or cloud environments by > unprivileged users that don't have root credentials. The users however can run > software tools (Perf, VTune etc.) once installed and configured by root. > > Even though Perf tool can be configured to use use CAP_PERFMON [1] the tool binary > should still reside on a file system supporting xattr to convey capabilities > into processes implementing monitoring. > > Unfortunately NFSv3 which is quite popular to be used for storing and sharing > software tooling in large production systems doesn't support capabilities yet. > > Thus, capabilities approach still has limitation in HPC clusters and cloud environments > and for PMT support this limitation has a chance to be lifted if > suitable access control mechanism would be designed from the very beggining. > > Actually I tried to change group ownership of /dev and /sys directories and files, being root, > and it appeared that for dev file it is possible: > ls -alh /dev/ > crw-rw----. 1 root admin_group 1, 9 Sep 15 18:28 telem > > So if e.g. perf tool having CAP_PERFMON and configured like: > > -rwxr-x---. 1 root admin_group 24M Mar 5 2020 perf.cap > > would mmap /dev/telem to provide uncore performance insights > to admin_group users only access control based on user/group/others ownership > would suffice without capabilities requirement. > > Still haven't had chance to verify it for memory mapped PMT dev files and > that is why I am asking you guys here. > > Alexei > > [1] https://www.kernel.org/doc/html/latest/admin-guide/perf-security.html#privileged-perf-users-groups We will have to see. There is a high likelihood this code will go away if we switch over to binary sysfs attributes for the data. I'm still working on the rewrite and hope to have something we can review as an RFC in the next few days. Thanks. - Alex