Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3665101img; Mon, 25 Mar 2019 15:15:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxCIuiEZ6p1lK1ZT+PeWD83qp6i7vD/XXpkXG+xlrWFRDoDB6/NR8EO8xs8of0TqpGzMJ0o X-Received: by 2002:a62:4115:: with SMTP id o21mr25257813pfa.153.1553552112831; Mon, 25 Mar 2019 15:15:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553552112; cv=none; d=google.com; s=arc-20160816; b=drHbiCpajIDnKTaPeyg67IGjM+uHpJj3ctpDbtnYIefqMQXgnPIS6owQImMNXUSIzM m0N4csV7HZUrBp4oTBN315Us0hEHZY6ntKObcX4IvnXhBVdKRDuMUqU9/tm3VY/qPJMb MJ3r3aIjaJW0yahNI+V/L6jB/xe9y5KwaD2hC18Vrw3r1hTZkYywVtUqRdlEnidDnZ0r QOWqT3xnhmvCUBoxmQrWcO9QzUFBMYdz796yk0yVu03/Ll7MeVXeJWySlOMZ5zAmrJ70 IeuSyiY+eccOZC9hjlTp8OL1waPBnGJVI5TnvgNSVKHs959M20kMsRrXmfEHleNYtEuA U0+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=fDig7kZw4F64jZ3glkaJ4FkOKfyo+66KlbXAoLiDIK8=; b=C/0Avjyrs90qM07HoVfr7WPAOcK4jqGwp0IbznK7Ygo85gWYO7HGfDttEAWy4yea/B eA3BC6mW77gyplleUDR1SsKGak9eS4qBhEPJ1fb5oZAAZtaxiAHGiW3/UREIaDhFE+XS b1SS33mopxFIix1ESaNCk+1fdTIqsNHmNoJzRN1mFUAG1wYf6+cr0uxAtbg+D12bR25T nnBfq2K50O5LkGDgfKc0VE8yYVk/B53SJwKBsBKRw8ziOrTYUvPfsBFjZdtiwDY6zOIv SdusCQ+gaZvcggnU7DPpNu5VU4+pPWfNCFBM/XF7GkCfh7sP5l0gVLieZX90q9vxe/f0 5sNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=dURQ4cQZ; 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 b8si14806818plr.54.2019.03.25.15.14.57; Mon, 25 Mar 2019 15:15:12 -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=dURQ4cQZ; 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 S1730709AbfCYWKM (ORCPT + 99 others); Mon, 25 Mar 2019 18:10:12 -0400 Received: from mail-qt1-f202.google.com ([209.85.160.202]:43927 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730599AbfCYWKJ (ORCPT ); Mon, 25 Mar 2019 18:10:09 -0400 Received: by mail-qt1-f202.google.com with SMTP id q21so11719584qtf.10 for ; Mon, 25 Mar 2019 15:10:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=fDig7kZw4F64jZ3glkaJ4FkOKfyo+66KlbXAoLiDIK8=; b=dURQ4cQZveYMOaE8wiQxqpQBPWN0bOzFc/OMjfuVpV/SpRxVkciThZh/XQp7aJUIoY Hpjqu1ojnBarr+Vb7V4twmoEaE7jZMFYiLZ/ruIcSSjRQCqleuF93UWWx27BMhJA+9MD GySbwDLTsb3iBPgkvE33DDYr0Qieqhpl+/c4AvqimN8UbCQbMGRoZr4Wx8wECE/sdcAS nyXqXomtgd+aaUVqkQ8WMRYNYXSU1Vh5CyrjW2uWtZEsUGxoJsZ20Z4rUrECYdswgZ1Q +iYF25aCFRUm8cNep9ZTuSi2XDOzYU0ae47vBLiSJEvCoYGBZ9CNJ8PLYsPrYNXQnTVn /A2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=fDig7kZw4F64jZ3glkaJ4FkOKfyo+66KlbXAoLiDIK8=; b=Eprky/5EOyZYB61epWovJm74dxehmgQpYOB6VJ6jfNCWLWOHFFDxfXugUhNdNWGfqL BeH/O92CaMfyzG5UiwBha1F+8SBZEq2WBAi4b7rUQGtXFvkV7sFs3qmBOBbQT+zr8aJA bRnM9Cwybk+D1GbE3Qir13b5OeHUkyTCtE18OB1DD7i+mclEk3P8Jaygpy789Vh/iJbp kKnhvECNnMbT1qJXOCJWrQgwO0YbZvcU6Hpzb1SIUeq4Be13Qfdpe1OcCCTkxPUYYzeC b9wBhh3tMY38tMX8KnpIFRaPbRRj1+LOxbpOIR2yUiWb+yWhg6ksIVWvPGiGbuVfShVA AcpA== X-Gm-Message-State: APjAAAVGE8iwP1+Gdrx7GpuIy7legxretR23WCyr/RTrKuNXz98MEQHC 5n93tOEShjn6CFhmMDugzTVa/bHa8vHYOJ/DgtCrEQ== X-Received: by 2002:ac8:3092:: with SMTP id v18mr23438957qta.41.1553551808486; Mon, 25 Mar 2019 15:10:08 -0700 (PDT) Date: Mon, 25 Mar 2019 15:09:31 -0700 In-Reply-To: <20190325220954.29054-1-matthewgarrett@google.com> Message-Id: <20190325220954.29054-5-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190325220954.29054-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog Subject: [PATCH 04/27] kexec_load: Disable at runtime if the kernel is locked down From: Matthew Garrett To: jmorris@namei.org Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, dhowells@redhat.com, Matthew Garrett , Dave Young , kexec@lists.infradead.org, Matthew Garrett 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 From: Matthew Garrett The kexec_load() syscall permits the loading and execution of arbitrary code in ring 0, which is something that lock-down is meant to prevent. It makes sense to disable kexec_load() in this situation. This does not affect kexec_file_load() syscall which can check for a signature on the image to be booted. Signed-off-by: Matthew Garrett Signed-off-by: David Howells Acked-by: Dave Young cc: kexec@lists.infradead.org Signed-off-by: Matthew Garrett --- kernel/kexec.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/kexec.c b/kernel/kexec.c index 68559808fdfa..8ea0ce31271f 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -207,6 +207,13 @@ static inline int kexec_load_check(unsigned long nr_segments, if (result < 0) return result; + /* + * kexec can be used to circumvent module loading restrictions, so + * prevent loading in that case + */ + if (kernel_is_locked_down("kexec of unsigned images")) + return -EPERM; + /* * Verify we have a legal set of flags * This leaves us room for future extensions. -- 2.21.0.392.gf8f6787159e-goog