From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB974C433E1 for ; Thu, 25 Jun 2020 22:57:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3B84207BB for ; Thu, 25 Jun 2020 22:57:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407615AbgFYW5I (ORCPT ); Thu, 25 Jun 2020 18:57:08 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:54608 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406272AbgFYW5H (ORCPT ); Thu, 25 Jun 2020 18:57:07 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 05PMWx4Z075491; Thu, 25 Jun 2020 18:56:51 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 31vx91cbxw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jun 2020 18:56:51 -0400 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 05PMg9vL113179; Thu, 25 Jun 2020 18:56:51 -0400 Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com with ESMTP id 31vx91cbxe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jun 2020 18:56:50 -0400 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 05PMsuGx018908; Thu, 25 Jun 2020 22:56:48 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma06fra.de.ibm.com with ESMTP id 31uusps3jf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 25 Jun 2020 22:56:48 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 05PMtQeH59376086 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jun 2020 22:55:27 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 06C61AE055; Thu, 25 Jun 2020 22:56:46 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BBF77AE053; Thu, 25 Jun 2020 22:56:44 +0000 (GMT) Received: from localhost.localdomain (unknown [9.85.142.225]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 25 Jun 2020 22:56:44 +0000 (GMT) Message-ID: <1593125804.27152.426.camel@linux.ibm.com> Subject: Re: [PATCH 12/12] ima: Support additional conditionals in the KEXEC_CMDLINE hook function From: Mimi Zohar To: Tyler Hicks , Dmitry Kasatkin Cc: James Morris , "Serge E . Hallyn" , Lakshmi Ramasubramanian , Prakhar Srivastava , linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, Eric Biederman , kexec@lists.infradead.org Date: Thu, 25 Jun 2020 18:56:44 -0400 In-Reply-To: <20200623003236.830149-13-tyhicks@linux.microsoft.com> References: <20200623003236.830149-1-tyhicks@linux.microsoft.com> <20200623003236.830149-13-tyhicks@linux.microsoft.com> 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-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.687 definitions=2020-06-25_19:2020-06-25,2020-06-25 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 impostorscore=0 phishscore=0 spamscore=0 adultscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006250133 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2020-06-22 at 19:32 -0500, Tyler Hicks wrote: > Take the properties of the kexec kernel's inode and the current task > ownership into consideration when matching a KEXEC_CMDLINE operation to > the rules in the IMA policy. This allows for some uniformity when > writing IMA policy rules for KEXEC_KERNEL_CHECK, KEXEC_INITRAMFS_CHECK, > and KEXEC_CMDLINE operations. > > Prior to this patch, it was not possible to write a set of rules like > this: > > dont_measure func=KEXEC_KERNEL_CHECK obj_type=foo_t > dont_measure func=KEXEC_INITRAMFS_CHECK obj_type=foo_t > dont_measure func=KEXEC_CMDLINE obj_type=foo_t > measure func=KEXEC_KERNEL_CHECK > measure func=KEXEC_INITRAMFS_CHECK > measure func=KEXEC_CMDLINE > > The inode information associated with the kernel being loaded by a > kexec_kernel_load(2) syscall can now be included in the decision to > measure or not > > Additonally, the uid, euid, and subj_* conditionals can also now be > used in KEXEC_CMDLINE rules. There was no technical reason as to why > those conditionals weren't being considered previously other than > ima_match_rules() didn't have a valid inode to use so it immediately > bailed out for KEXEC_CMDLINE operations rather than going through the > full list of conditional comparisons. This makes a lot of sense.   > diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c > index c1583d98c5e5..82acd66bf653 100644 > --- a/security/integrity/ima/ima_main.c > +++ b/security/integrity/ima/ima_main.c > @@ -731,13 +731,15 @@ int ima_load_data(enum kernel_load_data_id id) > * @eventname: event name to be used for the buffer entry. > * @func: IMA hook > * @pcr: pcr to extend the measurement > + * @inode: inode associated with the object being measured (NULL for KEY_CHECK) > * @keyring: keyring name to determine the action to be performed > * > * Based on policy, the buffer is measured into the ima log. > */ > void process_buffer_measurement(const void *buf, int size, > const char *eventname, enum ima_hooks func, > - int pcr, const char *keyring) > + int pcr, struct inode *inode, > + const char *keyring) > { The file descriptor is passed as the first arg to process_measurement().  Sorry for the patch churn, but could we do the same for process_buffer_measurements.  As much as possible lets keep them in same. thanks, Mimi From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1joanl-0004go-N8 for kexec@lists.infradead.org; Thu, 25 Jun 2020 22:57:05 +0000 Message-ID: <1593125804.27152.426.camel@linux.ibm.com> Subject: Re: [PATCH 12/12] ima: Support additional conditionals in the KEXEC_CMDLINE hook function From: Mimi Zohar Date: Thu, 25 Jun 2020 18:56:44 -0400 In-Reply-To: <20200623003236.830149-13-tyhicks@linux.microsoft.com> References: <20200623003236.830149-1-tyhicks@linux.microsoft.com> <20200623003236.830149-13-tyhicks@linux.microsoft.com> Mime-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "kexec" Errors-To: kexec-bounces+dwmw2=infradead.org@lists.infradead.org To: Tyler Hicks , Dmitry Kasatkin Cc: Prakhar Srivastava , kexec@lists.infradead.org, James Morris , linux-kernel@vger.kernel.org, Lakshmi Ramasubramanian , linux-security-module@vger.kernel.org, Eric Biederman , linux-integrity@vger.kernel.org, "Serge E . Hallyn" T24gTW9uLCAyMDIwLTA2LTIyIGF0IDE5OjMyIC0wNTAwLCBUeWxlciBIaWNrcyB3cm90ZToKPiBU YWtlIHRoZSBwcm9wZXJ0aWVzIG9mIHRoZSBrZXhlYyBrZXJuZWwncyBpbm9kZSBhbmQgdGhlIGN1 cnJlbnQgdGFzawo+IG93bmVyc2hpcCBpbnRvIGNvbnNpZGVyYXRpb24gd2hlbiBtYXRjaGluZyBh IEtFWEVDX0NNRExJTkUgb3BlcmF0aW9uIHRvCj4gdGhlIHJ1bGVzIGluIHRoZSBJTUEgcG9saWN5 LiBUaGlzIGFsbG93cyBmb3Igc29tZSB1bmlmb3JtaXR5IHdoZW4KPiB3cml0aW5nIElNQSBwb2xp Y3kgcnVsZXMgZm9yIEtFWEVDX0tFUk5FTF9DSEVDSywgS0VYRUNfSU5JVFJBTUZTX0NIRUNLLAo+ IGFuZCBLRVhFQ19DTURMSU5FIG9wZXJhdGlvbnMuCj4gCj4gUHJpb3IgdG8gdGhpcyBwYXRjaCwg aXQgd2FzIG5vdCBwb3NzaWJsZSB0byB3cml0ZSBhIHNldCBvZiBydWxlcyBsaWtlCj4gdGhpczoK PiAKPiAgZG9udF9tZWFzdXJlIGZ1bmM9S0VYRUNfS0VSTkVMX0NIRUNLIG9ial90eXBlPWZvb190 Cj4gIGRvbnRfbWVhc3VyZSBmdW5jPUtFWEVDX0lOSVRSQU1GU19DSEVDSyBvYmpfdHlwZT1mb29f dAo+ICBkb250X21lYXN1cmUgZnVuYz1LRVhFQ19DTURMSU5FIG9ial90eXBlPWZvb190Cj4gIG1l YXN1cmUgZnVuYz1LRVhFQ19LRVJORUxfQ0hFQ0sKPiAgbWVhc3VyZSBmdW5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