Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3539231pxf; Mon, 22 Mar 2021 08:44:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyx6WcWgLnlDCctEXjj4C9ATOaeKUf/tRl6ASbjTc/3Ou34N6vRNDKkdIMexamnJ/7Mptav X-Received: by 2002:a17:906:32da:: with SMTP id k26mr348858ejk.483.1616427869014; Mon, 22 Mar 2021 08:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616427869; cv=none; d=google.com; s=arc-20160816; b=OcI4g/Irdkv6LgYodG3KCEvJXm2xEEFmK16st4TCU3I0pDh89se/7SDrjSwE2LpKs+ EOZYu91RH0wGXY2qNSOixoypAtsQoxiBGP1THpU7RVGoEnYB4anOEXzwEJYxAO1GaTL1 tIdzk65UVJpIjczQhWIHnhtPKkzw4Pvf9r/HzBxqqp3y9gWYWtSLq/xXIPqXumDl3+aD KlonRzP1vvhzXIPHumo1KKFhRId2/YCBEvRibdZS44bYqxzGrUUGLBGYEQ1RHXT8+AS7 YTObgRq4xFv23eqcGXQgemOaKhKf1kpU4AF41WxiXdFbw4zP9S9KCZGBSU0cPdfoEoYE 0AGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=JSGjVlSecphP6Rjd5Yu8JmkAMUWPNySTAdpd2p4Iy40=; b=N/Hz/ka2hjGYyzMw2UODyUq2Oo5NAAcOjInEKEhq9x7WcdmKW5hX8ay7oMvdEaMfqo /0G6Jy1ciZC3PWo+Qi0bzyThzS07Ee7vxZs8FyrGwlydPaa6UNP2+l3r1EW+5C2C0qmY haqJh91xbCRbo/7LN9s+5A1aBRqOSe0qUbMD0Ktar9Vn9jtBWON8u0cyojn8qufddo/1 pZl5Wiei3sIpW04UIZMT2BXO69xbQGqBnuK7hMzFlCnpvh/7YI4hv1OWRLDX3eThGXzz 6ukH6JRr1yjD7u1jjKhi4uHa9cFeyb44zOw+7jAfM1YnarxpM6FfMvf/IyqinJ57tpxp deZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=WmG9LedD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v3si11667304edr.497.2021.03.22.08.44.06; Mon, 22 Mar 2021 08:44:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=WmG9LedD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230294AbhCVPnL (ORCPT + 99 others); Mon, 22 Mar 2021 11:43:11 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:35308 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230034AbhCVPmk (ORCPT ); Mon, 22 Mar 2021 11:42:40 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 12MFYCQb050623; Mon, 22 Mar 2021 11:42:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=JSGjVlSecphP6Rjd5Yu8JmkAMUWPNySTAdpd2p4Iy40=; b=WmG9LedD/nB60DmtYU1RcobF8drhFu6Vo3N/rpDEGJnVTpR4NgTtYq/sxCfJdqds+9zZ D4hLG168AupmirTihXJOQ9J55IJKEfw7SbpdhSB7qEjYslImm7sQaYFvQN0vWuhbRX+q Ylqaf31ncJPeuJMw1yd6ENd5dW33jm8g6BDy9TLt9iYJ4CGo40Wj6bfczvVOZZImoOM/ IChgSY6cFG3kfTqxi/d8N7lkl6GdQYJ+At9BD/riXk2hicCpRHOf8TX0ttU5b+7D3oU+ soJKUsrv7eJoiXoEylJ2Q5j50tJFa6qawOrXRiJUk2Ydjpwg25Dsx57c8sN5+SpdLsA4 UQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 37dwy5nede-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 22 Mar 2021 11:42:30 -0400 Received: from m0098399.ppops.net (m0098399.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 12MFai07061716; Mon, 22 Mar 2021 11:42:29 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 37dwy5nebs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 22 Mar 2021 11:42:29 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.43/8.16.0.43) with SMTP id 12MFdP38005787; Mon, 22 Mar 2021 15:42:27 GMT Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by ppma04ams.nl.ibm.com with ESMTP id 37d99rag6u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 22 Mar 2021 15:42:27 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 12MFgPDM40567134 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Mar 2021 15:42:25 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E1EC24C046; Mon, 22 Mar 2021 15:42:24 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 718874C052; Mon, 22 Mar 2021 15:42:22 +0000 (GMT) Received: from li-f45666cc-3089-11b2-a85c-c57d1a57929f.ibm.com.ibmuc.com (unknown [9.211.152.56]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 22 Mar 2021 15:42:22 +0000 (GMT) From: Mimi Zohar To: Dmitry Vyukov Cc: Mimi Zohar , James Morris , "Serge E . Hallyn" , linux-integrity@vger.kernel.org, linux-security-module , LKML , Eric Biggers , Kees Cook Subject: [PATCH 1/2] ima: don't access a file's integrity status before an IMA policy is loaded Date: Mon, 22 Mar 2021 11:42:06 -0400 Message-Id: <20210322154207.6802-1-zohar@linux.ibm.com> X-Mailer: git-send-email 2.27.0 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.369,18.0.761 definitions=2021-03-22_08:2021-03-22,2021-03-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 mlxscore=0 suspectscore=0 clxscore=1015 phishscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 priorityscore=1501 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103220111 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Only after an IMA policy is loaded, check, save, or update the cached file's integrity status. Signed-off-by: Mimi Zohar --- security/integrity/ima/ima_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index 9ef748ea829f..9d1196f712e1 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c @@ -606,6 +606,9 @@ void ima_post_create_tmpfile(struct user_namespace *mnt_userns, struct integrity_iint_cache *iint; int must_appraise; + if (!ima_policy_flag || !S_ISREG(inode->i_mode)) + return; + must_appraise = ima_must_appraise(mnt_userns, inode, MAY_ACCESS, FILE_CHECK); if (!must_appraise) @@ -636,6 +639,9 @@ void ima_post_path_mknod(struct user_namespace *mnt_userns, struct inode *inode = dentry->d_inode; int must_appraise; + if (!ima_policy_flag || !S_ISREG(inode->i_mode)) + return; + must_appraise = ima_must_appraise(mnt_userns, inode, MAY_ACCESS, FILE_CHECK); if (!must_appraise) -- 2.27.0