Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2228383rwl; Thu, 6 Apr 2023 07:31:09 -0700 (PDT) X-Google-Smtp-Source: AKy350bAmNfhiOUytsosKieHVHTcxe8IKYWuzqmyQzSMxqeDnuv7PxqoJFBMapiIxJOadCz8uhOM X-Received: by 2002:aa7:d1cd:0:b0:4fc:725:e670 with SMTP id g13-20020aa7d1cd000000b004fc0725e670mr1802677edp.11.1680791469461; Thu, 06 Apr 2023 07:31:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680791469; cv=none; d=google.com; s=arc-20160816; b=dL0kP2WTMwPI0wX6hiKfUp9RNnUVHrW/24Ap5/jlgCjcFPHdy2umA6BsnOrsa4Wicy Mkn5pLXmcRz3uMNDa4tJzasQVa/ddIN/lblYTv5NfXNuYUEeEJ5bqvBj7JnDjWXtWK26 ne3x2u+xvPCZWQInvB/8htz4W+wccORvV1s9LTX4u7rs9smyL7S7wbMCqLv8nP6d9p1D GaTy19MSL0jHLHWNS/GWt0iKXwh7RrIdIxO6Rj7HQ8Ig7Oj8EHgFfC1T3U7RD63hPV7d ETMzE6tqbgJIppK+G8UWuigiJcGQM6aUFvtf7zvIYj7+vpt1P2IaU88dG6hBWpdF65m1 WXaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature; bh=L8plKRYXq/lUnBCPQHPtYUtZSWbpoXo5C5FVI1IJWDY=; b=BQumnz+nAVrFUS9LajR9x2JiO3V7EqdePOMTImKJWrs8q9m1YcB+bKufHprXIyvGrl 2ne1Jc66Vlaw9xmrvxDEHEfUFD0gUgx06YvNq4PVAP3ZOa7EMFJmf3wcRZnLn0CtTQ/z SIurvgZfDtaMPln2NM8QJwX3KhEVhKWZvFe+/Z7FVttvVhKbDbzbHMN9WUxF+n6hfgWv j0iK9poigTOkY5Zhyn7uBFUWIi068HzvpY5uqcI3j66/1bgIRXOQoiJOBbYPpOPltuty z+xOTCnXc9tlGtQye34RW0SizhG1NUxBoDYE25wliPnwgBsbXbjqA+ppkUmucby2BTaN Getg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="S4brrj5/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n4-20020aa7c684000000b004be020a0537si1287806edq.512.2023.04.06.07.30.39; Thu, 06 Apr 2023 07:31:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="S4brrj5/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238742AbjDFOUs (ORCPT + 99 others); Thu, 6 Apr 2023 10:20:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229898AbjDFOUr (ORCPT ); Thu, 6 Apr 2023 10:20:47 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1F2786A8; Thu, 6 Apr 2023 07:20:45 -0700 (PDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 336E3HqY030670; Thu, 6 Apr 2023 14:20:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : from : subject : to : cc : references : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=L8plKRYXq/lUnBCPQHPtYUtZSWbpoXo5C5FVI1IJWDY=; b=S4brrj5/c+nujUTGS55jGpA0UUgyKBYSf1/jmisFa+J6XDkl95Z4rjHjq+1BBxH0L/AP Xsb43nwU7WEiA1TmC0G897Gx1+C8doU6kk9i2bZ+/v5crGM07vND4AMFohtvKdvpIL1v J4ljhAwJkaKhcoRgK/QHx06irQnjFPqM9f/DzI+tgUeac6WvAaNKn7awShtTMqbmeDQm 1u6uzdJkqggKseZPDFsi3VmssMlPMTqQUkohRVIDheb4RcKZiazG3l6ZwSXMeE50S/K2 bF4vAFrSTDm5GJyMIv97lEI0x6br25WvymKXIw/mvY1pNGgXdDnBIU3FBC5vP3AEOhMl 2g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3psayrwu7e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Apr 2023 14:20:41 +0000 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 336BiHIY016886; Thu, 6 Apr 2023 14:20:40 GMT Received: from ppma05wdc.us.ibm.com (1b.90.2fa9.ip4.static.sl-reverse.com [169.47.144.27]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3psayrwu6q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Apr 2023 14:20:40 +0000 Received: from pps.filterd (ppma05wdc.us.ibm.com [127.0.0.1]) by ppma05wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 336B8c5A014549; Thu, 6 Apr 2023 14:20:39 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([9.208.129.114]) by ppma05wdc.us.ibm.com (PPS) with ESMTPS id 3ppc88ay6h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Apr 2023 14:20:39 +0000 Received: from smtpav02.wdc07v.mail.ibm.com (smtpav02.wdc07v.mail.ibm.com [10.39.53.229]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 336EKcHD53870876 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 6 Apr 2023 14:20:38 GMT Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 676765805B; Thu, 6 Apr 2023 14:20:38 +0000 (GMT) Received: from smtpav02.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7F7C158058; Thu, 6 Apr 2023 14:20:37 +0000 (GMT) Received: from [9.47.158.152] (unknown [9.47.158.152]) by smtpav02.wdc07v.mail.ibm.com (Postfix) with ESMTP; Thu, 6 Apr 2023 14:20:37 +0000 (GMT) Message-ID: Date: Thu, 6 Apr 2023 10:20:37 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 From: Stefan Berger Subject: Re: [PATCH] overlayfs: Trigger file re-evaluation by IMA / EVM after writes To: Paul Moore , Christian Brauner Cc: zohar@linux.ibm.com, linux-integrity@vger.kernel.org, miklos@szeredi.hu, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, amir73il@gmail.com References: <20230405171449.4064321-1-stefanb@linux.ibm.com> <20230406-diffamieren-langhaarig-87511897e77d@brauner> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: q3P_7vLviB0y6aC0xfvdIB_lxMeHHrGJ X-Proofpoint-GUID: axRA0-svgYmFpSpmpbKHeis_USgWT0Jq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-06_07,2023-04-06_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 priorityscore=1501 mlxscore=0 adultscore=0 spamscore=0 malwarescore=0 clxscore=1015 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304060124 X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/6/23 10:05, Paul Moore wrote: > On Thu, Apr 6, 2023 at 6:26 AM Christian Brauner wrote: >> On Wed, Apr 05, 2023 at 01:14:49PM -0400, Stefan Berger wrote: >>> Overlayfs fails to notify IMA / EVM about file content modifications >>> and therefore IMA-appraised files may execute even though their file >>> signature does not validate against the changed hash of the file >>> anymore. To resolve this issue, add a call to integrity_notify_change() >>> to the ovl_release() function to notify the integrity subsystem about >>> file changes. The set flag triggers the re-evaluation of the file by >>> IMA / EVM once the file is accessed again. >>> >>> Signed-off-by: Stefan Berger >>> --- >>> fs/overlayfs/file.c | 4 ++++ >>> include/linux/integrity.h | 6 ++++++ >>> security/integrity/iint.c | 13 +++++++++++++ >>> 3 files changed, 23 insertions(+) >>> >>> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c >>> index 6011f955436b..19b8f4bcc18c 100644 >>> --- a/fs/overlayfs/file.c >>> +++ b/fs/overlayfs/file.c >>> @@ -13,6 +13,7 @@ >>> #include >>> #include >>> #include >>> +#include >>> #include "overlayfs.h" >>> >>> struct ovl_aio_req { >>> @@ -169,6 +170,9 @@ static int ovl_open(struct inode *inode, struct file *file) >>> >>> static int ovl_release(struct inode *inode, struct file *file) >>> { >>> + if (file->f_flags & O_ACCMODE) >>> + integrity_notify_change(inode); >>> + >>> fput(file->private_data); >>> >>> return 0; >>> diff --git a/include/linux/integrity.h b/include/linux/integrity.h >>> index 2ea0f2f65ab6..cefdeccc1619 100644 >>> --- a/include/linux/integrity.h >>> +++ b/include/linux/integrity.h >>> @@ -23,6 +23,7 @@ enum integrity_status { >>> #ifdef CONFIG_INTEGRITY >>> extern struct integrity_iint_cache *integrity_inode_get(struct inode *inode); >>> extern void integrity_inode_free(struct inode *inode); >>> +extern void integrity_notify_change(struct inode *inode); >> >> I thought we concluded that ima is going to move into the security hook >> infrastructure so it seems this should be a proper LSM hook? > > We are working towards migrating IMA/EVM to the LSM layer, but there > are a few things we need to fix/update/remove first; if anyone is > curious, you can join the LSM list as we've been discussing some of > these changes this week. Bug fixes like this should probably remain > as IMA/EVM calls for the time being, with the understanding that they > will migrate over with the rest of IMA/EVM. > > That said, we should give Mimi a chance to review this patch as it is > possible there is a different/better approach. A bit of patience may > be required as I know Mimi is very busy at the moment. > There may be a better approach actually by increasing the inode's i_version, which then should trigger the appropriate path in ima_check_last_writer().