From patchwork Thu Jun 18 23:12:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seth Forshee X-Patchwork-Id: 1312489 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49nyVC1M33z9sNR; Fri, 19 Jun 2020 09:16:03 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jm3lF-0001KG-9G; Thu, 18 Jun 2020 23:15:57 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jm3jS-0000CX-LB for kernel-team@lists.ubuntu.com; Thu, 18 Jun 2020 23:14:06 +0000 Received: from mail-io1-f69.google.com ([209.85.166.69]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jm3jQ-000056-Tl for kernel-team@lists.ubuntu.com; Thu, 18 Jun 2020 23:14:05 +0000 Received: by mail-io1-f69.google.com with SMTP id l19so5366506iol.5 for ; Thu, 18 Jun 2020 16:14:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AwYcIsdy0Sw03kYMfbvUFlWqCJhDqXXwh6mECPJ4aSs=; b=MgTw8nPOluv9rWdQQWF8dnDaGCN4WLbXjJ56loUfoFABH46dt4tGHylEyT/iqbkt21 hB/+1nDPEqz87Fho91wIX8/EpD80mt0otdzNzZwxJ6J43BFBSSg++1CB7hyyZZsSL49G aGPI0j9BlNio679VEIHf/MEwcalvuTmHxv82FuJzsM61TGC7ps2LUCi+PmXEvXzOwp1x iJkEb67Jflo0vFsnRR8L0pMiV3FwURwjNxLv0/A5+NREZP+e7scpbEnuwI5WVRqPLOoN CO6kgBlKYCrtmRWtROewa9S7+6b3b0DKQB+WnBH4SGkE3ffzBhWoXR7DS7bI+HqguaZ9 Vz3w== X-Gm-Message-State: AOAM533ZhQYtbL+2A4V2/5peKWJd1k/GsF7dxFoK2ZR4ZcQ7szUnkoN7 fo+CdsCFKhx4ets0yKzv6lRZBoBMsMs2Torh8fHu3HpVElLJ4zqM/3edaGfOWZsscu5P1uebf2m uLbzjC/DWWNb937nb442QTtjohpeju92iYxU4FZfjXA== X-Received: by 2002:a5e:c242:: with SMTP id w2mr1204066iop.86.1592522043719; Thu, 18 Jun 2020 16:14:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7J54pG2O7Y2XXuux0jik6gAsGpwG9XxJvS8HNrSgLL6mcDuFCNIhJNeRF4ZHNp1Smg/303w== X-Received: by 2002:a5e:c242:: with SMTP id w2mr1204050iop.86.1592522043481; Thu, 18 Jun 2020 16:14:03 -0700 (PDT) Received: from localhost ([2605:a601:ac0f:820:f090:1573:c2fc:6389]) by smtp.gmail.com with ESMTPSA id k3sm2232308ils.27.2020.06.18.16.14.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2020 16:14:03 -0700 (PDT) From: Seth Forshee To: kernel-team@lists.ubuntu.com Subject: [PATCH 45/47][X] UBUNTU: SAUCE: (efi-lockdown) kexec_file: Disable at runtime if the kernel is locked down Date: Thu, 18 Jun 2020 18:12:56 -0500 Message-Id: <20200618231258.630575-46-seth.forshee@canonical.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200618231258.630575-1-seth.forshee@canonical.com> References: <20200618231258.630575-1-seth.forshee@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Chun-Yi Lee BugLink: https://bugs.launchpad.net/bugs/1884159 When KEXEC_VERIFY_SIG is not enabled, kernel should not load images through kexec_file systemcall if the kernel is locked down. This code was showed in Matthew's patch but not in git: https://lkml.org/lkml/2015/3/13/778 Cc: Matthew Garrett Signed-off-by: Chun-Yi Lee Signed-off-by: David Howells Reviewed-by: James Morris cc: kexec@lists.infradead.org (backported from commit 6620737c201ed7242dbb672803085b46ae600ce7 git://git.kernel.org/pub/scm/linux/kernel/git/jwboyer/fedora.git) Signed-off-by: Seth Forshee --- kernel/kexec_file.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 6030efd4a188..14d19eda9ec9 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -317,6 +317,12 @@ SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, initrd_fd, if (!capable(CAP_SYS_BOOT) || kexec_load_disabled) return -EPERM; + /* Don't permit images to be loaded into trusted kernels if we're not + * going to verify the signature on them + */ + if (!IS_ENABLED(CONFIG_KEXEC_VERIFY_SIG) && secure_modules()) + return -EPERM; + /* Make sure we have a legal set of flags */ if (flags != (flags & KEXEC_FILE_FLAGS)) return -EINVAL;