From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932316AbdJYSIw (ORCPT ); Wed, 25 Oct 2017 14:08:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44216 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932240AbdJYSIu (ORCPT ); Wed, 25 Oct 2017 14:08:50 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9D179CD244 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=brdeoliv@redhat.com Date: Wed, 25 Oct 2017 16:08:48 -0200 From: "Bruno E. O. Meneguele" To: Mimi Zohar Cc: linux-kernel@vger.kernel.org, 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 Subject: Re: [PATCH v3 2/2] ima: check signature enforcement against cmdline param instead of CONFIG Message-ID: <20171025180848.GD26762@glitch> References: <1508885697.3164.5.camel@linux.vnet.ibm.com> <20171025150544.GC26762@glitch> <1508951897.7367.16.camel@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gDGSpKKIBgtShtf+" Content-Disposition: inline In-Reply-To: <1508951897.7367.16.camel@linux.vnet.ibm.com> X-PGP-Key: http://keys.gnupg.net/pks/lookup?op=get&search=0x3823031E4660608D User-Agent: Mutt/1.9.1 (2017-09-22) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 25 Oct 2017 18:08:50 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --gDGSpKKIBgtShtf+ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 25-10, Mimi Zohar wrote: > On Wed, 2017-10-25 at 13:05 -0200, Bruno E. O. Meneguele wrote: > > On 24-10, Mimi Zohar wrote: > > > On Tue, 2017-10-24 at 15:37 -0200, Bruno E. O. Meneguele wrote: > > > > When the user requests MODULE_CHECK policy and its kernel is compil= ed > > > > with CONFIG_MODULE_SIG_FORCE not set, all modules would not load, j= ust > > > > those loaded in initram time. One option the user would have would = be > > > > set a kernel cmdline param (module.sig_enforce) to true, but the IMA > > > > module check code doesn't rely on this value, it checks just > > > > CONFIG_MODULE_SIG_FORCE. > > > >=20 > > > > This patch solves this problem checking for the exported value of > > > > module.sig_enforce cmdline param intead of CONFIG_MODULE_SIG_FORCE, > > > > which holds the effective value (CONFIG || param). > > > >=20 > > > > Signed-off-by: Bruno E. O. Meneguele > > > > --- > > > > security/integrity/ima/ima_main.c | 6 +++--- > > > > 1 file changed, 3 insertions(+), 3 deletions(-) > > > >=20 > > > > diff --git a/security/integrity/ima/ima_main.c b/security/integrity= /ima/ima_main.c > > > > index e4ab8ef8016e..d11a7fcc5c8b 100644 > > > > --- a/security/integrity/ima/ima_main.c > > > > +++ b/security/integrity/ima/ima_main.c > > > > @@ -356,12 +356,12 @@ void ima_post_path_mknod(struct dentry *dentr= y) > > > > */ > > > > int ima_read_file(struct file *file, enum kernel_read_file_id read= _id) > > > > { > > > > + bool sig_enforce =3D is_module_sig_enforced(); > > > > + > > > > if (!file && read_id =3D=3D READING_MODULE) { > > >=20 > > > The only reason for getting here is that you're using the old module > > > load syscall. =A0Is there a reason for not using the new one, which > > > passes the file descriptor? >=20 > > Basicaly because the way kmod handles compressed (gz/xz) modules. The > > way it's today would require major changes in the code or some kind of > > memfd_create() + xattrs reassignement in order to finit_module() be used > > correctly. > >=20 > > Considering it would take some time to be accepted or even to figure out > > the correct way to tackle it, the current IMA module check code works > > aside kernel module signature validation, which is fine for now for me, > > but has the problem that this patch tries to solve in the > > CONFIG_MODULE_SIG_FORCE check (ignoring module.sig_enforce cmdline > > param). >=20 > Thank you for the reasoning. =A0BTW, these patches are now queued. >=20 >=20 You're welcome. Thank you for the feedback. > > > > -#ifndef CONFIG_MODULE_SIG_FORCE > > > > - if ((ima_appraise & IMA_APPRAISE_MODULES) && > > > > + if (!sig_enforce && (ima_appraise & IMA_APPRAISE_MODULES) && > > > > (ima_appraise & IMA_APPRAISE_ENFORCE)) > > > > return -EACCES; /* INTEGRITY_UNKNOWN */ > > > > -#endif > > > > return 0; /* We rely on module signature checking */ > > > > } > > > > return 0; > > >=20 > > >=20 > >=20 >=20 --=20 bmeneg=20 PGP Key: http://bmeneg.com/pubkey.txt --gDGSpKKIBgtShtf+ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEdWo6nTbnZdbDmXutYdRkFR+RokMFAlnw0ywACgkQYdRkFR+R okMAFAf+KSnQJMoPn+tnj6tJHvgSir6J5DLGklKbAMRYqtQsdIkpvI6c/1cTJ3UQ +U6fvGS7yGDqijztoXl5K10Rk5L60Jvyam4IMP698s4mZf4PiZVCnHaWaBRhr2Jq 19qkt3Jo7Q83Q1LaDyx9jUlm7UqGygQrFWVAdz04kN4q5s5Vlf4RD5N6I6ZyZ01Z EBtlbTgipP1P/1KzxvBjvcDON6G2f7M1+vRllkiPVjmy+nNJIZ5HjudV25YXj/g4 2HOVzhqN0psT6sfEgLRWtVF5iHK6yYrRTkMLtx/33f8f3Eu+OY4i0hwZxhPn3zkz Rxl/74QhL5lUfhUzmM7ocGr+UYC4+A== =CeWq -----END PGP SIGNATURE----- --gDGSpKKIBgtShtf+--