Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4527976imb; Wed, 6 Mar 2019 16:02:28 -0800 (PST) X-Google-Smtp-Source: APXvYqyHcqoaQYDlqZThlzi1+6ER69Hpb7NIIA3jz49TjdDCULE1Uwp+SMxt75DsRMuDdvvY4B1K X-Received: by 2002:a17:902:4545:: with SMTP id m63mr9564168pld.71.1551916948671; Wed, 06 Mar 2019 16:02:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551916948; cv=none; d=google.com; s=arc-20160816; b=AV94rgOtNTwVI9PNffSR3ywip10eRnlLpCPlG5MAJwpnG1B/xhQVs6xDc+Uzux/xC8 FWO/66eW7fvLO/tzA685tvgmw2z6FXEvOhsq6HIZTZ8UBS/bNvKo5+pTorOF/COEZ3uU nqjUVkukSZiSkce9GHVkTfraUv4WrZP3YFoqd41UiNpyArPaRU6s5IDO6CtJ9ropvngF lsB8qf6IuuCQ9uaY1GLRUSAat3y8/cwzv3H5z+aMqX4BM3FMoc14mTbqZWttjZKb9HTB 38ZjErbUXWdR2bY6NQuoO3O/F84FAkmbYRNeiwUNFQegaiS/YSHiXYENXAMvys36UhNb BvLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=1/Q9WI1yRVatQ/yQs+U4SWm6wGnrwBw/w693pRoFvME=; b=yGu+pG0gjvfCN1C+ayc0xlvGeYJphOV/2/lrmxZLYCRvi/1zJJ6jSgQklhYGTHRmb1 y0Rt38X/iLSnHMCRp74OpLlBjtvb/MyDkNmNksvIfozktX5BslgqbNXbmoVPw6DNC7Gl rdP/GIGLeoF4U7NtMQIi9whebs2qZNoJQeqRKvBMS66BIXq4Mn3dVDnXjM9j0mbqQZLA FKRTDzbaDWBAeGDCnD8t7aFVGVfaDxyvMjZCeEoCXaLNxWdRXONV0fGEGCAa2/pj/VGr HlhA+PnHYYUHBiqX5eBt/ViIjFzIsF4dq4uuSNK2BAwtoCsiT0OVu0NSg2hALgJn9uhP nS9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ja0HNHll; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1si2672993plr.439.2019.03.06.16.02.13; Wed, 06 Mar 2019 16:02:28 -0800 (PST) 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=@google.com header.s=20161025 header.b=Ja0HNHll; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726713AbfCGAAb (ORCPT + 99 others); Wed, 6 Mar 2019 19:00:31 -0500 Received: from mail-pf1-f201.google.com ([209.85.210.201]:51835 "EHLO mail-pf1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726705AbfCGAA3 (ORCPT ); Wed, 6 Mar 2019 19:00:29 -0500 Received: by mail-pf1-f201.google.com with SMTP id 23so15436383pfj.18 for ; Wed, 06 Mar 2019 16:00:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=1/Q9WI1yRVatQ/yQs+U4SWm6wGnrwBw/w693pRoFvME=; b=Ja0HNHllquwFqNG1YcYRVsIuOz1GquTrJ6u28a+VNVnXPhxF0/mfK/FHq09suoplle 7JqwJEgcdxpohcoOyj26m2vvd2O3DWaqqVJfBENoEsmPBIwdu9vxrBtRnHwgBn5u4uMz CGvyoeNzOQApATOK1KARCskkWxz6Zkg83BIqJ8sf7ZnfQ+y6DbqwKfs1rA5Lsw1IO0Yn 86ZEJt3E1SPzRbvLNtuYph5p1H02Q+kVt115/5FBrrpN9ok4axreUzF+V4aHGUXoKvcY PoXpEbSBn/qn3twrhP+7BhbzPl6dPIAt0jvQxIn5hP4UbXMvUAaKhgGorMQDWn7McRPd 22TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=1/Q9WI1yRVatQ/yQs+U4SWm6wGnrwBw/w693pRoFvME=; b=TJJjCFhVVH81TG4lRvI5CpVKHakhNOMcK3dG7QirJ585tNVAgi7FsU17hrrZTHfqIA XV5OmhW1hfmmlxHARlR6CFc5SOoxBZ2yzQNwqk/G8MV1C/TykzfhJklTel79ExFy4K1I 2X0Ebutl66jJMX2mBH9QS4WhD8LHDLTxiDG9DCb00dt4k5ERiuJIq8clxUcNf2rNcQcw iokFXlM6hMKfCpRE7P0gWrY5Fx/ohY7eUWiFnehJLRLpTkI4CwJbyDO9/X9isxoxI09H GVja0/qYylShM/V/zpWEnU85cEbl7t4hLWNWPjDqjofZbMTXv4CDdNlZnC0FDhbVu5Ry HiXQ== X-Gm-Message-State: APjAAAUy3jTV0A8W1Q6BjB8pKgoiTljsvvSPd9JytFzrmTMGHMO+KrhS Pu5Gy6HGKIkITkAiaQ6ouqh6y4bUIWNHJOaUsP33AA== X-Received: by 2002:a63:a506:: with SMTP id n6mr37123pgf.98.1551916826638; Wed, 06 Mar 2019 16:00:26 -0800 (PST) Date: Wed, 6 Mar 2019 15:59:09 -0800 In-Reply-To: <20190306235913.6631-1-matthewgarrett@google.com> Message-Id: <20190306235913.6631-24-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190306235913.6631-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.21.0.352.gf09ad66450-goog Subject: [PATCH 23/27] Lock down kprobes From: Matthew Garrett To: jmorris@namei.org Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, dhowells@redhat.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Howells Disallow the creation of kprobes when the kernel is locked down by preventing their registration. This prevents kprobes from being used to access kernel memory, either to make modifications or to steal crypto data. Reported-by: Alexei Starovoitov Signed-off-by: David Howells Signed-off-by: Matthew Garrett --- kernel/kprobes.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/kprobes.c b/kernel/kprobes.c index f4ddfdd2d07e..6f66cca8e2c6 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -1552,6 +1552,9 @@ int register_kprobe(struct kprobe *p) struct module *probed_mod; kprobe_opcode_t *addr; + if (kernel_is_locked_down("Use of kprobes")) + return -EPERM; + /* Adjust probe address from symbol */ addr = kprobe_addr(p); if (IS_ERR(addr)) -- 2.21.0.352.gf09ad66450-goog