Received: by 10.223.185.116 with SMTP id b49csp1980798wrg; Thu, 22 Feb 2018 06:23:56 -0800 (PST) X-Google-Smtp-Source: AH8x225JVMNTKfYQB9/U3U9gGbh0ADq3Br+UCu0TttQPlfLlDVXDA9qFsPVvbuo3NlcEruD9VVxV X-Received: by 2002:a17:902:a984:: with SMTP id bh4-v6mr6629889plb.95.1519309436089; Thu, 22 Feb 2018 06:23:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519309436; cv=none; d=google.com; s=arc-20160816; b=bREtPStoUUfH3PfKMl19hfBKssPNWkHDlydVy9CsvUmSsxIK3WMyb5UHJrjWmlGlNK 5PVgaZOe3kx3GPh9cI1YpTwNVWeELPF3GIFbWjhPYuv1z4o7iwbv81uhUVTj2YKA7Gks bciZ15wjVnv982touY9MiWA3v8sbGbgxxD42lXsHfFPoGo4B4UV1LrRraEp0M0MTA2r5 aKtd62zRn8TWxATv2cqs/nRWqBs+eACQou6RoGSnH1Q7VqJq7r4G+VaMKFfshTeEwe0U E27FwTzSWm0KzfBH6pHj9D22zxQyvplbuFkB4YYkzFKm6NvSHWYRLRuqO6kqSP9QEe46 r0cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:references:in-reply-to:from :organization:arc-authentication-results; bh=kLAhfjgDkoFMN2c4WhI9+549pw+3OyZOGQR9nozhXb4=; b=F31vhxoXTxSPyvuIS1q61FOn3CJ8S/G0jUqk4rvxM5YJu0mXhQLAq6WuTcvhAbG72t o5OSner2Rp3TlJi6S/zXP0658V6Y73VOP0E+KyXOAxAt3lVs9UKi4cKkRqhrtn3ji7sE r3cdVGNCqHcPY7xmA8OIeydRf2GEoSvDpBVkM8/KbDrEmX3mYOjQkGpZ1fPT2M78tZQE lIg0kxVrLPutE2zb8w06WkGXQEkhYKjlinfXWO+xZG+Jb9YqA2pJ9QtHY4Jq4H4spJos C9jikUQnECY6t8TLB12EcH/LH1VTf3NyaqkRrDetKd29rqCWaDJRDpCc2/3mlOW3tvKE pCdw== 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 p22-v6si112691plo.206.2018.02.22.06.23.41; Thu, 22 Feb 2018 06:23:56 -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; 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 S932735AbeBVOV6 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 22 Feb 2018 09:21:58 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60370 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932564AbeBVOVy (ORCPT ); Thu, 22 Feb 2018 09:21:54 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4C7A240363B6; Thu, 22 Feb 2018 14:21:54 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-250.rdu2.redhat.com [10.10.120.250]) by smtp.corp.redhat.com (Postfix) with ESMTP id 921742026609; Thu, 22 Feb 2018 14:21:53 +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 From: David Howells In-Reply-To: <8846.1519309243@warthog.procyon.org.uk> References: <8846.1519309243@warthog.procyon.org.uk> <151024869793.28329.4817577607302613028.stgit@warthog.procyon.org.uk> <151024863544.28329.2436580122759221600.stgit@warthog.procyon.org.uk> To: linux-security-module@vger.kernel.org Cc: dhowells@redhat.com, gnomes@lxorguk.ukuu.org.uk, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, jforbes@redhat.com Subject: Re: [PATCH 08/30] kexec_file: Restrict at runtime if the kernel is locked down MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <8886.1519309313.1@warthog.procyon.org.uk> Content-Transfer-Encoding: 8BIT Date: Thu, 22 Feb 2018 14:21:53 +0000 Message-ID: <8887.1519309313@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 22 Feb 2018 14:21:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 22 Feb 2018 14:21:54 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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 David Howells wrote: > I'm intending on inserting the attached patch before this one. And replacing this patch with the attached. David --- commit ed0424c531d7dd25adebdec0ee6a78a5784f207a Author: David Howells Date: Thu Feb 22 14:01:49 2018 +0000 kexec_file: Restrict at runtime if the kernel is locked down When KEXEC_VERIFY_SIG is not enabled, kernel should not load images through kexec_file systemcall if the kernel is locked down unless IMA can be used to validate the image. [Modified by David Howells to fit with modifications to the previous patch and to return -EPERM if the kernel is locked down for consistency with other lockdowns] Signed-off-by: Jiri Bohac Signed-off-by: David Howells Cc: Matthew Garrett cc: Chun-Yi Lee cc: kexec@lists.infradead.org diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index d5931e392050..c47c4de604cd 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -167,6 +167,14 @@ kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd, } ret = 0; + if (is_ima_appraise_enabled()) + break; + + if (kernel_is_locked_down(reason)) { + ret = -EPERM; + goto out; + } + break; /* All other errors are fatal, including nomem, unparseable