From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754762AbdKJWjd (ORCPT ); Fri, 10 Nov 2017 17:39:33 -0500 Received: from mx2.suse.de ([195.135.220.15]:38163 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754000AbdKJWjc (ORCPT ); Fri, 10 Nov 2017 17:39:32 -0500 Date: Fri, 10 Nov 2017 23:39:30 +0100 From: "Luis R. Rodriguez" To: Mimi Zohar Cc: David Howells , linux-security-module , linux-fsdevel , linux-kernel , "AKASHI, Takahiro" , Johannes Berg , James Bottomley , David Woodhouse Subject: Re: [RFC PATCH v1] fw_lockdown: new micro LSM module to prevent loading unsigned firmware Message-ID: <20171110223930.GT22894@wotan.suse.de> References: <1510347775.3549.2.camel@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1510347775.3549.2.camel@linux.vnet.ibm.com> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 10, 2017 at 04:02:55PM -0500, Mimi Zohar wrote: > If the kernel is locked down and IMA-appraisal is not enabled, prevent > loading of unsigned firmware. > > Signed-off-by: Mimi Zohar > --- > > Changelog v1: > - Lots of minor changes Kconfig, Makefile, fw_lsm.c for such a small patch <-- snip --> > diff --git a/security/fw_lockdown/fw_lsm.c b/security/fw_lockdown/fw_lsm.c > new file mode 100644 > index 000000000000..cce03a5c5280 > --- /dev/null > +++ b/security/fw_lockdown/fw_lsm.c > @@ -0,0 +1,51 @@ > +/* > + * fw_lockdown security module > + * > + * Copyright (C) 2017 IBM Corporation > + * > + * Authors: > + * Mimi Zohar > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License as published by > + * the Free Software Foundation; either version 2 of the License, or > + * (at your option) any later version. > + */ > + > +#define pr_fmt(fmt) "fw_lockdown: " fmt > + > +#include > +#include > +#include > + > +/** > + * fw_lockdown_read_file - prevent loading of unsigned firmware > + * @file: pointer to firmware > + * @read_id: caller identifier > + * > + * Prevent loading of unsigned firmware in lockdown mode. > + */ > +static int fw_lockdown_read_file(struct file *file, enum kernel_read_file_id id) > +{ > + if (id == READING_FIRMWARE) { > + if (!is_ima_appraise_enabled() && > + !kernel_is_locked_down("Loading of unsigned firmware")) > + return -EACCES; I don't have kernel_is_locked_down() but I found it here: https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/commit/?h=keys-lockdown&id=0ff5adf1e81135c4ed914d0a8b70124caed04142 1) I don't see it taking any arguments 2) Don't we want: if (!is_ima_appraise_enabled() && kernel_is_locked_down()) return -EACCES; If, only if IMA appraisal is enabled would we enable kernel lockdown. Luis