Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp313852ybi; Thu, 20 Jun 2019 23:44:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6Mn708vpvYZTiiIKSpN6pK1RRKE+7hNnFc85jk9FLj5FmbW1VtKwkc9PYHPdKwvv8DgLZ X-Received: by 2002:a17:902:820c:: with SMTP id x12mr32804388pln.216.1561099451330; Thu, 20 Jun 2019 23:44:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561099451; cv=none; d=google.com; s=arc-20160816; b=udByjaKOTUcSz1WWMvhvMmSl6BinTcgMWQBv5KMK17t9pSKxvXZ1q388fVsIoIVP/y S96bp5hfLGWUHrLYziockM95EpgifqsRBXt/6NLMshmjPspjuDzYZiXXYUZDEinjteHg JWCiJpJjfVgBSdmMYlF1B+HDjugJdqUCcK+8/YYPMoYiICADPWAL/p/rTt8vUe5TgE2h 6xlge0WSJtcglJKoX7PQzTE3XYcTvtR7VSCFIPr52AXM4lPYovHy2vipZxqTmMpZvkqc VGzLlPVGjbpl4TtpsrVREGaepd8300X5lOFWpYiyrbx2OD/4jSyhKysM9/A6CsvOCg1W A/yQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=SDUCDzQsDAFCjjiWdTRLA2d7rb+VQZLRvr9DLA9W7nk=; b=Lg5DMjKREER1PLWYdZYWGfoY6Cf+D5ndrsVyZpwYVYO0jrEN1zNHwcZSzmBZz14nv0 alWpdFOsJfi5b4QkjFD9pWF/YEinu+09IVG7Y2RhzRS6pGjF23sob8pkgMO1Hnat4O12 QUSC24JRl+vbnEcKkPz5tWDo5njFcjtjP/zFvWGr4pfpoJROb9SYtBbwxvlR+NpLNcGC +tKyKsfzSJY09NY8xUrfVpP8U7UiAO0n4VaqWBrmwiGfhpzZnuCmv3sFCV+Vt/mex4O8 wlhXWoAHRnMwNFdU0speL5HmXIaRslgcmgeeQ+GLA/ur+i2JACd/2d/fBt1FpKygeChs V2iA== 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 c5si1655764pgd.182.2019.06.20.23.43.55; Thu, 20 Jun 2019 23:44:11 -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 S1726092AbfFUGnv (ORCPT + 99 others); Fri, 21 Jun 2019 02:43:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43358 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726008AbfFUGnv (ORCPT ); Fri, 21 Jun 2019 02:43:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0F651F74AE; Fri, 21 Jun 2019 06:43:48 +0000 (UTC) Received: from localhost.localdomain (ovpn-12-101.pek2.redhat.com [10.72.12.101]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4DAFB5D739; Fri, 21 Jun 2019 06:43:44 +0000 (UTC) Date: Fri, 21 Jun 2019 14:43:40 +0800 From: Dave Young To: Matthew Garrett Cc: jmorris@namei.org, Jiri Bohac , linux-api@vger.kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, Matthew Garrett , dhowells@redhat.com, linux-security-module@vger.kernel.org, luto@kernel.org Subject: Re: [PATCH V31 07/25] kexec_file: Restrict at runtime if the kernel is locked down Message-ID: <20190621064340.GB4528@localhost.localdomain> References: <20190326182742.16950-1-matthewgarrett@google.com> <20190326182742.16950-8-matthewgarrett@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190326182742.16950-8-matthewgarrett@google.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 21 Jun 2019 06:43:48 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/26/19 at 11:27am, Matthew Garrett wrote: > From: Jiri Bohac > > When KEXEC_SIG is not enabled, kernel should not load images through > kexec_file systemcall if the kernel is locked down. > > [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. Modified by Matthew Garrett to remove the IMA > integration, which will be replaced by integrating with the IMA > architecture policy patches.] > > Signed-off-by: Jiri Bohac > Signed-off-by: David Howells > Signed-off-by: Matthew Garrett > Reviewed-by: Jiri Bohac > cc: kexec@lists.infradead.org > --- > kernel/kexec_file.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c > index 67f3a866eabe..a1cc37c8b43b 100644 > --- a/kernel/kexec_file.c > +++ b/kernel/kexec_file.c > @@ -239,6 +239,12 @@ kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd, > } > > ret = 0; > + > + if (kernel_is_locked_down(reason, LOCKDOWN_INTEGRITY)) { > + ret = -EPERM; > + goto out; > + } > + Checking here is late, it would be good to move the check to earlier code around below code: /* We only trust the superuser with rebooting the system. */ if (!capable(CAP_SYS_BOOT) || kexec_load_disabled) return -EPERM; > break; > > /* All other errors are fatal, including nomem, unparseable > -- > 2.21.0.392.gf8f6787159e-goog > > > _______________________________________________ > kexec mailing list > kexec@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/kexec Thanks Dave