Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1074503ybi; Fri, 21 Jun 2019 13:18:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrFdfRNGBZNirJKHlILPGEc9h+bL+0F6qyz+ZONsHtzsSEhDL5az0bgdB6eM3jSeQ1AgZi X-Received: by 2002:a17:902:b594:: with SMTP id a20mr55441971pls.259.1561148315003; Fri, 21 Jun 2019 13:18:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561148314; cv=none; d=google.com; s=arc-20160816; b=pNpRsF4feL2o8MHPMeSVQynwkMD1/3GMwUXX88fcSzfGPU9kVEamVvU9pdsFZw5/Ex Sh1f/tEkjSWD/sfSTj0O/+XB1MiWGTN63h0W7EVJHgSV2+oZgtE/sW26bQZrmsAnoZxh 4Br3V1sLUXauG3Gi1UKN67L5UoiMEt4/rTyjop+tKFmAyKD534LLNUpgB2QibO0lrqAV uqZx3alYyjAo2SQTpelKtzYBAWq3WdLlBM7AiNUHMVefdZkQ8LtT+NfUbhzq1R7xPk6y djyqM7W+5LlNiP+/gyK0FB0Rdq3TQGGr+MxaUUpnI+f86MIaVWqyiJB+2VfN8+XPIvu9 1jjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=E8efNcZtDwk7IidLHvLtP2hUl2fc9Kq5GohdU6xk+B0=; b=I9VSwD7kgxVw1Ynq11106SaYFpP2aE2yoOQwX6J/BhvbrXJfFJUCrd0ryWn3Os4tBh x3+s0qrLWV3V5v5GsB/RgbV2ewpIp8k7ts4885HSpTb8fIeCu6gVSXn/dMr5ZD0C28wG 9TghlwPd3TzqpmZ9fd2trOGVabIEVEuemvwEejnjFVzCIVUkBBuSzknLRlb6n2L8qR2T O9Hrbp/63s0TLerLHHkAn2ZgBz2oDeWov9QsabdD5DA1Fu7MR1vyfi4UkIdgXGSXxhqk 6+8BQ33J14zgl/DaE5daykg1a5dOJiOU4EndsNOJxJjOHS8F23oTnGV65lmmVkpuZPgO 0yYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Xj6Qle4/"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h21si3318349pgv.266.2019.06.21.13.18.19; Fri, 21 Jun 2019 13:18:34 -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=@google.com header.s=20161025 header.b="Xj6Qle4/"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726125AbfFUUSQ (ORCPT + 99 others); Fri, 21 Jun 2019 16:18:16 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:38684 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbfFUUSP (ORCPT ); Fri, 21 Jun 2019 16:18:15 -0400 Received: by mail-io1-f67.google.com with SMTP id j6so277148ioa.5 for ; Fri, 21 Jun 2019 13:18:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=E8efNcZtDwk7IidLHvLtP2hUl2fc9Kq5GohdU6xk+B0=; b=Xj6Qle4/q+GM5Ky8b2Khzf+oX1HiCniPCrEDrmA+nj/WMc5akAtYIQ6OJAj94ohBnb aX/9RTXO5LkDnk+mBUQQ3x5MOXNAP593Aaj9qJC62m3BuAAYVd0BM7x93MxB/eZMb564 ViDCqclpjT6u2cPNdJPmy22KXsTS0PnyoaQr4/78/7lxat7WAmkNrYzoalaarcBaxu4F NSSswrNR2IN5nwO5k82C1Yn/EoGPNInSbjbOYm6PbKtTaMEFc7ghnTss+GAsTc0VT3co iuuiNOnnE44+qY9sKAADPI3IEyStp11UrDg0PBvvcQhHnmGq9z6GO7nxez9WzxkFMPbs k7LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=E8efNcZtDwk7IidLHvLtP2hUl2fc9Kq5GohdU6xk+B0=; b=L0mjl5s8xDo+mC27yqZBu8AiacEKCXlzHAjd0V1VUSe0sdQoGvs4j14c/jMXhpoNbP gBtrtXQNV5N8wuw4WVJw6ggGiRkyB8/JBDhcF0UWMZXqWHc65Uaeqq283zYluHtYvWup g/CF40rz6Hl4mHPJ8m7Ki4u/YNrKr84+WIsXLN7artNwgywIwUCKcyn9VOwRXIaUfQni kkMAqRCNnF17cy0xYFSSwiB3zqunrUpxXKOLvbZ+/g4WPQE8L/pVTFb3MJuQHqwlA/OO uiEa+YXnAMQDVEiRkdwGgCkwYzwQg820YaTWSAfDbuHqbYcsuHqvju7rnyrv7AaaUTdU +Scw== X-Gm-Message-State: APjAAAW0kDXac69T284zbvRSnTDKK9hnTHyoq+9AGw/LSwOHBn+qbbCw BpkpQ8kKFbDiyZZDbnfSvehLtTyMNlGG3QSl3fihdQ== X-Received: by 2002:a05:6638:3d3:: with SMTP id r19mr12698566jaq.53.1561148294551; Fri, 21 Jun 2019 13:18:14 -0700 (PDT) MIME-Version: 1.0 References: <20190326182742.16950-1-matthewgarrett@google.com> <20190326182742.16950-8-matthewgarrett@google.com> <20190621064340.GB4528@localhost.localdomain> In-Reply-To: <20190621064340.GB4528@localhost.localdomain> From: Matthew Garrett Date: Fri, 21 Jun 2019 13:18:03 -0700 Message-ID: Subject: Re: [PATCH V31 07/25] kexec_file: Restrict at runtime if the kernel is locked down To: Dave Young Cc: James Morris , Jiri Bohac , Linux API , kexec@lists.infradead.org, Linux Kernel Mailing List , David Howells , LSM List , Andy Lutomirski Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 20, 2019 at 11:43 PM Dave Young wrote: > > 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; I don't think so - we want it to be possible to load images if they have a valid signature.