coredump: fix pidfs file refcount leak in umh_coredump_setup
Subsystems (2)
PATCH 1/1 coredump: fix pidfs file refcount leak in umh_coredump_setup
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().
--- fs/coredump.c | 1 + 1 file changed, 1 insertion(+)
fs/coredump.c +1 -0
@@ -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 ; }
Signature · 1 line
2.43.0