Received: by 10.213.65.68 with SMTP id h4csp1320606imn; Wed, 14 Mar 2018 17:06:10 -0700 (PDT) X-Google-Smtp-Source: AG47ELuASLClQAwlr+1YN17vTDJmzvGCc6e3M60hLSR3cyu90tTaLT14YWNIaeWtn5izuu6BCUx9 X-Received: by 2002:a17:902:67c8:: with SMTP id g8-v6mr5800217pln.106.1521072370442; Wed, 14 Mar 2018 17:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521072370; cv=none; d=google.com; s=arc-20160816; b=ZAxVV4crk2YicxhbxPqXEA5t7cZCa8fctPVKGjXlvpI2mdnKPCqRWRAJTIGQygi0/R XDY1VYFX5Jcy1JWkWicpTEiz6CJZoEj8zHXu8ehIKMc4K9G1kcT9P2Va/MnP+nw5Igry 8XasRB9XmdIgfYxz8zXb8zjFYV9lAKqwKt0GwJrtD7t/SWS7Ujxx2L15U7dU7Upx9xlu Dg/hHaEjJj61haw+k/KnHWJd8zYeTfnPZtm3MkErvIXPjvYgInknPcFPTWSs/8ZgMajS OUS5PeY1+4wnffw3cndmV1YGUlbA0z1ED9I30UGukv9pVFE1gzt1AZ9Z0O2cHsF4pb4I mx9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:mime-version:date:in-reply-to :subject:cc:to:from:user-agent:references:arc-authentication-results; bh=0wHORvfVJFS3/tqynO917bS+HDblwu4z70bmqCyE62I=; b=0PTYdZl6uFUIeA0aGb1XbkPDkd831XCcIzNN1lWTakCYCBYL7aMvYG2iHN+qP7AzAa NlOS2/PjBCJgh9SRluGjYdBRrPxhGNOgOOJv0OWz0a7PVXg8t8/IwGikqP8KhUbiCpXZ e00yWO01dVDqsjwO2nNmEtVHavp2Jj6NNEe33Ktm1+H+RAzkiFLJjvICFITYEtHsFnuO 61ggIPt17vcJQ6KInJA+jnGX0SS99GDN6MOdtwLyDab9pMJLzR71dhE2NvLsSJCX+suf aMiTUUggpI3JQbV0EolamyOt9dt8hk76n3UuZl+h06z52oLqlh0cl+S5aYhJlKnwJTWY /unw== 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 i3si2570288pgt.470.2018.03.14.17.05.56; Wed, 14 Mar 2018 17:06:10 -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 S1751961AbeCOADs (ORCPT + 99 others); Wed, 14 Mar 2018 20:03:48 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55286 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751835AbeCOADq (ORCPT ); Wed, 14 Mar 2018 20:03:46 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2F02KtV052418 for ; Wed, 14 Mar 2018 20:03:46 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gq8w6jjqe-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 14 Mar 2018 20:03:45 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 14 Mar 2018 18:03:45 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 14 Mar 2018 18:03:42 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2F03gEI14811508; Wed, 14 Mar 2018 17:03:42 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5989178037; Wed, 14 Mar 2018 18:03:42 -0600 (MDT) Received: from morokweng.localdomain (unknown [9.85.137.56]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTPS id 612AC78043; Wed, 14 Mar 2018 18:03:40 -0600 (MDT) References: <20180314202020.3794-1-bauerman@linux.vnet.ibm.com> <20180314202020.3794-4-bauerman@linux.vnet.ibm.com> <20180314214045.GC14289@mail.hallyn.com> User-agent: mu4e 1.0; emacs 25.3.1 From: Thiago Jung Bauermann To: "Serge E. Hallyn" Cc: linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, James Morris , Mimi Zohar , Dmitry Kasatkin Subject: Re: [PATCH 3/4] ima: Improvements in ima_appraise_measurement() In-reply-to: <20180314214045.GC14289@mail.hallyn.com> Date: Wed, 14 Mar 2018 21:03:36 -0300 MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 x-cbid: 18031500-0004-0000-0000-000013CD9AE6 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008675; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000254; SDB=6.01003137; UDB=6.00510491; IPR=6.00782468; MB=3.00020039; MTD=3.00000008; XFM=3.00000015; UTC=2018-03-15 00:03:44 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18031500-0005-0000-0000-000086776C33 Message-Id: <87efkmjjc7.fsf@morokweng.localdomain> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-14_12:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 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-1803140255 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Serge, Thanks for quickly reviewing these patches! Serge E. Hallyn writes: > Quoting Thiago Jung Bauermann (bauerman@linux.vnet.ibm.com): >> From: Mimi Zohar >> @@ -241,16 +241,20 @@ int ima_appraise_measurement(enum ima_hooks func, >> } >> >> status = evm_verifyxattr(dentry, XATTR_NAME_IMA, xattr_value, rc, iint); >> - if ((status != INTEGRITY_PASS) && >> - (status != INTEGRITY_PASS_IMMUTABLE) && >> - (status != INTEGRITY_UNKNOWN)) { >> - if ((status == INTEGRITY_NOLABEL) >> - || (status == INTEGRITY_NOXATTRS)) >> - cause = "missing-HMAC"; >> - else if (status == INTEGRITY_FAIL) >> - cause = "invalid-HMAC"; >> + switch (status) { >> + case INTEGRITY_PASS: >> + case INTEGRITY_PASS_IMMUTABLE: >> + case INTEGRITY_UNKNOWN: > > Wouldn't it be more future-proof to replace this with a 'default', or > to at least add a "default: BUG()" to catch new status values? I agree. I like the "default: BUG()" option. >> + break; >> + case INTEGRITY_NOXATTRS: /* No EVM protected xattrs. */ >> + case INTEGRITY_NOLABEL: /* No security.evm xattr. */ >> + cause = "missing-HMAC"; >> + goto out; >> + case INTEGRITY_FAIL: /* Invalid HMAC/signature. */ >> + cause = "invalid-HMAC"; >> goto out; >> } >> + >> switch (xattr_value->type) { >> case IMA_XATTR_DIGEST_NG: >> /* first byte contains algorithm id */ >> @@ -316,17 +320,20 @@ int ima_appraise_measurement(enum ima_hooks func, >> integrity_audit_msg(AUDIT_INTEGRITY_DATA, inode, filename, >> op, cause, rc, 0); >> } else if (status != INTEGRITY_PASS) { >> + /* Fix mode, but don't replace file signatures. */ >> if ((ima_appraise & IMA_APPRAISE_FIX) && >> (!xattr_value || >> xattr_value->type != EVM_IMA_XATTR_DIGSIG)) { >> if (!ima_fix_xattr(dentry, iint)) >> status = INTEGRITY_PASS; >> - } else if ((inode->i_size == 0) && >> - (iint->flags & IMA_NEW_FILE) && >> - (xattr_value && >> - xattr_value->type == EVM_IMA_XATTR_DIGSIG)) { >> + } >> + >> + /* Permit new files with file signatures, but without data. */ >> + if (inode->i_size == 0 && iint->flags & IMA_NEW_FILE && > > This may be correct, but it's not identical to what you're replacing. > Since in either case you're setting status to INTEGRITY_PASS the final > result is the same, but with a few extra possible steps. Not sure > whether that matters. Good point. I'll have to defer this one to Mimi though. > >> + xattr_value && xattr_value->type == EVM_IMA_XATTR_DIGSIG) { >> status = INTEGRITY_PASS; >> } >> + >> integrity_audit_msg(AUDIT_INTEGRITY_DATA, inode, filename, >> op, cause, rc, 0); >> } else { -- Thiago Jung Bauermann IBM Linux Technology Center