From patchwork Fri Oct 20 19:19:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bruno E. O. Meneguele" X-Patchwork-Id: 10020877 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DE5DC603B5 for ; Fri, 20 Oct 2017 19:20:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D153128F0E for ; Fri, 20 Oct 2017 19:20:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C59C628F47; Fri, 20 Oct 2017 19:20:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8585E28F42 for ; Fri, 20 Oct 2017 19:20:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752794AbdJTTUK (ORCPT ); Fri, 20 Oct 2017 15:20:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34074 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752788AbdJTTTY (ORCPT ); Fri, 20 Oct 2017 15:19:24 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 64C3BC13DA26; Fri, 20 Oct 2017 19:19:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 64C3BC13DA26 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=brdeoliv@redhat.com Received: from glitch.redhat.com (ovpn-116-21.gru2.redhat.com [10.97.116.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41C9C60E37; Fri, 20 Oct 2017 19:19:22 +0000 (UTC) From: "Bruno E. O. Meneguele" To: linux-kernel@vger.kernel.org Cc: linux-security-module@vger.kernel.org, linux-integrity@vger.kernel.org, serge@hallyn.com, james.l.morris@oracle.com, dmitry.kasatkin@gmail.com, zohar@linux.vnet.ibm.com, rusty@rustcorp.com.au, jeyu@kernel.org Subject: [PATCH 1/2] module: export module signature enforcement status Date: Fri, 20 Oct 2017 17:19:15 -0200 Message-Id: <5aea5786954da170e171fc9ddd1f591c0e36afc7.1508524595.git.brdeoliv@redhat.com> In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 20 Oct 2017 19:19:24 +0000 (UTC) Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A static variable sig_enforce is used as status var to indicate the real value of CONFIG_MODULE_SIG_FORCE, once this one is set the var will hold true, but if the CONFIG is not set the status var will hold whatever value is present in the module.sig_enforce kernel cmdline param: true when =1 and false when =0 or not present. Considering this cmdline param take place over the CONFIG value when it's not set, other places in the kernel could missbehave since they would have only the CONFIG_MODULE_SIG_FORCE value to rely on. Exporting this status var allows the kernel to rely in the effective value of module signature enforcement, being it from CONFIG value or cmdline param. Signed-off-by: Bruno E. O. Meneguele --- include/linux/module.h | 2 ++ kernel/module.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/include/linux/module.h b/include/linux/module.h index fe5aa3736707..ddfe17e3a85c 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -806,4 +806,6 @@ static inline bool module_sig_ok(struct module *module) } #endif /* CONFIG_MODULE_SIG */ +bool is_module_sig_enforced(void); + #endif /* _LINUX_MODULE_H */ diff --git a/kernel/module.c b/kernel/module.c index de66ec825992..b93c7ff44066 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -278,6 +278,14 @@ static bool sig_enforce = IS_ENABLED(CONFIG_MODULE_SIG_FORCE); module_param(sig_enforce, bool_enable_only, 0644); #endif /* !CONFIG_MODULE_SIG_FORCE */ +/* Export sig_enforce kernel cmdline parameter to allow other subsystems rely + * on that instead of directly to CONFIG_MODULE_SIG_FORCE config. */ +bool is_module_sig_enforced(void) +{ + return sig_enforce; +} +EXPORT_SYMBOL(is_module_sig_enforced); + /* Block module loading/unloading? */ int modules_disabled = 0; core_param(nomodule, modules_disabled, bint, 0);