Message ID | 20221013223654.659758-4-keescook@chromium.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp510926wrs; Thu, 13 Oct 2022 15:40:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4EXTWuR1LHA86uDurBBshZIkhbSNb/d0TXkfM3SyZh+OXbTNsjKC85Ip/7lDnyPDx4zBf8 X-Received: by 2002:a17:906:cc16:b0:78d:ce93:f5af with SMTP id ml22-20020a170906cc1600b0078dce93f5afmr1348202ejb.592.1665700827275; Thu, 13 Oct 2022 15:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665700827; cv=none; d=google.com; s=arc-20160816; b=xcKysuUZvp/tZEM6wylWEWhMZ8JXetMxb4HP1JoNd38FUq/PKTVSWMvhZWamL7ITZ/ VUDvFSch/CY2JWxeFYWOGEba/05E9OyI+Lh5Mk17LPDqdRZ5Voi4jrXypQBwmZcrJjlm Dcwrx03bccKM2AmfZsqYxg3YjpUxZOIklUgQPYFjlWwdR3swO3F+umFGGgmDukBQiM05 6I/DZIUw7MUQmKWZAUxNVNAZNQd/abq0OHn6OsbT77AdKuUmehaHSpXbiS18oC2Ondnx 8cbhUbTEa44GKZAJVRvtXOFEYFjB7j+rASErclQXYdKKRAwRyTb0HXIQaQI+tcU5dTMj fOng== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RwwHIW9ubgGCNZI9bpt1owrfiGZeXb5wwl1H6trWtBY=; b=StxowNsArajBahQi05HycZxQ4tQXT5ti3rlSZeDJRPD+cdk/w/DSfo8Egml3J/AYj6 Ee4rjVI7/eL5Xscc2QKpmBPgsz16vMi/tZdRcK1R1hTxPlakOVsxufIbvjMI8I0CfXxh KgL2S6RFYxf3TevtpUUxn6F9H9cJQaiDimHtsWKD2aaVqrLlhSTxicBgo7PZwQHaM2Le lIhqctIknSi8R9QceSnU0kKEg1a8EcRpN0xmypa+ZpoYhRs5jejSVYYj4ybpcZ3N9wIp l5IHpIpfNIkkdYlFOb15YhTDI+BDQtKUqezQchqGuEXomfKT06FS28apGKkCvs3G43/R YcSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NPbuugns; 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=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x66-20020a50bac8000000b00445e20bc95bsi703643ede.428.2022.10.13.15.40.02; Thu, 13 Oct 2022 15:40:27 -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=@chromium.org header.s=google header.b=NPbuugns; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229811AbiJMWhY (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Thu, 13 Oct 2022 18:37:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229749AbiJMWhF (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 13 Oct 2022 18:37:05 -0400 Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0531EC098E for <linux-kernel@vger.kernel.org>; Thu, 13 Oct 2022 15:37:00 -0700 (PDT) Received: by mail-pf1-x429.google.com with SMTP id 204so3209904pfx.10 for <linux-kernel@vger.kernel.org>; Thu, 13 Oct 2022 15:37:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RwwHIW9ubgGCNZI9bpt1owrfiGZeXb5wwl1H6trWtBY=; b=NPbuugnsa8ZjJmuKOsOOSrzjod1kIYqRgRjmTGaTWJUUqeqq4o26Thx5EwcjH8ntOg 2FXLuaMoSoMJWiLmgy0LqmQpFgBGbd/D2jky5NbREy2VZpMXlHQhUgKFk4GR4LHv+2Yh AhE40vgIjDEMlzjYgT0H7Xngnyh4qql/BXqpA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RwwHIW9ubgGCNZI9bpt1owrfiGZeXb5wwl1H6trWtBY=; b=qwxB0HSlAkf7nj/dqcgLXptAm3AWsTXNQmrGsGZ0jjUadAzdb9PCDygag3GU1mh7t+ KXk1g1949YY20PSf0U9NGBtTtGwZYKaKvwwPIc43g+B5AnBluAVUSpe0/5Yy0aPMpkU5 GwYiuVV6k/YOqWTYRG4k6VsaQP6eRkxAO0hHcaNTUWfjdgRTnUerz+n239S4OQ5J7HzL LkFEoc+zDM1G7Y2h+3bXL+WSN+Z+3E6PFUmUPIVHJ9P/h0TNsfkeaVEC9B+bEj0XjJUq 2So3jCrL+glW4G3PAqNgB0lCejLqvm/Tp7QCKs7kcvunrJDInx6Vkj7Dv+e1sUeKpLZO HHcQ== X-Gm-Message-State: ACrzQf1bH5taVnHaj6nPTNZ4vWHmP9Q1GEr9AvDmovivm18RLdv5WeSe BwaMTYeUvGQQ4K9DfLqpuf2+lQ== X-Received: by 2002:a63:4753:0:b0:462:b3f0:a984 with SMTP id w19-20020a634753000000b00462b3f0a984mr1760357pgk.501.1665700619583; Thu, 13 Oct 2022 15:36:59 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id a6-20020a170902710600b0016d773aae60sm363047pll.19.2022.10.13.15.36.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 15:36:56 -0700 (PDT) From: Kees Cook <keescook@chromium.org> To: Mimi Zohar <zohar@linux.ibm.com> Cc: Kees Cook <keescook@chromium.org>, Dmitry Kasatkin <dmitry.kasatkin@gmail.com>, Paul Moore <paul@paul-moore.com>, James Morris <jmorris@namei.org>, "Serge E. Hallyn" <serge@hallyn.com>, Petr Vorel <pvorel@suse.cz>, Jonathan McDowell <noodles@fb.com>, Borislav Petkov <bp@suse.de>, Takashi Iwai <tiwai@suse.de>, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= <mic@digikod.net>, KP Singh <kpsingh@kernel.org>, Casey Schaufler <casey@schaufler-ca.com>, John Johansen <john.johansen@canonical.com>, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH 4/9] ima: Move ima_file_free() into LSM Date: Thu, 13 Oct 2022 15:36:49 -0700 Message-Id: <20221013223654.659758-4-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221013222702.never.990-kees@kernel.org> References: <20221013222702.never.990-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3106; h=from:subject; bh=j7SUgkDxPUE08MqOt4a9Z07kxHXSo2qyUDZKl6O5dvY=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBjSJME98uVBOBVBjxVK8UcpHvXl8yakzz5L2nvmUUm /7U1ct+JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCY0iTBAAKCRCJcvTf3G3AJlXUD/ 9LlocRqLBjy5RTiLduzQ0vovRa//i2jiaWLU4i+ih50alFhDMD02D29Huhx1Bpfkxw3tEd5uirD4Qm woZnL++HqvBws+6hGWHagdC04silwQ+UneqsQ9+EwvYKkgPjAXUf8EqEiroy2E5PW6tvyWQGp7DE04 5fMsRSD1C33QHyVeVM7PoXVrtGzW7ZXZRlq9qLdxpIfMps7lsUPsMQTc2kI0mXBsFDmzmFC+dvs9Kk TBA2b7kANBV4ws5RZBLHQlcNlcorhUbixldb3SD4Igl+MJgA67JGenetiOgFwYTBZT1K73uJbk5yUk WZQc601AOB4dC1ijypfacOlZMsqn3UAybG24Vl3JBK6k9KVLuk//880teg87CIZ3aouwk8oaGFjJCb MGXsSIxvhXFzaDBaD+6ZerRPCd6plADAlHpnOft2dB4URCIbURA0fsBQocvf8yBHNcbIDACPNQ+vsD o2HdBbh3bSEvxx+IZz7MNSOJtcgg19X9ybRdJ2DWUahXj4tAVcVFScJ9Y59q3grUFY4qHgtvQuDUsV VXEVwWI71XFXuUiZWOk3URctGgJ8R6g+ke4PyNtO7Os8N9dDI8SUiFqBidQyChnIfDZLrBJ3kZBTvq Fucu8VZ0mHiRAoMrfyl5lQR9vABa7Kxyt11ZCZCO9fEMV4YrarDv6b7dG5ZA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746613910866917886?= X-GMAIL-MSGID: =?utf-8?q?1746613910866917886?= |
Series |
integrity: Move hooks into LSM
|
|
Commit Message
Kees Cook
Oct. 13, 2022, 10:36 p.m. UTC
The file_free_security hook already exists for managing notification of
released files. Use the LSM hook instead of open-coded stacking.
Cc: Mimi Zohar <zohar@linux.ibm.com>
Cc: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
Cc: Paul Moore <paul@paul-moore.com>
Cc: James Morris <jmorris@namei.org>
Cc: "Serge E. Hallyn" <serge@hallyn.com>
Cc: Petr Vorel <pvorel@suse.cz>
Cc: Jonathan McDowell <noodles@fb.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: linux-integrity@vger.kernel.org
Cc: linux-security-module@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
fs/file_table.c | 1 -
include/linux/ima.h | 6 ------
security/integrity/ima/ima_main.c | 3 ++-
3 files changed, 2 insertions(+), 8 deletions(-)
Comments
On Thu, Oct 13, 2022 at 03:36:49PM -0700, Kees Cook wrote: > The file_free_security hook already exists for managing notification of > released files. Use the LSM hook instead of open-coded stacking. > > Cc: Mimi Zohar <zohar@linux.ibm.com> > Cc: Dmitry Kasatkin <dmitry.kasatkin@gmail.com> > Cc: Paul Moore <paul@paul-moore.com> > Cc: James Morris <jmorris@namei.org> > Cc: "Serge E. Hallyn" <serge@hallyn.com> > Cc: Petr Vorel <pvorel@suse.cz> > Cc: Jonathan McDowell <noodles@fb.com> > Cc: Borislav Petkov <bp@suse.de> > Cc: Takashi Iwai <tiwai@suse.de> > Cc: linux-integrity@vger.kernel.org > Cc: linux-security-module@vger.kernel.org > Signed-off-by: Kees Cook <keescook@chromium.org> > --- > fs/file_table.c | 1 - > include/linux/ima.h | 6 ------ > security/integrity/ima/ima_main.c | 3 ++- > 3 files changed, 2 insertions(+), 8 deletions(-) > > diff --git a/fs/file_table.c b/fs/file_table.c > index 99c6796c9f28..fa707d221a43 100644 > --- a/fs/file_table.c > +++ b/fs/file_table.c > @@ -311,7 +311,6 @@ static void __fput(struct file *file) > eventpoll_release(file); > locks_remove_file(file); > > - ima_file_free(file); > if (unlikely(file->f_flags & FASYNC)) { > if (file->f_op->fasync) > file->f_op->fasync(-1, file, 0); > diff --git a/include/linux/ima.h b/include/linux/ima.h > index 6dc5143f89f2..9f18df366064 100644 > --- a/include/linux/ima.h > +++ b/include/linux/ima.h > @@ -19,7 +19,6 @@ extern enum hash_algo ima_get_current_hash_algo(void); > extern int ima_file_check(struct file *file, int mask); > extern void ima_post_create_tmpfile(struct user_namespace *mnt_userns, > struct inode *inode); > -extern void ima_file_free(struct file *file); > extern void ima_post_path_mknod(struct user_namespace *mnt_userns, > struct dentry *dentry); > extern int ima_file_hash(struct file *file, char *buf, size_t buf_size); > @@ -56,11 +55,6 @@ static inline void ima_post_create_tmpfile(struct user_namespace *mnt_userns, > { > } > > -static inline void ima_file_free(struct file *file) > -{ > - return; > -} > - > static inline void ima_post_path_mknod(struct user_namespace *mnt_userns, > struct dentry *dentry) > { > diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c > index b3b79d030a67..94379ba40b58 100644 > --- a/security/integrity/ima/ima_main.c > +++ b/security/integrity/ima/ima_main.c > @@ -183,7 +183,7 @@ static void ima_check_last_writer(struct integrity_iint_cache *iint, > * > * Flag files that changed, based on i_version > */ > -void ima_file_free(struct file *file) > +static void ima_file_free(struct file *file) > { > struct inode *inode = file_inode(file); > struct integrity_iint_cache *iint; > @@ -1085,6 +1085,7 @@ static struct security_hook_list ima_hooks[] __lsm_ro_after_init = { > LSM_HOOK_INIT(bprm_check_security, ima_bprm_check), > LSM_HOOK_INIT(mmap_file, ima_file_mmap), > LSM_HOOK_INIT(file_mprotect, ima_file_mprotect), > + LSM_HOOK_INIT(file_free_security, ima_file_free), This doesn't work afaict. If the file is opened for writing ima may update xattrs. But by the time security_file_free() is called put_file_access() has already been called which will have given up write access to the file's mount. So you would have to - just one of the possibilities - have to move security_file_free() out of file_free() and into the old ima_file_free() location. But that might cause semantic changes for other LSMs.
On Tue, 2022-10-18 at 17:02 +0200, Christian Brauner wrote: > On Thu, Oct 13, 2022 at 03:36:49PM -0700, Kees Cook wrote: > > The file_free_security hook already exists for managing > > notification of > > released files. Use the LSM hook instead of open-coded stacking. > > > > Cc: Mimi Zohar <zohar@linux.ibm.com> > > Cc: Dmitry Kasatkin <dmitry.kasatkin@gmail.com> > > Cc: Paul Moore <paul@paul-moore.com> > > Cc: James Morris <jmorris@namei.org> > > Cc: "Serge E. Hallyn" <serge@hallyn.com> > > Cc: Petr Vorel <pvorel@suse.cz> > > Cc: Jonathan McDowell <noodles@fb.com> > > Cc: Borislav Petkov <bp@suse.de> > > Cc: Takashi Iwai <tiwai@suse.de> > > Cc: linux-integrity@vger.kernel.org > > Cc: linux-security-module@vger.kernel.org > > Signed-off-by: Kees Cook <keescook@chromium.org> > > --- > > fs/file_table.c | 1 - > > include/linux/ima.h | 6 ------ > > security/integrity/ima/ima_main.c | 3 ++- > > 3 files changed, 2 insertions(+), 8 deletions(-) > > > > diff --git a/fs/file_table.c b/fs/file_table.c > > index 99c6796c9f28..fa707d221a43 100644 > > --- a/fs/file_table.c > > +++ b/fs/file_table.c > > @@ -311,7 +311,6 @@ static void __fput(struct file *file) > > eventpoll_release(file); > > locks_remove_file(file); > > > > - ima_file_free(file); > > if (unlikely(file->f_flags & FASYNC)) { > > if (file->f_op->fasync) > > file->f_op->fasync(-1, file, 0); > > diff --git a/include/linux/ima.h b/include/linux/ima.h > > index 6dc5143f89f2..9f18df366064 100644 > > --- a/include/linux/ima.h > > +++ b/include/linux/ima.h > > @@ -19,7 +19,6 @@ extern enum hash_algo > > ima_get_current_hash_algo(void); > > extern int ima_file_check(struct file *file, int mask); > > extern void ima_post_create_tmpfile(struct user_namespace > > *mnt_userns, > > struct inode *inode); > > -extern void ima_file_free(struct file *file); > > extern void ima_post_path_mknod(struct user_namespace *mnt_userns, > > struct dentry *dentry); > > extern int ima_file_hash(struct file *file, char *buf, size_t > > buf_size); > > @@ -56,11 +55,6 @@ static inline void > > ima_post_create_tmpfile(struct user_namespace *mnt_userns, > > { > > } > > > > -static inline void ima_file_free(struct file *file) > > -{ > > - return; > > -} > > - > > static inline void ima_post_path_mknod(struct user_namespace > > *mnt_userns, > > struct dentry *dentry) > > { > > diff --git a/security/integrity/ima/ima_main.c > > b/security/integrity/ima/ima_main.c > > index b3b79d030a67..94379ba40b58 100644 > > --- a/security/integrity/ima/ima_main.c > > +++ b/security/integrity/ima/ima_main.c > > @@ -183,7 +183,7 @@ static void ima_check_last_writer(struct > > integrity_iint_cache *iint, > > * > > * Flag files that changed, based on i_version > > */ > > -void ima_file_free(struct file *file) > > +static void ima_file_free(struct file *file) > > { > > struct inode *inode = file_inode(file); > > struct integrity_iint_cache *iint; > > @@ -1085,6 +1085,7 @@ static struct security_hook_list ima_hooks[] > > __lsm_ro_after_init = { > > LSM_HOOK_INIT(bprm_check_security, ima_bprm_check), > > LSM_HOOK_INIT(mmap_file, ima_file_mmap), > > LSM_HOOK_INIT(file_mprotect, ima_file_mprotect), > > + LSM_HOOK_INIT(file_free_security, ima_file_free), > > This doesn't work afaict. If the file is opened for writing ima may > update xattrs. But by the time security_file_free() is called > put_file_access() has already been called which will have given up > write > access to the file's mount. > > So you would have to - just one of the possibilities - have to move > security_file_free() out of file_free() and into the old > ima_file_free() > location. But that might cause semantic changes for other LSMs. Hi I also did this work before. In my implementation, I created a new security hook called security_file_pre_free(). https://github.com/robertosassu/linux/commit/692c9d36fff865435b23b3cb765d31f3584f6263 If useful, the whole patch set is available at: https://github.com/robertosassu/linux/commits/ima-evm-lsm-v1-devel-v3 Roberto
On Tue, Oct 18, 2022 at 05:32:40PM +0200, Roberto Sassu wrote: > I also did this work before. In my implementation, I created a new > security hook called security_file_pre_free(). > > https://github.com/robertosassu/linux/commit/692c9d36fff865435b23b3cb765d31f3584f6263 > > If useful, the whole patch set is available at: > > https://github.com/robertosassu/linux/commits/ima-evm-lsm-v1-devel-v3 Ah, lovely! Can you pick this back up and run with it? I mainly did these a proof-of-concept, but it looks like you got further.
On Tue, 2022-10-18 at 11:29 -0700, Kees Cook wrote: > On Tue, Oct 18, 2022 at 05:32:40PM +0200, Roberto Sassu wrote: > > I also did this work before. In my implementation, I created a new > > security hook called security_file_pre_free(). > > > > https://github.com/robertosassu/linux/commit/692c9d36fff865435b23b3cb765d31f3584f6263 > > > > If useful, the whole patch set is available at: > > > > https://github.com/robertosassu/linux/commits/ima-evm-lsm-v1-devel-v3 > > Ah, lovely! Can you pick this back up and run with it? I mainly did > these a proof-of-concept, but it looks like you got further. It was some time ago. If I remember correctly, I got to the point of running IMA/EVM and passing basic tests. Will take a look at your patches and comments, and integrate in mines if something is missing. Will also send again the prerequisite patch set. Roberto
On Wed, Oct 19, 2022 at 2:56 AM Roberto Sassu <roberto.sassu@huaweicloud.com> wrote: > On Tue, 2022-10-18 at 11:29 -0700, Kees Cook wrote: > > On Tue, Oct 18, 2022 at 05:32:40PM +0200, Roberto Sassu wrote: > > > I also did this work before. In my implementation, I created a new > > > security hook called security_file_pre_free(). > > > > > > https://github.com/robertosassu/linux/commit/692c9d36fff865435b23b3cb765d31f3584f6263 > > > > > > If useful, the whole patch set is available at: > > > > > > https://github.com/robertosassu/linux/commits/ima-evm-lsm-v1-devel-v3 > > > > Ah, lovely! Can you pick this back up and run with it? I mainly did > > these a proof-of-concept, but it looks like you got further. > > It was some time ago. If I remember correctly, I got to the point of > running IMA/EVM and passing basic tests. > > Will take a look at your patches and comments, and integrate in mines > if something is missing. > > Will also send again the prerequisite patch set. Thanks Roberto, I appreciate you taking the time to resume your earlier work. I think this will be a nice improvement and help us cleanup a lot of code.
diff --git a/fs/file_table.c b/fs/file_table.c index 99c6796c9f28..fa707d221a43 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -311,7 +311,6 @@ static void __fput(struct file *file) eventpoll_release(file); locks_remove_file(file); - ima_file_free(file); if (unlikely(file->f_flags & FASYNC)) { if (file->f_op->fasync) file->f_op->fasync(-1, file, 0); diff --git a/include/linux/ima.h b/include/linux/ima.h index 6dc5143f89f2..9f18df366064 100644 --- a/include/linux/ima.h +++ b/include/linux/ima.h @@ -19,7 +19,6 @@ extern enum hash_algo ima_get_current_hash_algo(void); extern int ima_file_check(struct file *file, int mask); extern void ima_post_create_tmpfile(struct user_namespace *mnt_userns, struct inode *inode); -extern void ima_file_free(struct file *file); extern void ima_post_path_mknod(struct user_namespace *mnt_userns, struct dentry *dentry); extern int ima_file_hash(struct file *file, char *buf, size_t buf_size); @@ -56,11 +55,6 @@ static inline void ima_post_create_tmpfile(struct user_namespace *mnt_userns, { } -static inline void ima_file_free(struct file *file) -{ - return; -} - static inline void ima_post_path_mknod(struct user_namespace *mnt_userns, struct dentry *dentry) { diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index b3b79d030a67..94379ba40b58 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c @@ -183,7 +183,7 @@ static void ima_check_last_writer(struct integrity_iint_cache *iint, * * Flag files that changed, based on i_version */ -void ima_file_free(struct file *file) +static void ima_file_free(struct file *file) { struct inode *inode = file_inode(file); struct integrity_iint_cache *iint; @@ -1085,6 +1085,7 @@ static struct security_hook_list ima_hooks[] __lsm_ro_after_init = { LSM_HOOK_INIT(bprm_check_security, ima_bprm_check), LSM_HOOK_INIT(mmap_file, ima_file_mmap), LSM_HOOK_INIT(file_mprotect, ima_file_mprotect), + LSM_HOOK_INIT(file_free_security, ima_file_free), LSM_HOOK_INIT(kernel_read_file, ima_read_file), LSM_HOOK_INIT(kernel_post_read_file, ima_post_read_file), LSM_HOOK_INIT(kernel_load_data, ima_load_data),