Linux filesystem development
 help / color / mirror / Atom feed
* [PATCH] autofs: fix sbi->pipe file reference leak in autofs_kill_sb()
@ 2026-09-19 20:48 Hui Peng
  2026-09-25 14:51 ` Christian Brauner
  0 siblings, 1 reply; 2+ messages in thread
From: Hui Peng @ 2026-09-19 20:48 UTC (permalink / raw)
  To: Ian Kent; +Cc: autofs, linux-fsdevel, linux-kernel

When autofs_fill_super() fails before clearing AUTOFS_SBI_CATATONIC (for
example, when find_get_pid() fails on an invalid pgrp mount option, or
when an fs_context is closed before mounting), deactivate_locked_super()
invokes autofs_kill_sb() -> autofs_catatonic_mode(sbi).

Because AUTOFS_SBI_CATATONIC is still set in sbi->flags,
autofs_catatonic_mode() returns early without calling fput(sbi->pipe),
permanently leaking the pipe struct file reference.

Explicitly release sbi->pipe in autofs_kill_sb() if it is still non-NULL
after autofs_catatonic_mode().

Fixes: ebc921ca9b92 ("autofs: copy autofs4 to autofs")
Assisted-by: LLM
Signed-off-by: Hui Peng <benquike@gmail.com>
---
diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c
--- a/fs/autofs/inode.c
+++ b/fs/autofs/inode.c
@@ -51,6 +51,10 @@ void autofs_kill_sb(struct super_block *sb)
 	if (sbi) {
 		/* Free wait queues, close pipe */
 		autofs_catatonic_mode(sbi);
+		if (sbi->pipe) {
+			fput(sbi->pipe);
+			sbi->pipe = NULL;
+		}
 		put_pid(sbi->oz_pgrp);
 	}
 
-- 
2.43.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] autofs: fix sbi->pipe file reference leak in autofs_kill_sb()
  2026-09-19 20:48 [PATCH] autofs: fix sbi->pipe file reference leak in autofs_kill_sb() Hui Peng
@ 2026-09-25 14:51 ` Christian Brauner
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Brauner @ 2026-09-25 14:51 UTC (permalink / raw)
  To: Ian Kent, Hui Peng; +Cc: autofs, linux-fsdevel, linux-kernel

On Sat, 19 Sep 2026 20:48:08 +0000, Hui Peng wrote:
> autofs: fix sbi->pipe file reference leak in autofs_kill_sb()

Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes

[1/1] autofs: fix sbi->pipe file reference leak in autofs_kill_sb()
      https://git.kernel.org/vfs/vfs/c/aa5e44b29ffe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-25 14:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-19 20:48 [PATCH] autofs: fix sbi->pipe file reference leak in autofs_kill_sb() Hui Peng
2026-09-25 14:51 ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox