Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp852526ybd; Sat, 22 Jun 2019 17:09:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4BgKHs821dL5YDpBs4bh4nfB53BYimqmTPlYjqY/SYWNs2x/oCRjKt3SaH8GlpRtuaUbh X-Received: by 2002:a63:289:: with SMTP id 131mr19528543pgc.211.1561248595876; Sat, 22 Jun 2019 17:09:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561248595; cv=none; d=google.com; s=arc-20160816; b=L+PNnPkfQN+IEJtecgd+eCQBClwhIiXzmecOjdE+9sABJ8MEFi3rd61iALWxbOUTIM 033nGDDRuJMeY9OMZactxCvaFsqOK/fcEY4eLpm78yzEG8L4PwPp/jbFambn8mqZUeSx GdmnSQmlLxGx48/so1m8vs/5VltrnDa1/r02YEVB5uvQB5wOK2RwAcVXX/jWNXwzKCLK 5vQSEZuSyBWk1YcpxtHKQEP9a2GvxPDila77S/3bGDfBk9kbP5cgHtUSs+3xmcGa++k4 VOh4O06c2/6fUDrl8FXcV2ODLVMCxQfHLwuHqeH3vbg5dPNkqPGaO8HJSQ6jP/Kj+Ryy KkMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=vWIjWJgohtlUoEwu3+7zUIlhLSIs1C/QTS8o7CJbmYY=; b=DQDHqlxk2yePQM9DtCXHGSzgZdgsZ4Or1iS0CeQYBspFpf38LAaMq7MXBJSenz1wuK eqZ+gPeMJfqS0ecIIfqX3F8g8mMQl+8aoyo2kPsBE9b68JDFVW4Bt4/S0CQEL6mPzfQx r1gi3/y65vZg9jb4aWom0K/5aDgrmaPHoKijY7aiENWgWNc6deJNj17SQCSeekEv7RsQ 4ECAsqoNvHTX2VV4Frkdj9wb3KoYTAqWy7UJkvgoNvzxEhsPE6rA6JLZKMS5R7V12lUa XvRO6xByRC/WTkaxyVxDlRfgZ2Wj/HmK+0MRyTDwSKFhjQJOACbZVpXI/rdkzUekszSr HxvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=oXxHB58C; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si6129056pgq.465.2019.06.22.17.09.37; Sat, 22 Jun 2019 17:09:55 -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=pass header.i=@chromium.org header.s=google header.b=oXxHB58C; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726523AbfFWAJD (ORCPT + 99 others); Sat, 22 Jun 2019 20:09:03 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:40369 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726410AbfFWAJD (ORCPT ); Sat, 22 Jun 2019 20:09:03 -0400 Received: by mail-pf1-f194.google.com with SMTP id p184so5431819pfp.7 for ; Sat, 22 Jun 2019 17:09:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=vWIjWJgohtlUoEwu3+7zUIlhLSIs1C/QTS8o7CJbmYY=; b=oXxHB58CnJuSsv8e6M+Hv435kyh+G5amzn9487tXyJ/z1gwAX1/iqax2cRXrSQui/V dpewHIy8N9N9V8GZ4/BIe3R/O/iFF2vJq1IUNXXLMEyj5gmBVudu0i12Wp0itb6zp4nC roTiUqbSHiLr5TB50VhMJeLam+l0vAsTaPE1I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=vWIjWJgohtlUoEwu3+7zUIlhLSIs1C/QTS8o7CJbmYY=; b=uFNg63TFs73Rr8CQxsW7RP4S9Nqo3/0jJLU5L3+n5dJJVrpXodDxa08kj8tEYRZR8d hJS3DhiToDW8kpyD77w6WXXDgC6663zOGNXWyTrZpFIW4XJDwgvIHZoTRZJtBDCdTR5j KylDqyrBF83SZQiLQxDlVYsKBC0vx29T6tlrb5SrIFgjC8nC0bT83Zyd5c4Kg51H9FK+ RlFaVdpJj/xBjjIpiFcTmLASAVKPSDgxLf2zhrd1oeUWifoPTUHdy9AbMkhf1C39Xn8R cZWi7MItI52bYiYnzjz+D7UwaQRuU80wSGX0k2Ibq1sgh/inhBrb/R7SSZvURNrmc5m5 SAng== X-Gm-Message-State: APjAAAW1TNH7F82VG6GXYd4L/g0/UjGJqEVJQ3fK9JG8SaVAcnxX89PX Fut1o7ZMNxgmUHVw5/+6qlNISw== X-Received: by 2002:a17:90a:b883:: with SMTP id o3mr15506972pjr.50.1561248542488; Sat, 22 Jun 2019 17:09:02 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id n7sm7096532pff.59.2019.06.22.17.09.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 22 Jun 2019 17:09:01 -0700 (PDT) Date: Sat, 22 Jun 2019 17:09:00 -0700 From: Kees Cook To: Matthew Garrett Cc: jmorris@namei.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, David Howells , Alexei Starovoitov , Matthew Garrett , "Naveen N . Rao" , Anil S Keshavamurthy , davem@davemloft.net, Masami Hiramatsu Subject: Re: [PATCH V34 22/29] Lock down tracing and perf kprobes when in confidentiality mode Message-ID: <201906221708.4E617CD@keescook> References: <20190622000358.19895-1-matthewgarrett@google.com> <20190622000358.19895-23-matthewgarrett@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190622000358.19895-23-matthewgarrett@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 21, 2019 at 05:03:51PM -0700, Matthew Garrett wrote: > From: David Howells > > Disallow the creation of perf and ftrace kprobes when the kernel is > locked down in confidentiality mode by preventing their registration. > This prevents kprobes from being used to access kernel memory to steal > crypto data, but continues to allow the use of kprobes from signed > modules. > > Reported-by: Alexei Starovoitov > Signed-off-by: David Howells > Signed-off-by: Matthew Garrett > Cc: Naveen N. Rao > Cc: Anil S Keshavamurthy > Cc: davem@davemloft.net > Cc: Masami Hiramatsu Reviewed-by: Kees Cook -Kees > --- > include/linux/security.h | 1 + > kernel/trace/trace_kprobe.c | 5 +++++ > security/lockdown/lockdown.c | 1 + > 3 files changed, 7 insertions(+) > > diff --git a/include/linux/security.h b/include/linux/security.h > index 3875f6df2ecc..e6e3e2403474 100644 > --- a/include/linux/security.h > +++ b/include/linux/security.h > @@ -96,6 +96,7 @@ enum lockdown_reason { > LOCKDOWN_MMIOTRACE, > LOCKDOWN_INTEGRITY_MAX, > LOCKDOWN_KCORE, > + LOCKDOWN_KPROBES, > LOCKDOWN_CONFIDENTIALITY_MAX, > }; > > diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c > index 5d5129b05df7..5a76a0f79d48 100644 > --- a/kernel/trace/trace_kprobe.c > +++ b/kernel/trace/trace_kprobe.c > @@ -11,6 +11,7 @@ > #include > #include > #include > +#include > > #include "trace_dynevent.h" > #include "trace_kprobe_selftest.h" > @@ -415,6 +416,10 @@ static int __register_trace_kprobe(struct trace_kprobe *tk) > { > int i, ret; > > + ret = security_locked_down(LOCKDOWN_KPROBES); > + if (ret) > + return ret; > + > if (trace_probe_is_registered(&tk->tp)) > return -EINVAL; > > diff --git a/security/lockdown/lockdown.c b/security/lockdown/lockdown.c > index 4c9b324dfc55..5a08c17f224d 100644 > --- a/security/lockdown/lockdown.c > +++ b/security/lockdown/lockdown.c > @@ -32,6 +32,7 @@ static char *lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX+1] = { > [LOCKDOWN_MMIOTRACE] = "unsafe mmio", > [LOCKDOWN_INTEGRITY_MAX] = "integrity", > [LOCKDOWN_KCORE] = "/proc/kcore access", > + [LOCKDOWN_KPROBES] = "use of kprobes", > [LOCKDOWN_CONFIDENTIALITY_MAX] = "confidentiality", > }; > > -- > 2.22.0.410.gd8fdbe21b5-goog > -- Kees Cook