Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751944AbdHCVB3 (ORCPT ); Thu, 3 Aug 2017 17:01:29 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:46290 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751794AbdHCVB0 (ORCPT ); Thu, 3 Aug 2017 17:01:26 -0400 References: <20170706221753.17380-1-bauerman@linux.vnet.ibm.com> <20170706221753.17380-8-bauerman@linux.vnet.ibm.com> <1501424988.9230.67.camel@linux.vnet.ibm.com> <87fud9yig8.fsf@linux.vnet.ibm.com> <1501714334.27872.38.camel@linux.vnet.ibm.com> <1501771065.27872.63.camel@linux.vnet.ibm.com> From: Thiago Jung Bauermann To: Mimi Zohar Cc: linux-security-module@vger.kernel.org, linux-ima-devel@lists.sourceforge.net, keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Dmitry Kasatkin , James Morris , "Serge E. Hallyn" , David Howells , David Woodhouse , Jessica Yu , Rusty Russell , Herbert Xu , "David S. Miller" , "AKASHI\, Takahiro" Subject: Re: [PATCH v3 7/7] ima: Support module-style appended signatures for appraisal In-reply-to: <1501771065.27872.63.camel@linux.vnet.ibm.com> Date: Thu, 03 Aug 2017 18:01:06 -0300 MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-MML: disable x-cbid: 17080321-0004-0000-0000-000012B2861A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007479; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000216; SDB=6.00897123; UDB=6.00448857; IPR=6.00677307; BA=6.00005509; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016520; XFM=3.00000015; UTC=2017-08-03 21:01:23 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17080321-0005-0000-0000-00008088D917 Message-Id: <87y3r0xt65.fsf@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-08-03_10:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1706020000 definitions=main-1708030320 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2819 Lines: 80 Mimi Zohar writes: > On Wed, 2017-08-02 at 18:52 -0400, Mimi Zohar wrote: >> On Wed, 2017-08-02 at 14:42 -0300, Thiago Jung Bauermann wrote: >> > Mimi Zohar writes: > >> > >> @@ -229,8 +251,24 @@ int ima_appraise_measurement(enum ima_hooks func, >> > >> goto out; >> > >> } >> > >> >> > >> - status = evm_verifyxattr(dentry, XATTR_NAME_IMA, xattr_value, rc, iint); >> > >> - if ((status != INTEGRITY_PASS) && (status != INTEGRITY_UNKNOWN)) { >> > >> + /* >> > >> + * Appended signatures aren't protected by EVM but we still call >> > >> + * evm_verifyxattr to check other security xattrs, if they exist. >> > >> + */ >> > >> + if (appraising_modsig) { >> > >> + xattr_value_evm = NULL; >> > >> + xattr_len_evm = 0; >> > >> + } else { >> > >> + xattr_value_evm = xattr_value; >> > >> + xattr_len_evm = xattr_len; >> > >> + } >> > >> + >> > >> + status = evm_verifyxattr(dentry, XATTR_NAME_IMA, xattr_value_evm, >> > >> + xattr_len_evm, iint); >> > >> + if (appraising_modsig && status == INTEGRITY_FAIL) { >> > >> + cause = "invalid-HMAC"; >> > >> + goto out; >> > > >> > > "modsig" is special, because having any security xattrs is not >> > > required. This test doesn't prevent status from being set to >> > > "missing-HMAC". This test is redundant with the original tests below. >> > >> > Indeed, that is wrong. I'm still a bit fuzzy about how EVM works and how >> > it interacts with IMA. The only way I can think of singling out modsig >> > without reintroduced the complex expression you didn't like in v2 is as >> > below. What do you think? >> >> The original code, without any extra tests, should be fine. > > There is one major difference. > > EVM verifies a file's metadata has not been modified based on either > an HMAC or signature stored as security.evm. Prior to the appended > signatures patch set, all files in policy required a security.evm > xattr. With IMA enabled we could guarantee that at least one security > xattr existed. The only exception were new files, which hadn't yet > been labeled. > > With appended signatures, there is now no guarantee that at least one > security xattr exists. > > Perhaps the code snippet below will help clarify the meaning of the > integrity_status results. > > switch (status) { > case INTEGRITY_PASS: > case INTEGRITY_UNKNOWN: > break; > case INTEGRITY_NOXATTRS:/* no EVM protected xattrs */ > if (appraising_modsig) > break; > case INTEGRITY_NOLABEL:/* no security.evm xattr */ > cause = "missing-HMAC"; > fail = 1; > break; > case INTEGRITY_FAIL:/* invalid HMAC/signature */ > default: > cause = "invalid-HMAC"; > fail = 1; > break; > } Thanks! I'll use the switch above in the next version of the patch. -- Thiago Jung Bauermann IBM Linux Technology Center