Received: by 10.192.165.156 with SMTP id m28csp933786imm; Wed, 11 Apr 2018 09:29:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx49Liv/XT+s/vvrUV8JfRWe1JGsbN53K9mUd6jqFs9Df3EKhFR8lKjY9HMIUMfymhnx3m1no X-Received: by 10.98.201.15 with SMTP id k15mr4631110pfg.184.1523464186356; Wed, 11 Apr 2018 09:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523464186; cv=none; d=google.com; s=arc-20160816; b=cxeEOhrr4SLeT8AjvhzQFNE3vXMF6liOF7lW98bH5xcLHp+kPFoEWCdTpDSuO2M3Zx FQxCM5SjJuw3za6fHo23FC96qV7xkPHRUh+ZeGJYgSRNqhvz3Ro7Kttji9q2TA2532gb rTkuOFRrckxDlMXz2suc2cz/VU0l9xtZH65uDUp7B/7AVWuqCQAdiP+pXpzx8afyRdVc fP4tONB6BgVnNZfINGW6+dp/5Ke7mbrPFH5pgbmhqr82c9knttVMD87rMjjYyoUEYNIw eq5CtFO1VXsuIbu8TUGWa0fg6vQUi8pvDWnJNUDB5BFAZaLvsaXmR9ddo483pPpuPJxS Hp3A== 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:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:arc-authentication-results; bh=7893AjNenYGvB2uDz42wTe/P29lXX86EZUO0Vd/vw1I=; b=Bv+7rDIWqKPe6AxhSqYeZZJhfpKoh6UpnE6gjINuhTaRTPT8NJlXEcSbRtooA+iwZR 2bMBAP07rmLUzBpsQv/W2xykN4t9t/2QVMIvBOE1+mNXElZ3R00DMKhlvqtkKNctHcri KxPCrTif/6ErBqnlR7u+kp9FJARRvqIJC3cGMcR7UH9Rm6akkoSwQPonSOKcClMmlLNl Um6zzwaFSEYa0UTLum+4FI/eFqXOcGV1Cm3oevF65R/4YdMaqjvwZ8XHlMVIoEdC6iVd M1C8833fVztILboyOlYdkH+hryF7/d5uHl6WVKRJu8zTd67TLXXqs1uUfd/yHgZEcZTc vchA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g66si951454pgc.624.2018.04.11.09.29.08; Wed, 11 Apr 2018 09:29:46 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754063AbeDKQZY (ORCPT + 99 others); Wed, 11 Apr 2018 12:25:24 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45148 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752804AbeDKQZU (ORCPT ); Wed, 11 Apr 2018 12:25:20 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 159298182D1C; Wed, 11 Apr 2018 16:25:20 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-8.rdu2.redhat.com [10.10.120.8]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3EA68215CDAF; Wed, 11 Apr 2018 16:25:19 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 06/24] kexec_load: Disable at runtime if the kernel is locked down From: David Howells To: torvalds@linux-foundation.org Cc: linux-man@vger.kernel.org, linux-api@vger.kernel.org, jmorris@namei.org, linux-kernel@vger.kernel.org, dhowells@redhat.com, linux-security-module@vger.kernel.org Date: Wed, 11 Apr 2018 17:25:18 +0100 Message-ID: <152346391877.4030.6270466586590461223.stgit@warthog.procyon.org.uk> In-Reply-To: <152346387861.4030.4408662483445703127.stgit@warthog.procyon.org.uk> References: <152346387861.4030.4408662483445703127.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 11 Apr 2018 16:25:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 11 Apr 2018 16:25:20 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dhowells@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Garrett The kexec_load() syscall permits the loading and execution of arbitrary code in ring 0, which is something that lock-down is meant to prevent. It makes sense to disable kexec_load() in this situation. This does not affect kexec_file_load() syscall which can check for a signature on the image to be booted. Signed-off-by: Matthew Garrett Signed-off-by: David Howells Acked-by: Dave Young Reviewed-by: "Lee, Chun-Yi" Reviewed-by: James Morris cc: kexec@lists.infradead.org --- kernel/kexec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/kexec.c b/kernel/kexec.c index aed8fb2564b3..1553ac765e73 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -199,6 +199,13 @@ static inline int kexec_load_check(unsigned long nr_segments, if (!capable(CAP_SYS_BOOT) || kexec_load_disabled) return -EPERM; + /* + * kexec can be used to circumvent module loading restrictions, so + * prevent loading in that case + */ + if (kernel_is_locked_down("kexec of unsigned images")) + return -EPERM; + /* * Verify we have a legal set of flags * This leaves us room for future extensions.