Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4251381pxb; Tue, 2 Mar 2021 10:13:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzujO3UdwceD5+h9kCLYGwmtxSvAGZmdSUk8xtZPse0xk8wJh9mJ6AO6mr6DZt63n5B5bae X-Received: by 2002:a17:906:9be1:: with SMTP id de33mr17433299ejc.320.1614708832883; Tue, 02 Mar 2021 10:13:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614708832; cv=none; d=google.com; s=arc-20160816; b=0Lo/eZhd5rY3IFAlvhdkE7KjtgwVihaUe1qWgB14QnwGQOJMmX4PlFNmqDg5990B5w hGs+Ql1KkQwaESTBq90VDR7RTbauWZv9n6OEkBTr+0dPKr5SV90F81YxmNOqPwWlTv3e RvkxeexC4Ge1JEJhk0capiAyieKPATXC4mF2vqYUNIND8hAZBXk+jsiV2shOPK61U6dZ P70SavlRcIVzdk8IEqkJcZ2zKB6JqCde1MO1myNiEiDz+2OX3VqbZ1RpHJDxXBxoI7sw aDjj2FxjhsDFtK9DGMBo+xOy0j/UWqFyzjloM0a8X4ILvGsYGhQZb6mUHU5fpmn/vL2s jvMw== 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=xA2EiPMtYi+Gfmg1Yc47LmxZNfLbHszPXKAA6vPAIh8=; b=crMUgpOBRBdJP3t1oNG+0zN8ZfANZkaNksg5CX8Fk+q8kbZz0HJvRH+9xZ/04utIOO vu6ewx4vYSTqyvKwuIcUjaQ1RZDjqxodzmnOkaxHkWj5Coeq22jYCctuEh9uosYcYb5o Eht7ZWiNm5U5rionI4JFOtVii6lViRs9pWCoiEgXD/MqAQjCNmvhY/x4w1qvOQGJ+xNj yxUSIHTtrPXbGUeeQEjkpwFAr1xsyEA5ZL02ztJCDCD3X9NyRngAwt/mtKP7MJN/7WYE QxHQlpcGSQ6ASgUCx7/+gKrHWuudw8dbSCqylVlvl3n4D9d7e/9dO8CmXrwU61hZQpDV XVHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jYofzaji; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x26si4499479ejj.525.2021.03.02.10.13.27; Tue, 02 Mar 2021 10:13:52 -0800 (PST) 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=@chromium.org header.s=google header.b=jYofzaji; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1575441AbhCBD4N (ORCPT + 99 others); Mon, 1 Mar 2021 22:56:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344159AbhCAWuL (ORCPT ); Mon, 1 Mar 2021 17:50:11 -0500 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9DDDC061794 for ; Mon, 1 Mar 2021 14:49:22 -0800 (PST) Received: by mail-qk1-x730.google.com with SMTP id b130so6789315qkc.10 for ; Mon, 01 Mar 2021 14:49:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xA2EiPMtYi+Gfmg1Yc47LmxZNfLbHszPXKAA6vPAIh8=; b=jYofzajioBOR03n4mCqbrDpH6/uBSr/aENM4iC5Q2rRptMDrqaVIPX0nIF14iyLROZ 0RJhJQi0W1CELV1slYYaWGBnwqyUQmUjzRgurOCryijZ4pLbPkuTw2H4JAGuFs9fL/kW iirv9/cgEYCYikSJ/JtOiSHuDX0WkB5obllmQ= 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=xA2EiPMtYi+Gfmg1Yc47LmxZNfLbHszPXKAA6vPAIh8=; b=G/K/0TnYwBSQqbA4Fhde/YaXSDO2OXF0/AYOx55VYBjlGwxUtLnAoWKC7Vj6te7ERP hLueGvgG+bwqmJ6DKye36r/LNUcHllYeIoR3JAAGzSANb+oiltw3Vr1TpT/4ujLX8ulm WWPDq7dZs8FB5SLouJb6uBOtOdW9HTMcjzDd6AEtdl/SD1C9msLH15RaZKN7fSWAPLVd QHj0rr9Pl5059K/QjZxn8L3VFcgv89PZHcb53G9tij6R4NGsBG5wScK3KO/3nQTk3HVR q2p+VSjeTmoUFPeKqRRFHE6wTyXgSUGHTjiFXyjcraZGFDTgRmVaUl9QcCpn7mtAFef7 RJWA== X-Gm-Message-State: AOAM530bh/0iOrwV4Xst2Z6BQuz/F5h1ZrnZo61nTAvT2fLU79+DJqyM UUl5lhXcBOq2DrEBPGoxuNNMDJLnE/ZSlQ== X-Received: by 2002:a05:620a:1353:: with SMTP id c19mr6265662qkl.392.1614638961925; Mon, 01 Mar 2021 14:49:21 -0800 (PST) Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com. [209.85.219.171]) by smtp.gmail.com with ESMTPSA id b27sm2884116qkl.102.2021.03.01.14.49.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Mar 2021 14:49:21 -0800 (PST) Received: by mail-yb1-f171.google.com with SMTP id 133so18681553ybd.5 for ; Mon, 01 Mar 2021 14:49:21 -0800 (PST) X-Received: by 2002:a25:4e83:: with SMTP id c125mr24079401ybb.343.1614638581776; Mon, 01 Mar 2021 14:43:01 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Doug Anderson Date: Mon, 1 Mar 2021 14:42:50 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCHv2 1/4] perf/core: Add support to exclude kernel mode PMU tracing To: Sai Prakash Ranjan Cc: Mathieu Poirier , Suzuki K Poulose , Mike Leach , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Leo Yan , Jiri Olsa , Namhyung Kim , coresight@lists.linaro.org, Stephen Boyd , Denis Nikitin , Mattias Nissler , Al Grant , linux-arm-msm , LKML , Linux ARM Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Mon, Mar 1, 2021 at 11:05 AM Sai Prakash Ranjan wrote: > > Hardware assisted tracing families such as ARM Coresight, Intel PT > provides rich tracing capabilities including instruction level > tracing and accurate timestamps which are very useful for profiling > and also pose a significant security risk. One such example of > security risk is when kernel mode tracing is not excluded and these > hardware assisted tracing can be used to analyze cryptographic code > execution. In this case, even the root user must not be able to infer > anything. > > To explain it more clearly in the words of a security team member > (credits: Mattias Nissler), > > "Consider a system where disk contents are encrypted and the encryption > key is set up by the user when mounting the file system. From that point > on the encryption key resides in the kernel. It seems reasonable to > expect that the disk encryption key be protected from exfiltration even > if the system later suffers a root compromise (or even against insiders > that have root access), at least as long as the attacker doesn't > manage to compromise the kernel." > > Here the idea is to protect such important information from all users > including root users since root privileges does not have to mean full > control over the kernel [1] and root compromise does not have to be > the end of the world. > > But "Peter said even the regular counters can be used for full branch > trace, the information isn't as accurate as PT and friends and not easier > but is good enough to infer plenty". This would mean that a global tunable > config for all kernel mode pmu tracing is more appropriate than the one > targeting the hardware assisted instruction tracing. > > Currently we can exclude kernel mode tracing via perf_event_paranoid > sysctl but it has following limitations, > > * No option to restrict kernel mode instruction tracing by the > root user. > * Not possible to restrict kernel mode instruction tracing when the > hardware assisted tracing IPs like ARM Coresight ETMs use an > additional interface via sysfs for tracing in addition to perf > interface. > > So introduce a new config CONFIG_EXCLUDE_KERNEL_PMU_TRACE to exclude > kernel mode pmu tracing which will be generic and applicable to all > hardware tracing families and which can also be used with other > interfaces like sysfs in case of ETMs. > > [1] https://lwn.net/Articles/796866/ > > Suggested-by: Suzuki K Poulose > Suggested-by: Al Grant > Tested-by: Denis Nikitin > Link: https://lore.kernel.org/lkml/20201015124522.1876-1-saiprakash.ranjan@codeaurora.org/ > Signed-off-by: Sai Prakash Ranjan > --- > init/Kconfig | 11 +++++++++++ > kernel/events/core.c | 3 +++ > 2 files changed, 14 insertions(+) I'm not really knowledgeable at all about the perf subsystem so my review doesn't hold a lot of weight. However, Sai's patch seems sane to me. Reviewed-by: Douglas Anderson