From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758418AbcCaVYZ (ORCPT ); Thu, 31 Mar 2016 17:24:25 -0400 Received: from e28smtp03.in.ibm.com ([125.16.236.3]:50186 "EHLO e28smtp03.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757390AbcCaVYU (ORCPT ); Thu, 31 Mar 2016 17:24:20 -0400 X-IBM-Helo: d28relay01.in.ibm.com X-IBM-MailFrom: zohar@linux.vnet.ibm.com X-IBM-RcptTo: linux-kernel@vger.kernel.org;linux-security-module@vger.kernel.org Message-ID: <1459459442.2657.51.camel@linux.vnet.ibm.com> Subject: Re: [PATCH v2 5/5] LSM: LoadPin for kernel file loading restrictions From: Mimi Zohar To: Kees Cook Cc: James Morris , "Serge E. Hallyn" , Andrew Morton , Kalle Valo , Mauro Carvalho Chehab , Joe Perches , Guenter Roeck , Jiri Slaby , Paul Moore , Stephen Smalley , Casey Schaufler , Andreas Gruenbacher , Andy Shevchenko , Rasmus Villemoes , Ulf Hansson , Vitaly Kuznetsov , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 31 Mar 2016 17:24:02 -0400 In-Reply-To: <1459199662-16558-6-git-send-email-keescook@chromium.org> References: <1459199662-16558-1-git-send-email-keescook@chromium.org> <1459199662-16558-6-git-send-email-keescook@chromium.org> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.12.11 (3.12.11-1.fc21) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable x-cbid: 16033121-0009-0000-0000-00000BB73BDF Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2016-03-28 at 14:14 -0700, Kees Cook wrote: > +static const char *id_str[READING_MAX_ID] = { > + [READING_FIRMWARE] = "firmware", > + [READING_MODULE] = "kernel module", > + [READING_KEXEC_IMAGE] = "kexec image", > + [READING_KEXEC_INITRAMFS] = "kexec initramfs", > + [READING_POLICY] = "security policy", > +}; > + > +static int loadpin_read_file(struct file *file, enum kernel_read_file_id id) > +{ > + struct super_block *load_root; > + const char *origin; > + > + if (id < 0 || id >= READING_MAX_ID) > + return -EINVAL; > + The kernel_read_file_id enumeration starts at 1. > + origin = id_str[id]; > + if (!origin) { > + origin = "unknown"; Right, all the entries in the kernel_read_file_id enumeration are currently listed in id_str. Checking origin is needed for when id_str[] isn't kept in sync with the enumeration. Looks good! Mimi