Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4546771img; Tue, 26 Mar 2019 11:32:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqyg2hQSIWqdv0GPNzJgg/uVuLDZE7Iy2/qhs5OhLuN5KQuohFOSWM296DhGSYlyWiupYjlM X-Received: by 2002:a62:5543:: with SMTP id j64mr31041360pfb.105.1553625147814; Tue, 26 Mar 2019 11:32:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553625147; cv=none; d=google.com; s=arc-20160816; b=b+e2kvqlM11Xto14qI6FCHXwf5zXk+fIFRTvOuu/RAwwevSJIlGxFLinVtL+KYJHtz +IGBLY3GIYzpAGLYY5xOi7HH1xr6ApN/EKYgqaEp2Q8qndllJKHiDjDGEls7FiU+jcg2 4VT8+k8LlMV/1MQVW9vrrCx79I6SZegiFR3icF3t6qw227DD5QTpUWDFjlB1Ygp3awwg UHRB5l3MtZa+vKDrCnbWJeWHTRbzujmcS663GXioDY07Fhup9UtNtvd9+A2nijs3Wb6A EE0fL1I0wFjY2yNHcN3H2FwcwRHjmByVQ5beM+jkZn+nQ0eqtAlRBzjBL18g6/0p1quO kc8g== 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=LW7lq5jkExR1NuLSqDh6tdSVxounhx+I412qfIcDAFY=; b=hOtdVzpcFSoZKP3udzrMxSB4zfJ3qwpikoeYIcqCmFZU50q+03u1mGBSRsZmbpLjsq 4sKorjtFWWeCiYhtl+98zDSWZhKZMcL+VsmPDJOeQozNxTBmCGzLW82eba32vHTYqtzJ 2Pt34jXFMlrOy4Bmqr43J7Adjtn2X1YtIdMDRr40stN1u6XILNZW6aX1g8GUHjVILSUw 7W5fNv37Jkamop/T8Be4yO47GGnT9OXSbv8mYehgDSlnN+vmIhtdFzbt+14xpgzbx6Uj OPpHm9K7GYfK6NQ4eQk9UVGrtAgooW9Q5KhWot5vh4lcZ+H1qkuBqPoR66PeLNCAHXYf 1xqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="q/9vwQqe"; 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 o8si17250663pfh.136.2019.03.26.11.32.12; Tue, 26 Mar 2019 11:32:27 -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="q/9vwQqe"; 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 S1732820AbfCZSa0 (ORCPT + 99 others); Tue, 26 Mar 2019 14:30:26 -0400 Received: from mail-vk1-f201.google.com ([209.85.221.201]:48224 "EHLO mail-vk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732566AbfCZS2G (ORCPT ); Tue, 26 Mar 2019 14:28:06 -0400 Received: by mail-vk1-f201.google.com with SMTP id l85so5677685vke.15 for ; Tue, 26 Mar 2019 11:28:06 -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=LW7lq5jkExR1NuLSqDh6tdSVxounhx+I412qfIcDAFY=; b=q/9vwQqeELW8VlIFBstln+nSZdV89CEKrwLeAoPYLE0WmwDflbjM9zmZfkKzmVHUCm BRnYfeAzcXfVP3XdbekpJi4zOfVDDYynZcWlYJti/6+3PxXoHiybysEqPwNAyOwkVt5z 6L1AOH9G3bHZuwcCpB3xab+jt0vlMwC1dvuwiaHH84kZPIiYvnVXeABd6keKeimDoNiQ UxsPfKdmLHQpyQPhNC7Sa2RQjxS3K2H2JEzrv6rj/nis1F03CbK2WTnLlqiaDqM6GC0e cx56GL8Ws9KW2dbhz2y9dpGYjqfK4CjEmLkgl8xLX7USn7CY0pmxMYV1pgX6tmm3D3dT gMFw== 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=LW7lq5jkExR1NuLSqDh6tdSVxounhx+I412qfIcDAFY=; b=nevRsM4oYS1mtX3KFZVMickEL5wENy9BR9a3Htp8kfA3OBtczWuZ+GjC0Pjl7iREUn 8Uy8DD1/TuCdmUEqaQ8Kv+ZgCKXEGWf7oiXx9F0arF4v0AIHuBtqnUoFxl5QWgC5SP5T kbd8iErDPA04CcJyMWwCEe5zBZwQwbSRk34c8rnTGhgqmkw5+44421hG0So4lwAJwean g2u/OUhFpCpmudtcJYITJVZAtoLDiYvtYbIzyiUYJfAtKqul2JNKuik36rZAsv+zFF1z w80E8Gco81xUxfJ3w2PS9utLXwHtMpV0cIw0vEEwn2WIE/GD7djevCmQ7e2ZgRY2VRbd Z1vA== X-Gm-Message-State: APjAAAWOKX3RPvRyqLif+OG4BhHBn03AJdSKSlFvjn8QZ41CHN8r1Mip PjJtgXb4gO+m1/9cbNmdBUm17BU7JEdcX0Mpo+K3Qw== X-Received: by 2002:a1f:a18e:: with SMTP id k136mr7884472vke.88.1553624885547; Tue, 26 Mar 2019 11:28:05 -0700 (PDT) Date: Tue, 26 Mar 2019 11:27:20 -0700 In-Reply-To: <20190326182742.16950-1-matthewgarrett@google.com> Message-Id: <20190326182742.16950-5-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190326182742.16950-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog Subject: [PATCH V31 04/25] 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, linux-api@vger.kernel.org, luto@kernel.org, Matthew Garrett , Matthew Garrett , Dave Young , kexec@lists.infradead.org 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: David Howells Signed-off-by: Matthew Garrett Acked-by: Dave Young cc: kexec@lists.infradead.org --- kernel/kexec.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/kexec.c b/kernel/kexec.c index 68559808fdfa..57047acc9a36 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -207,6 +207,14 @@ 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", + LOCKDOWN_INTEGRITY)) + return -EPERM; + /* * Verify we have a legal set of flags * This leaves us room for future extensions. -- 2.21.0.392.gf8f6787159e-goog