From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932245AbdJWM5J (ORCPT ); Mon, 23 Oct 2017 08:57:09 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:39988 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932215AbdJWM5H (ORCPT ); Mon, 23 Oct 2017 08:57:07 -0400 Subject: Re: [PATCH 1/2] module: export module signature enforcement status From: Mimi Zohar To: "Bruno E. O. Meneguele" , 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, rusty@rustcorp.com.au, jeyu@kernel.org Date: Mon, 23 Oct 2017 08:56:55 -0400 In-Reply-To: <5aea5786954da170e171fc9ddd1f591c0e36afc7.1508524595.git.brdeoliv@redhat.com> References: <5aea5786954da170e171fc9ddd1f591c0e36afc7.1508524595.git.brdeoliv@redhat.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-MML: disable x-cbid: 17102312-0016-0000-0000-000004F8EA44 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17102312-0017-0000-0000-000028345796 Message-Id: <1508763415.3639.91.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-10-23_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710230185 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2017-10-20 at 17:19 -0200, Bruno E. O. Meneguele wrote: > 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 ^misbehave > 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. Thanks! There's a minor checkpatch warning below. > 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. */ Checkpatch complains.  Please use the normal format: /*  *  */ > +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);