Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1390336yba; Thu, 9 May 2019 16:03:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqy+hkd3WINwUpytdSTCDkaV8KPKRWN18qYO6PePE74MLpZeLvxkfhglTz5t4omDAshn/rKb X-Received: by 2002:a63:5c1b:: with SMTP id q27mr9324506pgb.127.1557443000539; Thu, 09 May 2019 16:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557443000; cv=none; d=google.com; s=arc-20160816; b=GQwaCtd5xpLh74Q2TNGTyAHNt+cVqBlKXbD6Y3SIVxxlsKrOsSU7z/LPuDzR5adJbt PSAIiy5/IPJiqgnRYnesbEmy1JjZyCFJ1btrTNuHmLbrttzTKuywEyBvmLENL6XcCDJq g7jZgMbmTuAH1V8jb6cMOxEowKCFxHxtauIVA2Bgp30c1eLGfj2UHnOygWcgb23igxIc zgHPrDURDYSrNrRWGw6C0nC2fbOy/uvbDmHWBiLuGDgMm0kpnjqhOi3h9PAQIJ8Ub8E6 ZgdB/E4vLkuL6fNBE34NQVtJxWPcx/wzY2q1OJon/5PhSA0Dj7RtxbFnCwBprtGFMZ0b iF9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:cc:to:from:subject; bh=ZmkNbCIy3GMaYFwp0474OR/A2UhfRjt+G0uP/A7cXbc=; b=oAnrol5TuwWH32J4Psr3fqPbTD9XN7KsIU5xksbQtq3mF64Apvc2wnzUEgNY6Vimpp aZIG6mmm+MRbxfpkGnzF4bEB2pvxppAnHqXw8W1idmSoF/NW1x57C0jhsvBcIeihC0/T pg4d9dxVLyehVRdniX52xERENFQ4dEM2rl9BuxtylEoUB4DAG58LpsdgpD5IrpfptpkS 5Ox6tguIZrSNvNhA7m5Gb0HTN9qUPu9DuZE/lUV5LYbu3BHPl3nf95motUsZMUCMgObL Lf8JqBJDxXUc6LgFppjX87KpD7xKpQ1bPfhmjke0yykAeZcAZicEKYIcCcuRzui1MJ+Y s07w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t139si859365pfc.192.2019.05.09.16.03.01; Thu, 09 May 2019 16:03:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726825AbfEIXBm (ORCPT + 99 others); Thu, 9 May 2019 19:01:42 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44252 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726789AbfEIXBl (ORCPT ); Thu, 9 May 2019 19:01:41 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x49Mpe9K136108 for ; Thu, 9 May 2019 19:01:40 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2scuyktuu6-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 09 May 2019 19:01:40 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 10 May 2019 00:01:37 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 10 May 2019 00:01:32 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x49N1VD750659486 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 9 May 2019 23:01:31 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BE2FF4C044; Thu, 9 May 2019 23:01:31 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E739D4C040; Thu, 9 May 2019 23:01:29 +0000 (GMT) Received: from dhcp-9-31-103-88.watson.ibm.com (unknown [9.31.103.88]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 9 May 2019 23:01:29 +0000 (GMT) Subject: Re: [PATCH v10 11/12] ima: Define ima-modsig template From: Mimi Zohar To: Thiago Jung Bauermann , linux-integrity@vger.kernel.org Cc: linux-security-module@vger.kernel.org, keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , David Howells , David Woodhouse , Jessica Yu , Herbert Xu , "David S. Miller" , Jonathan Corbet , "AKASHI, Takahiro" Date: Thu, 09 May 2019 19:01:29 -0400 In-Reply-To: <20190418035120.2354-12-bauerman@linux.ibm.com> References: <20190418035120.2354-1-bauerman@linux.ibm.com> <20190418035120.2354-12-bauerman@linux.ibm.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-cbid: 19050923-0020-0000-0000-0000033B164F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19050923-0021-0000-0000-0000218DBF5D Message-Id: <1557442889.10635.88.camel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-05-09_02:,, 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 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905090130 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2019-04-18 at 00:51 -0300, Thiago Jung Bauermann wrote: > Define new "d-modsig" template field which holds the digest that is > expected to match the one contained in the modsig, and also new "modsig" > template field which holds the appended file signature. > > Add a new "ima-modsig" defined template descriptor with the new fields as > well as the ones from the "ima-sig" descriptor. > > Change ima_store_measurement() to accept a struct modsig * argument so that > it can be passed along to the templates via struct ima_event_data. > > Suggested-by: Mimi Zohar > Signed-off-by: Thiago Jung Bauermann Thanks, Roberto.  Just some thoughts inline below. Reviewed-by: Mimi Zohar > --- > +/* > + * Validating the appended signature included in the measurement list requires > + * the file hash calculated without the appended signature (i.e., the 'd-modsig' > + * field). Therefore, notify the user if they have the 'modsig' field but not > + * the 'd-modsig' field in the template. > + */ > +static void check_current_template_modsig(void) > +{ > +#define MSG "template with 'modsig' field also needs 'd-modsig' field\n" > + struct ima_template_desc *template; > + bool has_modsig, has_dmodsig; > + static bool checked; > + int i; > + > + /* We only need to notify the user once. */ > + if (checked) > + return; > + > + has_modsig = has_dmodsig = false; > + template = ima_template_desc_current(); > + for (i = 0; i < template->num_fields; i++) { > + if (!strcmp(template->fields[i]->field_id, "modsig")) > + has_modsig = true; > + else if (!strcmp(template->fields[i]->field_id, "d-modsig")) > + has_dmodsig = true; > + } > + > + if (has_modsig && !has_dmodsig) > + pr_notice(MSG); > + > + checked = true; > +#undef MSG > +} > + There was some recent discussion about supporting per IMA policy rule template formats.  This feature will allow just the kexec kernel image to require ima-modsig.  When per policy rule template formats support is upstreamed, this function will need to be updated. > > @@ -389,3 +425,25 @@ int ima_eventsig_init(struct ima_event_data *event_data, > return ima_write_template_field_data(xattr_value, event_data->xattr_len, > DATA_FMT_HEX, field_data); > } > + > +int ima_eventmodsig_init(struct ima_event_data *event_data, > + struct ima_field_data *field_data) > +{ > + const void *data; > + u32 data_len; > + int rc; > + > + if (!event_data->modsig) > + return 0; > + > + /* > + * The xattr_value for IMA_MODSIG is a runtime structure containing > + * pointers. Get its raw data instead. > + */ "xattr_value"?  The comment needs some clarification. Mimi > + rc = ima_modsig_serialize(event_data->modsig, &data, &data_len); > + if (rc) > + return rc; > + > + return ima_write_template_field_data(data, data_len, > + DATA_FMT_HEX, field_data); > +}