Received: by 10.223.164.221 with SMTP id h29csp4186429wrb; Thu, 19 Oct 2017 10:44:38 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TyiDSB7Td5gtyUwjQTld/Kk3UXWLdrjuIIxN3lu5/JcoMNTUORVUukUwthL5Ebzt+akRPv X-Received: by 10.84.218.68 with SMTP id f4mr2014577plm.395.1508435078535; Thu, 19 Oct 2017 10:44:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508435078; cv=none; d=google.com; s=arc-20160816; b=t2X4Me9WSC2TsubJieyqbOZ5r4O3Ix0BBw/mhdEo+agMWJuqYH0RMV40UQQJ5z/VY3 8M4eSq95l0KMM7ZBr1WSZoJ0DkDIp4XYkeqG5ux+2QIOTn2Qxk9Y+YT+hX2uEpbIv9R1 eUU7GaGgXYAveHgeRz18D9A/wdLTpz8wSXgXwmP9EUlGySf5KWH1WAMHjdImiXwEltzx /9bd8nO1hkMGWJyeIrC2tf2QJcE0UBqVPsOd9PvVuJ65Pas/7PgG9V472T0bHd33jmk+ Oxv5ps1Bof1YjppbpcZqN5iWqhLxg8uuWNLYTkR/sKUf72MuoO36yG/9r/oOI3iUGxfV 6CKg== 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:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=UprrJTvqqxFhVB9HFZ4OoWhqn29420zYn/5u6W+z26s=; b=wNB1s9PJLXH85yxOux323s3ecQIRD+2UACUz39PUmyl1q2WRbK8SUx5r5lhkyrvUao 27h2jMDv1Ui9Pu96tcFUfPGwMds3IpPx/IZlctWutR6yi4QnY9gJWnFYQWxQXcOgbjDS Khc3yNGjA9sg/UKacmNIFSjYarTDaOLoAR0bL+It26u1cx0PyUCXXoRY+YbM3rKX7Vpt QJnP6/1jgBS2zXwp+aJUUYVT7McaQLsXQ7/P8LQznmfVPasASqfCb/Qwe83jYNosmqG+ SQnX7l4rIitNHwXyZOaB0YhPgNyhzURgl0R28LFSnV0GW2IV7d0jN1zSRERu4bZ1BH5e MMrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=WlErU3NM; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k194si8923885pgc.157.2017.10.19.10.44.24; Thu, 19 Oct 2017 10:44:38 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=WlErU3NM; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755273AbdJSRUd (ORCPT + 99 others); Thu, 19 Oct 2017 13:20:33 -0400 Received: from merlin.infradead.org ([205.233.59.134]:39376 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754317AbdJSRUa (ORCPT ); Thu, 19 Oct 2017 13:20:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=UprrJTvqqxFhVB9HFZ4OoWhqn29420zYn/5u6W+z26s=; b=WlErU3NMET7d/Aj0pFIu0sDAGd YAmWp9LKs/1SNRe38QigNGXlFpQO3OQuagt3Z0MoYuyWJDCcTEGgkGBt5MhqNqy0qnEX/y0ImaGyV Mf9HE/EvnQJk//wo2Pj365sTSO/YlBuqv0bGXklerbkLoaYnZJDZnoJCZ7dDP1gGk5XPPilawdThe JvqfLrJKR+gK8BIJkvwqfNmthLoodA/L28Nm1VBE4zvI4fSOovnGqsamX1tYxa1ncWheu7yvU9RFg v0FmHiRvi+5ZmE7qxdAUvClI2Bu3QQbhKa3MuTa8sgtEHE+SI7+MO3kikMYXVFwUaad9MPeEuaUO6 Eq6DC4TA==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=midway.dunlap) by merlin.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1e5EUe-0006lw-D7; Thu, 19 Oct 2017 17:20:28 +0000 Subject: Re: [PATCH 02/27] Add a SysRq option to lift kernel lockdown To: David Howells , linux-security-module@vger.kernel.org Cc: gnomes@lxorguk.ukuu.org.uk, linux-efi@vger.kernel.org, matthew.garrett@nebula.com, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, jforbes@redhat.com References: <150842463163.7923.11081723749106843698.stgit@warthog.procyon.org.uk> <150842464774.7923.7951986297563109339.stgit@warthog.procyon.org.uk> From: Randy Dunlap Message-ID: <97659d0c-6992-3025-0f85-819d23e954cc@infradead.org> Date: Thu, 19 Oct 2017 10:20:26 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <150842464774.7923.7951986297563109339.stgit@warthog.procyon.org.uk> 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 10/19/17 07:50, David Howells wrote: > From: Kyle McMartin > > Make an option to provide a sysrq key that will lift the kernel lockdown, > thereby allowing the running kernel image to be accessed and modified. > > On x86_64 this is triggered with SysRq+x, but this key may not be available > on all arches, so it is set by setting LOCKDOWN_LIFT_KEY in asm/setup.h. > > Signed-off-by: Kyle McMartin > Signed-off-by: David Howells > cc: x86@kernel.org > --- > > arch/x86/include/asm/setup.h | 2 ++ > drivers/input/misc/uinput.c | 1 + > drivers/tty/sysrq.c | 19 +++++++++++------ > include/linux/input.h | 5 ++++ > include/linux/sysrq.h | 8 ++++++- > kernel/debug/kdb/kdb_main.c | 2 +- > security/Kconfig | 15 +++++++++++++ > security/lock_down.c | 48 ++++++++++++++++++++++++++++++++++++++++++ > 8 files changed, 92 insertions(+), 8 deletions(-) > diff --git a/security/Kconfig b/security/Kconfig > index 8e01fd59ae7e..4be6be71e075 100644 > --- a/security/Kconfig > +++ b/security/Kconfig > @@ -213,6 +213,21 @@ config LOCK_DOWN_KERNEL > turns off various features that might otherwise allow access to the > kernel image (eg. setting MSR registers). > > +config ALLOW_LOCKDOWN_LIFT > + bool > + help > + Allow the lockdown on a kernel to be lifted, thereby restoring the > + ability of userspace to access the kernel image (eg. by SysRq+x under how about: on > + x86). > + > +config ALLOW_LOCKDOWN_LIFT_BY_SYSRQ > + bool "Allow the kernel lockdown to be lifted by SysRq" > + depends on MAGIC_SYSRQ > + help > + Allow the lockdown on a kernel to be lifted, by pressing a SysRq key > + combination on a wired keyboard. > + > + > source security/selinux/Kconfig > source security/smack/Kconfig > source security/tomoyo/Kconfig > diff --git a/security/lock_down.c b/security/lock_down.c > index d8595c0e6673..f71118c340d2 100644 > --- a/security/lock_down.c > +++ b/security/lock_down.c > + > +/* > + * Allow lockdown to be lifted by pressing something like SysRq+x (and not by > + * echoing the appropriate letter into the sysrq-trigger file). > + */ > +#ifdef CONFIG_ALLOW_LOCKDOWN_LIFT_BY_KEY is that the same as: CONFIG_ALLOW_LOCKDOWN_LIFT_BY_SYSRQ ? tested? > + > +static void sysrq_handle_lockdown_lift(int key) > +{ > + if (kernel_locked_down) > + lift_kernel_lockdown(); > +} > + > +static struct sysrq_key_op lockdown_lift_sysrq_op = { > + .handler = sysrq_handle_lockdown_lift, > + .help_msg = "unSB(x)", > + .action_msg = "Disabling Secure Boot restrictions", > + .enable_mask = SYSRQ_DISABLE_USERSPACE, > +}; > + > +static int __init lockdown_lift_sysrq(void) > +{ > + if (kernel_locked_down) { > + lockdown_lift_sysrq_op.help_msg[5] = LOCKDOWN_LIFT_KEY; > + register_sysrq_key(LOCKDOWN_LIFT_KEY, &lockdown_lift_sysrq_op); > + } > + return 0; > +} > + > +late_initcall(lockdown_lift_sysrq); > + > +#endif /* CONFIG_ALLOW_LOCKDOWN_LIFT_BY_KEY */ BY_SYSRQ -- ~Randy From 1581705988971189585@xxx Thu Oct 19 16:59:37 +0000 2017 X-GM-THRID: 1581705988971189585 X-Gmail-Labels: Inbox,Category Forums