Skip to contentSkip to conversation

coredump: fix pidfs file refcount leak in umh_coredump_setup

PATCH New Qian Zuo 1 participant 1 message Jul 7

Subsystems (2)
lore
Share & tools
lore

Qian Zuo

author
#0 lore raw

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().

Fixes cdb61a705f5f ("coredump: hand a pidfd to the usermode coredump helper")
---
 fs/coredump.c | 1 +
 1 file changed, 1 insertion(+)
fs/coredump.c +1 -0
index d3a4f5dc2..2f1f66f42 100644
@@ -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