From b85a0d749ba062a0bba6ac8b1569d958923b3306 Mon Sep 17 00:00:00 2001 From: Hui Peng Date: Sat, 19 Sep 2026 20:48:08 +0000 Subject: [PATCH] autofs: fix sbi->pipe file reference leak in autofs_kill_sb() [ Upstream commit aa5e44b29ffe4eaa08cc2237fd65bc2596bc023e ] 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(). Backported to OpenCloudOS linux-6.6/devel (base v6.6.119) from stable 6.6.y commit a58593b501b7 (v6.6.158). fs/autofs/inode.c on this branch is identical to v6.6.119, so the upstream patch applies verbatim. Conflict: none Fixes: ebc921ca9b92 ("autofs: copy autofs4 to autofs") Signed-off-by: Hui Peng Link: https://patch.msgid.link/20260919204808.2812930-1-benquike@gmail.com Signed-off-by: Christian Brauner (Amutable) Signed-off-by: Sasha Levin Signed-off-by: muzimu217 <1278844978@qq.com> --- fs/autofs/inode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index 2b49662ed237..8b2c056ea7c2 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -50,6 +50,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); } -- Gitee