Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1934454rwl; Thu, 6 Apr 2023 03:36:00 -0700 (PDT) X-Google-Smtp-Source: AKy350a9DA72macSLfRQYKcMhnbmOrnbYUH3+Nb/0gpyxYYqh064Nbi1IMQeF4DhMYk4BK6235Bp X-Received: by 2002:a17:906:fa0c:b0:947:d991:8e4c with SMTP id lo12-20020a170906fa0c00b00947d9918e4cmr5709397ejb.68.1680777360712; Thu, 06 Apr 2023 03:36:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680777360; cv=none; d=google.com; s=arc-20160816; b=yOepRRCosKn5vtmFrLcpUjNSkc1GPVvSok+rQSLrTiqboidnnNJ9emInKx4XDhT4Ek IxgY2q8AMNQbrHz3i2s+9xuW8W5sEkuDK05sd+5MAoecyGMmgowL9C68g6BSkkn1czM3 v40bdCU5P8xknG9IAAs3EaTZAeuHQnD2AOLOyiJsxltC6BnlfdV/Uhwb6BNMoFlBxir0 lRuSbo0F83SsrobKpNAa3V0q7Qs3T8l5lXxP8ZyGk5USncgpI1qfjGdZbrMl+qnrx4Gn 0zA2WWHcQ3RTFXNRD7aK7/1r7cwUVBMbM0WtLy9AY3P/O93rpaT2Uc5KKPTmXJ6IXl6s Ns/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=URqChwAkJpanvPCD6ZAAS4JwoGU3+2t+7yBodqZqWEo=; b=jElVqSv6A0GrIHfT1dUzVoI/prtS8QqqZJtIt7mrrG3eKGEsJKYPrIIAL5qkeze+n7 JCb2tqKqwDA7uCWdZZWczE5UXF9TOFbsDxcGWu5817Mk5GcHmy1341hvJ2bkHopKLNNn SpaF0LnCykj+jLm80fcZrnq2W9TZ4QTAN/K8YrAeJOqlMsm6aChFCimSqXDphi1Mi8pB SVjm6eLewVahuEne/JsChcZbSfTQrCKBFQGQpE+bfry9ikMitra8PoAFeM6m+BVJU5yu KSId3ab1oeXd/rXXZ+WAjRaH8rjw+kmJxX45c95PWgyHNyKm3gDbFTqjJVMlilM7NPaf gc+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QWYNS0Io; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id tc17-20020a1709078d1100b009311b97abe3si936594ejc.112.2023.04.06.03.35.35; Thu, 06 Apr 2023 03:36:00 -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=@kernel.org header.s=k20201202 header.b=QWYNS0Io; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236962AbjDFK0X (ORCPT + 99 others); Thu, 6 Apr 2023 06:26:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235604AbjDFK0V (ORCPT ); Thu, 6 Apr 2023 06:26:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53BC21713; Thu, 6 Apr 2023 03:26:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D5DB3642B5; Thu, 6 Apr 2023 10:26:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECB72C433D2; Thu, 6 Apr 2023 10:26:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680776779; bh=yVOn8o+5hTtwRbr8XWL47ZWTuN1kQFTfBsh5tqfXXsQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QWYNS0Io9NTLz6QIIXU25HZjd2/sgvoDoIrhLx/Yz50kimlZLKl7PXdLTeRCF0E+F TTLD39rqPrNIE5+pZd8q1vXeULBayb9zSJbktxLOl/65+bAcfLNlTCkGBqHMrJaMwc KUc7zYbWYouSEJKxP5Sh2yWpPuLjnyRRJ30d4suhCC/CiMiHFAynVIIVf/UUWWPQ4i XYBdhcocsdcpgZGnu2YYh3FhbABlkQX3a/UxiH+1AAtce8afGlPO/ekJSSfOYld9Ml S8giSIw0VqfkGjV9gnpZf0KtdAdBVHyXkut8KomvYWM1D2yX/s9riOcAWU7ALSjpkP lg0/Q0/5zKwQw== Date: Thu, 6 Apr 2023 12:26:13 +0200 From: Christian Brauner To: Stefan Berger 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 Subject: Re: [PATCH] overlayfs: Trigger file re-evaluation by IMA / EVM after writes Message-ID: <20230406-diffamieren-langhaarig-87511897e77d@brauner> References: <20230405171449.4064321-1-stefanb@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230405171449.4064321-1-stefanb@linux.ibm.com> X-Spam-Status: No, score=-5.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,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 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?