* [PATCH] fsverity: add missing fsverity_free_info()
@ 2026-02-02 21:43 Eric Biggers
2026-02-03 5:32 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Eric Biggers @ 2026-02-02 21:43 UTC (permalink / raw)
To: fsverity
Cc: linux-fsdevel, Christoph Hellwig, Theodore Ts'o, Eric Biggers
If fsverity_set_info() fails, we need to call fsverity_free_info().
Fixes: ada3a1a48d5a ("fsverity: use a hashtable to find the fsverity_info")
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
fs/verity/enable.c | 4 +++-
fs/verity/fsverity_private.h | 1 +
fs/verity/open.c | 14 +++++++-------
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/fs/verity/enable.c b/fs/verity/enable.c
index 94c88c419054c..c9448074cce17 100644
--- a/fs/verity/enable.c
+++ b/fs/verity/enable.c
@@ -272,12 +272,14 @@ static int enable_verity(struct file *filp,
* the fsverity_info always first checks the S_VERITY flag on the inode,
* which will only be set at the very end of the ->end_enable_verity
* method.
*/
err = fsverity_set_info(vi);
- if (err)
+ if (err) {
+ fsverity_free_info(vi);
goto rollback;
+ }
/*
* Tell the filesystem to finish enabling verity on the file.
* Serialized with ->begin_enable_verity() by the inode lock. The file
* system needs to set the S_VERITY flag on the inode at the very end of
diff --git a/fs/verity/fsverity_private.h b/fs/verity/fsverity_private.h
index 4d4a0a560562b..2887cb849ceca 100644
--- a/fs/verity/fsverity_private.h
+++ b/fs/verity/fsverity_private.h
@@ -128,10 +128,11 @@ int fsverity_init_merkle_tree_params(struct merkle_tree_params *params,
struct fsverity_info *fsverity_create_info(struct inode *inode,
struct fsverity_descriptor *desc);
int fsverity_set_info(struct fsverity_info *vi);
+void fsverity_free_info(struct fsverity_info *vi);
void fsverity_remove_info(struct fsverity_info *vi);
int fsverity_get_descriptor(struct inode *inode,
struct fsverity_descriptor **desc_ret);
diff --git a/fs/verity/open.c b/fs/verity/open.c
index 04b2e05a95d73..dfa0d1afe0feb 100644
--- a/fs/verity/open.c
+++ b/fs/verity/open.c
@@ -176,17 +176,10 @@ static void compute_file_digest(const struct fsverity_hash_alg *hash_alg,
desc->sig_size = 0;
fsverity_hash_buffer(hash_alg, desc, sizeof(*desc), file_digest);
desc->sig_size = sig_size;
}
-static void fsverity_free_info(struct fsverity_info *vi)
-{
- kfree(vi->tree_params.hashstate);
- kvfree(vi->hash_block_verified);
- kmem_cache_free(fsverity_info_cachep, vi);
-}
-
/*
* Create a new fsverity_info from the given fsverity_descriptor (with optional
* appended builtin signature), and check the signature if present. The
* fsverity_descriptor must have already undergone basic validation.
*/
@@ -394,10 +387,17 @@ int __fsverity_file_open(struct inode *inode, struct file *filp)
return -EPERM;
return ensure_verity_info(inode);
}
EXPORT_SYMBOL_GPL(__fsverity_file_open);
+void fsverity_free_info(struct fsverity_info *vi)
+{
+ kfree(vi->tree_params.hashstate);
+ kvfree(vi->hash_block_verified);
+ kmem_cache_free(fsverity_info_cachep, vi);
+}
+
void fsverity_remove_info(struct fsverity_info *vi)
{
rhashtable_remove_fast(&fsverity_info_hash, &vi->rhash_head,
fsverity_info_hash_params);
fsverity_free_info(vi);
base-commit: 8866b64d3d59f5c9ac5c1c1e3acc6ebeb730f1c2
--
2.52.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fsverity: add missing fsverity_free_info()
2026-02-02 21:43 [PATCH] fsverity: add missing fsverity_free_info() Eric Biggers
@ 2026-02-03 5:32 ` Christoph Hellwig
2026-02-04 3:33 ` Eric Biggers
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2026-02-03 5:32 UTC (permalink / raw)
To: Eric Biggers
Cc: fsverity, linux-fsdevel, Christoph Hellwig, Theodore Ts'o
On Mon, Feb 02, 2026 at 01:43:06PM -0800, Eric Biggers wrote:
> If fsverity_set_info() fails, we need to call fsverity_free_info().
>
> Fixes: ada3a1a48d5a ("fsverity: use a hashtable to find the fsverity_info")
> Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Looks good. It might make sense to fold into the offending patch to help
with bisectability, though.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fsverity: add missing fsverity_free_info()
2026-02-03 5:32 ` Christoph Hellwig
@ 2026-02-04 3:33 ` Eric Biggers
0 siblings, 0 replies; 3+ messages in thread
From: Eric Biggers @ 2026-02-04 3:33 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: fsverity, linux-fsdevel, Theodore Ts'o
On Tue, Feb 03, 2026 at 06:32:28AM +0100, Christoph Hellwig wrote:
> On Mon, Feb 02, 2026 at 01:43:06PM -0800, Eric Biggers wrote:
> > If fsverity_set_info() fails, we need to call fsverity_free_info().
> >
> > Fixes: ada3a1a48d5a ("fsverity: use a hashtable to find the fsverity_info")
> > Signed-off-by: Eric Biggers <ebiggers@kernel.org>
>
> Looks good. It might make sense to fold into the offending patch to help
> with bisectability, though.
>
I folded it into "fsverity: use a hashtable to find the fsverity_info".
- Eric
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-04 3:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-02 21:43 [PATCH] fsverity: add missing fsverity_free_info() Eric Biggers
2026-02-03 5:32 ` Christoph Hellwig
2026-02-04 3:33 ` Eric Biggers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox