Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp843007ybd; Sat, 22 Jun 2019 16:55:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxTK7M20wcNq2nupHkdSHUg6MqkGdf9MKHTyImWxJHqJRwG4BilOtEHv8BhXV3RgoAidxs8 X-Received: by 2002:a17:902:165:: with SMTP id 92mr113575403plb.197.1561247735882; Sat, 22 Jun 2019 16:55:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561247735; cv=none; d=google.com; s=arc-20160816; b=Swq8eGdaEOdanyUmjEdWzuO5qo2e12Xls0z8Sgu75Lpm4sEUtBiJOnt00jR3E+iXSU ADPsxfmLPFeqXc3an0wNXEOmmS4L8yCZGTPLisQ30vqQtBwaF4vlsJbzolClgE1s89mK V45wxYwBVCQmH13p2zsl6OooNjorvlBqIrBuhcaHDqN6zu0y7fGQ/UCwynyI/8GDJ3jr +bx902a3FAX6WnrSD/4fRs1GXAW5RbZtrB92gj4xs+L8TeLS+YRWEDuShlwUwFAAHZRa Xzrhh6rmtbzbyEu0MU3wY6BT+mhiBy7QiugTP/gSh77VQEoTbLqwXhzjmeuZV6LU65IW QZ7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=E0DLK9o2G9JjdDYpbAB7EERdssjBdQ3kUgIhR7SzB14=; b=UV1+AdiSQXLKzwn9uJKEjn3/4TF2b9ygDGCFY8p7cExowN3yz+xaJd5iUzxIflGXkd bPjTvX1M75gZPsVXfUPSAOoHhQe0CWyFIBO41KCNMVSjpAkfdW7221HLxLxiDbVMoHcm F20CXClKFBJ4v3L6EBvHyWCfjgl/TDqwoNwf86gbYLPp2x4VLsrOHUBadqMVJfveEDMS CwWmGBKjuJWqi+E2h/LV8aARTVNi21ujO1tmgV7F6itIAhhc0RE64tYqb2aqvAQ5NNJO eACskxkl1iw2PdP38afGP7x4fLmMrUQ/a5p1AcNW/Gyk/2+GD+6DKBb+JTxDZtqAtrri N0wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=PoZU+SAU; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5si5788340pgs.4.2019.06.22.16.55.20; Sat, 22 Jun 2019 16:55:35 -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=pass header.i=@chromium.org header.s=google header.b=PoZU+SAU; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726500AbfFVXyG (ORCPT + 99 others); Sat, 22 Jun 2019 19:54:06 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36914 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726296AbfFVXyG (ORCPT ); Sat, 22 Jun 2019 19:54:06 -0400 Received: by mail-pf1-f194.google.com with SMTP id 19so5432520pfa.4 for ; Sat, 22 Jun 2019 16:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=E0DLK9o2G9JjdDYpbAB7EERdssjBdQ3kUgIhR7SzB14=; b=PoZU+SAUmLJWgB2EheN3a27PmwJ+tthDLgoDrTEExRu180ZGcMB/LViOHJdFTBNylB X17zTQ2wQBMKx/B+rw9MQcR/r16JrEmksfW1pNlazb7/sre8xDr3wgaLmeh0jYQ6dzZv obJqYfCWFPrsp+QHpFF1CobqFwFBMyvi7lTwk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=E0DLK9o2G9JjdDYpbAB7EERdssjBdQ3kUgIhR7SzB14=; b=RXYRl/ezHwVHoNxjupPRU0uUHIizmqZpC/jrvdcL3mwDl1VKVIZT2YILPGZKfo3i36 y+1yF7+PQ6QFTZeGPTHPvJ5GDgT4M76BTOMIIikpUMK+xAM6aKSpLxDoWLSZN7XEMuCx +VzvG5hsTkJG+vrO2YbE2LM3kVl77SLhq9OG1VzlJsvzWhGMagqxYTMfBlrjAEoaBiXL 5iy40mI5rfLKtl9M3WN6sDbM2GvwsybgnTE+QD2UPlKTZ/nbMo/QPHj+D3yKiFjsGF1n +OVtAmwVjtPfQYlVipE+Z1jk6b8FAjdFPj/6qcCSXDKvVMfg5VOEW6VTHlgq4G4G1K5H cDtQ== X-Gm-Message-State: APjAAAVyKjDL+P5uytHhb+a6kby2DaaXQP5XjQYHyElRwHxDR/qqd/wl WaWE3y05BsIBrBB8Bs5vdy9DFg== X-Received: by 2002:a17:90a:1785:: with SMTP id q5mr15405856pja.106.1561247645823; Sat, 22 Jun 2019 16:54:05 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id f7sm6791434pfd.43.2019.06.22.16.54.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 22 Jun 2019 16:54:05 -0700 (PDT) Date: Sat, 22 Jun 2019 16:54:04 -0700 From: Kees Cook To: Matthew Garrett Cc: jmorris@namei.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Jiri Bohac , David Howells , Matthew Garrett , kexec@lists.infradead.org Subject: Re: [PATCH V34 09/29] kexec_file: Restrict at runtime if the kernel is locked down Message-ID: <201906221654.3E113D1@keescook> References: <20190622000358.19895-1-matthewgarrett@google.com> <20190622000358.19895-10-matthewgarrett@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190622000358.19895-10-matthewgarrett@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 21, 2019 at 05:03:38PM -0700, 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 Reviewed-by: Kees Cook -Kees > Signed-off-by: David Howells > Signed-off-by: Matthew Garrett > Reviewed-by: Jiri Bohac > cc: kexec@lists.infradead.org > --- > kernel/kexec_file.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c > index eec7e5bb2a08..27adb4312b03 100644 > --- a/kernel/kexec_file.c > +++ b/kernel/kexec_file.c > @@ -237,7 +237,10 @@ kimage_file_prepare_segments(struct kimage *image, int kernel_fd, int initrd_fd, > goto out; > } > > - ret = 0; > + ret = security_locked_down(LOCKDOWN_KEXEC); > + if (ret) > + goto out; > + > break; > > /* All other errors are fatal, including nomem, unparseable > -- > 2.22.0.410.gd8fdbe21b5-goog > -- Kees Cook