Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4526395imb; Wed, 6 Mar 2019 16:00:24 -0800 (PST) X-Google-Smtp-Source: APXvYqxfnmsiFKma6+1D4aYhghofeL6t5X6VR5ewaXofNbOr52iUWOdV0lWdGRtNRZZGtgBhXez1 X-Received: by 2002:a63:6a88:: with SMTP id f130mr8654193pgc.114.1551916823928; Wed, 06 Mar 2019 16:00:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551916823; cv=none; d=google.com; s=arc-20160816; b=dHPWivf7MNWNoNpqg8vE4ZsRyjWkczY5/0CAXR207adXvudqM5c9DB5hPbidHGjXIm vAk+/lIgXVS5VkLb7Ecu0IS+I9v358E04wKun78L7Yhsq7OPTNTkO3cIZc/CjxRIOHrg c8g5dxwJ0rwKsVTWyM5TPPKPiPOttNFS6iNhzVi5ctgmbHmpW/7xYZvnouzHUfRw9ip4 lRP0tt0KgqwFYOq590RpiMjyCVVgVwnIu5fPRjQC88EouK9HwFzH8WScRG/9kPCgzyRH A5EIpsKrVxuj6DcdewyQCRrWACor660HzWE7S9c8N97MpdchO8EGULryot+w9SbgZevj pI/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=KKKYFBHbBMb9DlNvNVTDrUs10yWe2S8P/IItgj6dN2A=; b=qpJg375IMmifjFV4GJVzQWzJIV1C8f0g5JepCYlu0DFIxUqklajC+20jhD7wLltBAJ wswS6hfJUwlGYpImIiCbmEfNCWxFKBmZr/Q1oaXn9hqWdJYTBkS6zo9hE/ZkPeRlfQ5x A0ChdncbxTUW1wauM6yJ4kZn+N3MvbfboEMS9lb3I2CJYK+IlGbAotIaR8E9gGDO3Nqb ck3VeFZMYApmIhC8BBl24hdCYg+2zvrdZ/7x8Bvm47Wg0ePQZHwmtTwQknB0wYKVAiGx mCRrKTvQjiBJ2e16E6WhqPwPGkD5svWAJ8nqLLeUrtZJeHlLCX6ISm/eFVAIFXJGCfGU 7/0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uKlleygv; 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 f1si2816807pff.246.2019.03.06.16.00.08; Wed, 06 Mar 2019 16:00:23 -0800 (PST) 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=uKlleygv; 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 S1726367AbfCFX7i (ORCPT + 99 others); Wed, 6 Mar 2019 18:59:38 -0500 Received: from mail-vk1-f202.google.com ([209.85.221.202]:49127 "EHLO mail-vk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726352AbfCFX7g (ORCPT ); Wed, 6 Mar 2019 18:59:36 -0500 Received: by mail-vk1-f202.google.com with SMTP id j1so7389151vkj.15 for ; Wed, 06 Mar 2019 15:59:35 -0800 (PST) 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=KKKYFBHbBMb9DlNvNVTDrUs10yWe2S8P/IItgj6dN2A=; b=uKlleygvjUMu0CZK8wWnXDD7l1l67NNJNeOSKFJK+V2wTAcUjiyenGRE5P2wrxne9Q 02bgm5U3OFFXfiJkN4XhPpSZ2KHfwRe1bHljwcmMSOCdBOTS+Fyzi1QjvcS7aOSeFeNt apxcV8clriCVsbuz5ETKf8LBktpAwVGPsVMSqxm2HY+oPFHStshNNS613RV/o2jPnu9z c8XxFhxGCuZvOEewoCz8/vUIYzwqutWSk0UTbjcUkAGNSOQRdF+I1+Pbf5zz+rq93PUw fFefZg3+vEBOuNlXvEazOUuWVraHPbtFiOQNjEKh3i5qnICTeGZGbY/QSN5V7/1oIHO+ nYFQ== 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=KKKYFBHbBMb9DlNvNVTDrUs10yWe2S8P/IItgj6dN2A=; b=Q2lmfpcWQV7O3t00QFOafN8zV/xAQ9Zr4nKMYq6BPvorkzU2Y50cveNr7ZFrUGSrGh lGKXnM7p9yJH+jaQSdjQGTqe79kbXreSqOIuLvBc2eB18Z6yKm2+WAHlrZuOJFKunaNW yRl8ZNUS4MoYum0jwFTP2RV5DzrsWh7vV9SWUa3VAIfF6ocfiN+asi+wn7WWWftIS1QR zchZyvr/Sp7biBKpgWsd2Ps7qg3QSh0ilhvmMszxvCk+IfALnkKsxJj7Ih9/Ab0hDWEB dRgEqCjokQbUDsyLNjH/nsMBFewggTAu4d+xsr4dlyPeVWSXDZTSYmsQkjNG/sJtVzuC 4MZw== X-Gm-Message-State: APjAAAU4aEEYfWwNtYkgcxHUDlgaf4iHkgFfZBlWMqVgqe2cAl5Ri4D2 6A8GNyozQtanfrOlUYDCbWjxsVTuZgYru90+CnMkkg== X-Received: by 2002:ab0:6455:: with SMTP id j21mr6864734uap.11.1551916775048; Wed, 06 Mar 2019 15:59:35 -0800 (PST) Date: Wed, 6 Mar 2019 15:58:51 -0800 In-Reply-To: <20190306235913.6631-1-matthewgarrett@google.com> Message-Id: <20190306235913.6631-6-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190306235913.6631-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.21.0.352.gf09ad66450-goog Subject: [PATCH 05/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 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 Reviewed-by: "Lee, Chun-Yi" Reviewed-by: James Morris 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.352.gf09ad66450-goog