From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758883AbdKOT5U (ORCPT ); Wed, 15 Nov 2017 14:57:20 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:53870 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757310AbdKOT5K (ORCPT ); Wed, 15 Nov 2017 14:57:10 -0500 Subject: Re: Firmware signing -- Re: [PATCH 00/27] security, efi: Add kernel lockdown From: Mimi Zohar To: "Luis R. Rodriguez" Cc: Linus Torvalds , Johannes Berg , Matthew Garrett , David Howells , Alan Cox , "AKASHI, Takahiro" , Greg Kroah-Hartman , Jan Blunck , Julia Lawall , Marcus Meissner , Gary Lin , LSM List , linux-efi , Linux Kernel Mailing List Date: Wed, 15 Nov 2017 14:56:57 -0500 In-Reply-To: <20171115175246.GN729@wotan.suse.de> References: <20171113174250.GA22894@wotan.suse.de> <20171113210848.4dc344bd@alans-desktop> <454.1510609487@warthog.procyon.org.uk> <1510662098.3711.139.camel@linux.vnet.ibm.com> <20171114205014.GJ729@wotan.suse.de> <1510746597.3711.268.camel@linux.vnet.ibm.com> <20171115175246.GN729@wotan.suse.de> 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-GCONF: 00 x-cbid: 17111519-0040-0000-0000-000003EEC089 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17111519-0041-0000-0000-000025F176F5 Message-Id: <1510775817.3711.315.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-15_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711150260 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2017-11-15 at 18:52 +0100, Luis R. Rodriguez wrote: > On Wed, Nov 15, 2017 at 06:49:57AM -0500, Mimi Zohar wrote: > > On Tue, 2017-11-14 at 21:50 +0100, Luis R. Rodriguez wrote: > > > > > Johannes made cfg80211 recently just use request_firmware() now via commit on > > > linux-next 90a53e4432 ("cfg80211: implement regdb signature checking") [0] as > > > he got tired of waiting firmware signing, but note he implemented a signature > > > checking on its own so he open codes verify_pkcs7_signature() after the > > > request_firmware() call. If we are happy to live with this, then so be it. > > > > > > [0] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=90a53e4432b12288316efaa5f308adafb8d304b0 > > > > Johannes was tired of waiting?  Commit 5a9196d "ima: add support for > > measuring and appraising firmware" has been in the kernel since linux- > > 3.17. > > > > The original firmware hook for verifying firmware signatures were > > replaced with the common LSM pre and post kernel_read_file() hooks > > in linux-4.6.y. > > > > Even if you wanted to support firmware signature verification without > > IMA-appraisal, it should be using the LSM hooks. > > request_firmware() uses kernel_read_file_from_path() underneath the hood, > and so its used for both: > > /lib/firmware/regulatory.db > /lib/firmware/regulatory.db.p7s The firmware signature validation should occur as part of kernel_read_file_from_path(), not as a stand alone verification. Why not extend kernel_read_file_from_path() to pass the detached signature?  Since the signature would only be used for the verification, there's no need to return the open file descriptor. Or if you prefer, call kernel_read_file_from_path() for the detached signature first, and then call it again for the firmware with a pointer to the detached signature. > > The later only if CONFIG_CFG80211_REQUIRE_SIGNED_REGDB, which defaults > to y anyway. > > What I meant was that net/wireless/reg.c now open codes firmware signature > validation on its own rather than using a helper. IMA appraisal will still > be used if enabled given kernel_read_file_from_path() is used. > > The open coding of the firmware signature check is what I wanted to highlight. How are the keys in the CFG80211_EXTRA_REGDB_KEYDIR verified?  The call to key_create_or_update() with the KEY_ALLOC_BYPASS_RESTRICTION option by-passes any requirement that the keys in this directory are signed.  This by-passes the concept of extending the secure boot signature chain of trust.  To safely validate the keys use the restrict_link_by_builtin_trusted option. Mimi From mboxrd@z Thu Jan 1 00:00:00 1970 From: zohar@linux.vnet.ibm.com (Mimi Zohar) Date: Wed, 15 Nov 2017 14:56:57 -0500 Subject: Firmware signing -- Re: [PATCH 00/27] security, efi: Add kernel lockdown In-Reply-To: <20171115175246.GN729@wotan.suse.de> References: <20171113174250.GA22894@wotan.suse.de> <20171113210848.4dc344bd@alans-desktop> <454.1510609487@warthog.procyon.org.uk> <1510662098.3711.139.camel@linux.vnet.ibm.com> <20171114205014.GJ729@wotan.suse.de> <1510746597.3711.268.camel@linux.vnet.ibm.com> <20171115175246.GN729@wotan.suse.de> Message-ID: <1510775817.3711.315.camel@linux.vnet.ibm.com> To: linux-security-module@vger.kernel.org List-Id: linux-security-module.vger.kernel.org On Wed, 2017-11-15 at 18:52 +0100, Luis R. Rodriguez wrote: > On Wed, Nov 15, 2017 at 06:49:57AM -0500, Mimi Zohar wrote: > > On Tue, 2017-11-14 at 21:50 +0100, Luis R. Rodriguez wrote: > > > > > Johannes made cfg80211 recently just use request_firmware() now via commit on > > > linux-next 90a53e4432 ("cfg80211: implement regdb signature checking") [0] as > > > he got tired of waiting firmware signing, but note he implemented a signature > > > checking on its own so he open codes verify_pkcs7_signature() after the > > > request_firmware() call. If we are happy to live with this, then so be it. > > > > > > [0] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=90a53e4432b12288316efaa5f308adafb8d304b0 > > > > Johannes was tired of waiting? ?Commit 5a9196d "ima: add support for > > measuring and appraising firmware" has been in the kernel since linux- > > 3.17. > > > > The original firmware hook for verifying firmware signatures were > > replaced with the common LSM pre and post kernel_read_file() hooks > > in?linux-4.6.y. > > > > Even if you wanted to support firmware signature verification without > > IMA-appraisal, it should be using the LSM hooks. > > request_firmware() uses kernel_read_file_from_path() underneath the hood, > and so its used for both: > > /lib/firmware/regulatory.db > /lib/firmware/regulatory.db.p7s The firmware signature validation should occur as part of kernel_read_file_from_path(), not as a stand alone verification. Why not extend kernel_read_file_from_path() to pass the detached signature? ?Since the signature would only be used for the verification, there's no need to return the open file descriptor. Or if you prefer, call kernel_read_file_from_path() for the detached signature first, and then call it again for the firmware with a pointer to the detached signature. > > The later only if CONFIG_CFG80211_REQUIRE_SIGNED_REGDB, which defaults > to y anyway. > > What I meant was that net/wireless/reg.c now open codes firmware signature > validation on its own rather than using a helper. IMA appraisal will still > be used if enabled given kernel_read_file_from_path() is used. > > The open coding of the firmware signature check is what I wanted to highlight. How are the keys in the CFG80211_EXTRA_REGDB_KEYDIR verified? ?The call to key_create_or_update() with the KEY_ALLOC_BYPASS_RESTRICTION option by-passes any requirement that the keys in this directory are signed. ?This by-passes the concept of extending the secure boot signature chain of trust. ?To safely validate the keys use the restrict_link_by_builtin_trusted option. Mimi -- To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html