[PATCH 6.6.y] coredump: fix pidfs file refcount leak in umh_coredump_setup
From: Qian Zuo
Date: Mon Jul 06 2026 - 23:46:47 EST
The backport of upstream commit b5325b2a270f introduced a reference
count leak for pidfs_file.
In the upstream implementation, pidfs_file is declared with
__free(fput), which automatically drops the initial file reference when
leaving the scope. During the backport, the code was rewritten to manage
the file pointer manually, but after a successful replace_fd(),
pidfs_file was simply cleared without dropping the initial reference.
As a result, the pidfs file keeps an extra reference and is never
released after the usermode helper exits, leaving associated objects,
such as struct pid, permanently allocated and triggering kmemleak
reports.
Fix this by explicitly calling fput(pidfs_file) after replace_fd().
Fixes: cdb61a705f5f ("coredump: hand a pidfd to the usermode coredump helper")
Signed-off-by: Qian Zuo <zuoqian113@xxxxxxxxx>
---
fs/coredump.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/coredump.c b/fs/coredump.c
index d3a4f5dc2..2f1f66f42 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -560,6 +560,7 @@ static int umh_coredump_setup(struct subprocess_info *info, struct cred *new)
if (err < 0)
goto out_fail;
+ fput(pidfs_file);
pidfs_file = NULL;
}
--
2.43.0