From patchwork Mon Feb 5 13:40:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mimi Zohar X-Patchwork-Id: 10200385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8970F60247 for ; Mon, 5 Feb 2018 13:41:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BB6426E4A for ; Mon, 5 Feb 2018 13:41:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6FD342874E; Mon, 5 Feb 2018 13:41:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5996826E4A for ; Mon, 5 Feb 2018 13:41:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753060AbeBENlo (ORCPT ); Mon, 5 Feb 2018 08:41:44 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:37292 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753069AbeBENlj (ORCPT ); Mon, 5 Feb 2018 08:41:39 -0500 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w15DenkD008374 for ; Mon, 5 Feb 2018 08:41:39 -0500 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2fxqd12c2u-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 05 Feb 2018 08:41:38 -0500 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 5 Feb 2018 13:41:36 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 5 Feb 2018 13:41:33 -0000 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 w15DfWpV49414264; Mon, 5 Feb 2018 13:41:32 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 212E04C04A; Mon, 5 Feb 2018 13:35:25 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3A65F4C044; Mon, 5 Feb 2018 13:35:24 +0000 (GMT) Received: from localhost.localdomain (unknown [9.80.80.137]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 5 Feb 2018 13:35:24 +0000 (GMT) Subject: [RFC PATCH] ima: force the re-evaluation of files on untrusted file systems From: Mimi Zohar To: Miklos Szeredi Cc: Alban Crequy , Dongsu Park , linux-integrity , linux-security-module , linux-fsdevel Date: Mon, 05 Feb 2018 08:40:54 -0500 Mime-Version: 1.0 X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) X-TM-AS-GCONF: 00 x-cbid: 18020513-0008-0000-0000-000004C98D71 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18020513-0009-0000-0000-00001E5D363E Message-Id: <1517838054.3736.49.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-02-05_03:, , 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-1802050175 Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On filesystems, such as fuse or remote filesystems, that we can not detect or rely on the filesystem to tell us when a file has changed, always re-measure, re-appraise, and/or re-audit the file. Signed-of-by: Mimi Zohar --- Hi Miklos, Was something like this what you had in mind? Mimi --- security/integrity/ima/ima_main.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index 6d78cb26784d..a428bd75232e 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c @@ -170,6 +170,7 @@ static int process_measurement(struct file *file, char *buf, loff_t size, int mask, enum ima_hooks func, int opened) { struct inode *inode = file_inode(file); + struct dentry *dentry = file_dentry(file); struct integrity_iint_cache *iint = NULL; struct ima_template_desc *template_desc; char *pathbuf = NULL; @@ -228,9 +229,16 @@ static int process_measurement(struct file *file, char *buf, loff_t size, IMA_APPRAISE_SUBMASK | IMA_APPRAISED_SUBMASK | IMA_ACTION_FLAGS); - if (test_and_clear_bit(IMA_CHANGE_XATTR, &iint->atomic_flags)) - /* reset all flags if ima_inode_setxattr was called */ + /* + * Re-measure, re-appraise, and/or re-audit a file, if the security + * xattrs changed or if the file is on an untrusted file system + * (eg. FUSE, remote filesystems). + */ + if (test_and_clear_bit(IMA_CHANGE_XATTR, &iint->atomic_flags) || + (dentry->d_op && dentry->d_op->d_revalidate)) { iint->flags &= ~IMA_DONE_MASK; + iint->measured_pcrs = 0; + } /* Determine if already appraised/measured based on bitmask * (IMA_MEASURE, IMA_MEASURED, IMA_XXXX_APPRAISE, IMA_XXXX_APPRAISED,