Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758345AbcLANOm (ORCPT ); Thu, 1 Dec 2016 08:14:42 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33390 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751423AbcLANOj (ORCPT ); Thu, 1 Dec 2016 08:14:39 -0500 Reply-To: minyard@acm.org Subject: Re: [PATCH 03/39] Annotate hardware config module parameters in drivers/char/ipmi/ References: <148059537897.31612.9461043954611464597.stgit@warthog.procyon.org.uk> <148059540295.31612.4139752007431784342.stgit@warthog.procyon.org.uk> To: David Howells , linux-kernel@vger.kernel.org Cc: gnomes@lxorguk.ukuu.org.uk, linux-security-module@vger.kernel.org, keyrings@vger.kernel.org, openipmi-developer@lists.sourceforge.net From: Corey Minyard Message-ID: <95ae3781-2c2c-fb2a-7e1b-3732acaa603e@acm.org> Date: Thu, 1 Dec 2016 07:14:35 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <148059540295.31612.4139752007431784342.stgit@warthog.procyon.org.uk> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4549 Lines: 85 On 12/01/2016 06:30 AM, David Howells wrote: > When the kernel is running in secure boot mode, we lock down the kernel to > prevent userspace from modifying the running kernel image. Whilst this > includes prohibiting access to things like /dev/mem, it must also prevent > access by means of configuring driver modules in such a way as to cause a > device to access or modify the kernel image. > > To this end, annotate module_param* statements that refer to hardware > configuration and indicate for future reference what type of parameter they > specify. The parameter parser in the core sees this information and can > skip such parameters with an error message if the kernel is locked down. > The module initialisation then runs as normal, but just sees whatever the > default values for those parameters is. > > Note that we do still need to do the module initialisation because some > drivers have viable defaults set in case parameters aren't specified and > some drivers support automatic configuration (e.g. PNP or PCI) in addition > to manually coded parameters. > > This patch annotates drivers in drivers/char/ipmi/. > > Suggested-by: One Thousand Gnomes > Signed-off-by: David Howells > cc: Corey Minyard > cc: openipmi-developer@lists.sourceforge.net Reviewed by: Corey Minyard > --- > > drivers/char/ipmi/ipmi_si_intf.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c > index a112c0146012..157e96391eca 100644 > --- a/drivers/char/ipmi/ipmi_si_intf.c > +++ b/drivers/char/ipmi/ipmi_si_intf.c > @@ -1375,39 +1375,39 @@ MODULE_PARM_DESC(type, "Defines the type of each interface, each" > " interface separated by commas. The types are 'kcs'," > " 'smic', and 'bt'. For example si_type=kcs,bt will set" > " the first interface to kcs and the second to bt"); > -module_param_array(addrs, ulong, &num_addrs, 0); > +module_param_hw_array(addrs, ulong, iomem, &num_addrs, 0); > MODULE_PARM_DESC(addrs, "Sets the memory address of each interface, the" > " addresses separated by commas. Only use if an interface" > " is in memory. Otherwise, set it to zero or leave" > " it blank."); > -module_param_array(ports, uint, &num_ports, 0); > +module_param_hw_array(ports, uint, ioport, &num_ports, 0); > MODULE_PARM_DESC(ports, "Sets the port address of each interface, the" > " addresses separated by commas. Only use if an interface" > " is a port. Otherwise, set it to zero or leave" > " it blank."); > -module_param_array(irqs, int, &num_irqs, 0); > +module_param_hw_array(irqs, int, irq, &num_irqs, 0); > MODULE_PARM_DESC(irqs, "Sets the interrupt of each interface, the" > " addresses separated by commas. Only use if an interface" > " has an interrupt. Otherwise, set it to zero or leave" > " it blank."); > -module_param_array(regspacings, int, &num_regspacings, 0); > +module_param_hw_array(regspacings, int, other, &num_regspacings, 0); > MODULE_PARM_DESC(regspacings, "The number of bytes between the start address" > " and each successive register used by the interface. For" > " instance, if the start address is 0xca2 and the spacing" > " is 2, then the second address is at 0xca4. Defaults" > " to 1."); > -module_param_array(regsizes, int, &num_regsizes, 0); > +module_param_hw_array(regsizes, int, other, &num_regsizes, 0); > MODULE_PARM_DESC(regsizes, "The size of the specific IPMI register in bytes." > " This should generally be 1, 2, 4, or 8 for an 8-bit," > " 16-bit, 32-bit, or 64-bit register. Use this if you" > " the 8-bit IPMI register has to be read from a larger" > " register."); > -module_param_array(regshifts, int, &num_regshifts, 0); > +module_param_hw_array(regshifts, int, other, &num_regshifts, 0); > MODULE_PARM_DESC(regshifts, "The amount to shift the data read from the." > " IPMI register, in bits. For instance, if the data" > " is read from a 32-bit word and the IPMI data is in" > " bit 8-15, then the shift would be 8"); > -module_param_array(slave_addrs, int, &num_slave_addrs, 0); > +module_param_hw_array(slave_addrs, int, other, &num_slave_addrs, 0); > MODULE_PARM_DESC(slave_addrs, "Set the default IPMB slave address for" > " the controller. Normally this is 0x20, but can be" > " overridden by this parm. This is an array indexed" >