From nobody Sun Feb 8 18:39:18 2026 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32B2932D425 for ; Fri, 14 Nov 2025 15:53:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763135599; cv=none; b=GAI4ofr265rm++9ARCczE4FoURoExYWNAcghjRq5f+LcJcS6s7ve8jqDuTbS1j0K0TqqcbvmbEi6ck2UT8qw5454TaGqMuyt/qJI3Gfz57fDu3Wu4kgZXtCscZGkriBNonzP5RaE6EjebEmIJX/9sbS6VV+S+IJpzAWp3NOQo2Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763135599; c=relaxed/simple; bh=8WRpsZt54Mswfz2xCcSPYYNBrsqaK3aNc9iH26/F+kU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=s1flUI5AcnM/ywP1e3yUUWZ33Dz1tgNw78QfGfmz407A1C03XhR88PpII04QqmTKbJS5GG93pHPuA7LXxnh+3gjBbnHbYr2k9ILbVM59aiYfqcefZ8XlAomFgB2Rr1jMqpe/BECGHE94Cs2cqpPyAL6NWZqu6uGUov+XpJQQ274= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XnNqWYSc; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XnNqWYSc" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-4775c4197e1so957915e9.0 for ; Fri, 14 Nov 2025 07:53:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763135594; x=1763740394; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Q8KPdQqhauc0N5/k7s1UlzxI59hwfKTHWBoWJzJ2Gqo=; b=XnNqWYScJ8m1xV/cI396DbMRPuygqN0j2c4tApMhcwo16wdSHnq9qo5jzwOf2rhWJu aGme5SVlqAdkva3aFQHtlkA2MadnFbyOsZwUgGhPY0CoRcCv4OAzARF/1YahueVkRZUK 5AWSKuoM4oEqgiPbGlag4/c3pY+iSQQYTrjZO4xnikG5s1/DySCEU8oaXMfcg2eYCAQl Vlv9ZJXpkJU4cZOkE4IfvyNQL7VS+2Jw7WR4DIAG/ptpTWkp8jxaXjruFH5GWCGJ14mn 1AeSNWpE3sUrUqw8HqaY36PDsk6H/+OJTrtET+67ryakpLi0bdMNWCUaoTl6zQBAnTO8 pbJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763135594; x=1763740394; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Q8KPdQqhauc0N5/k7s1UlzxI59hwfKTHWBoWJzJ2Gqo=; b=jyOrq073Tc4Z7WTu912pd1EAN98sou7Is76miV6npGLYYmnAIe5U7DM1XpD+rMdFj9 7E4Yrn61p1rMedFvjxlHBwWCDCPGsjKNNBWOfHqz1AbQOS2vQ5DG/fLVXNk94JC8GIg7 iaQy/lPvAlVwIVnbs10LYoWQeKJ3Lx6qIgV8EIgx+3qDQ5IYEBeJ15EFqm3++YRn5+HM IYQGPc9yjA1G5SfgWKC14ieCQowpCxLPwYlr6RXwN/0H88BvFGj7DRpa3dz98M2mDtW+ elXuGCtwHs6uyd1wEcGInSzZN5RjSD1gu+gk3dzRIdPb3wgqazOLiwYQhKdPXf3zY8rC xwFg== X-Forwarded-Encrypted: i=1; AJvYcCVsFwAAiahWaXyuar+6QlorCyPXyING+Z2Bp8LJZkwU8tKNJEChw3JPnYpLWVHe+t7tesJT68NLEqp4huk=@vger.kernel.org X-Gm-Message-State: AOJu0YwK5WsbOAR3TpC0MPKJPPl3iZGWuNotHRo5CWcxBPN3v8LlrHR+ dVyUGssnM7tfbBvUFQR5KS2fA46zcRHAWau/LGCxtET3lcKF1qwdtjXv X-Gm-Gg: ASbGncu6y9dYj9NQjQAYMxDAPoMwEKHVG8sLO4nfLC9B2R0J1OCVh9mmgV9j4Dh1cZy mL2ejpTX2q5/9hWiNJhB7mRR8m5WvjqeODoPApawi1CYiUSq6IoVZqu+mXrHRG7smxlix6dR2zH RbP61+awgIwRgl0o6QAwv7jEqYd3Mrry4KNUxMcNfrnfPreJbzCA/nc9GXjx65/WIhC5owRTP+W AzPwJ8uyrM3Q+7dVFI4fqgseK6Ilu0XauAHbJSSreFqrdM/bMxByQZb8zkXRNCuu07w8TEJAni9 BR2KtFAwxf3OH4CNUcl0g//FyG5qONHccBhm2V8bNmh8M3wMY7ySqdc1aKFgtmJtOL1qa5vBq+5 fSXrFDeYJIzgndeL5BlCqVCv/KWx+vriqNmaVAQs1lAYkP0BcjItvZC338t464rVhcH3Q3tOLYM JCLFKVGA== X-Google-Smtp-Source: AGHT+IGT1RDAkilt8ulv0yMxWgpeZ6pkOqR1nVxwseskZoLEsxMf89IT/uT00v+JdAbcSlztK4/FBw== X-Received: by 2002:a05:600c:4e8a:b0:477:555b:3411 with SMTP id 5b1f17b1804b1-477902367d2mr16058075e9.1.1763135594359; Fri, 14 Nov 2025 07:53:14 -0800 (PST) Received: from bhk ([196.239.132.233]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47795751d08sm8972205e9.7.2025.11.14.07.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Nov 2025 07:53:13 -0800 (PST) From: Mehdi Ben Hadj Khelifa To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, syzbot+ad45f827c88778ff7df6@syzkaller.appspotmail.com Cc: frank.li@vivo.com, glaubitz@physik.fu-berlin.de, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, slava@dubeyko.com, syzkaller-bugs@googlegroups.com, skhan@linuxfoundation.org, david.hunter.linux@gmail.com, khalid@kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Mehdi Ben Hadj Khelifa Subject: [PATCH] fs/super: fix memory leak of s_fs_info on setup_bdev_super failure Date: Fri, 14 Nov 2025 17:52:27 +0100 Message-ID: <20251114165255.101361-1-mehdi.benhadjkhelifa@gmail.com> X-Mailer: git-send-email 2.51.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Failure in setup_bdev_super() triggers an error path where fc->s_fs_info ownership has already been transferred to the superblock via sget_fc() call in get_tree_bdev_flags() and calling put_fs_context() in do_new_mount() to free the s_fs_info for the specific filesystem gets passed in a NULL pointer. Pass back the ownership of the s_fs_info pointer to the filesystem context once the error path has been triggered to be cleaned up gracefully in put_fs_context(). Fixes: cb50b348c71f ("convenience helpers: vfs_get_super() and sget_fc()") Reported-by: syzbot+ad45f827c88778ff7df6@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3Dad45f827c88778ff7df6 Signed-off-by: Mehdi Ben Hadj Khelifa --- Note:This patch might need some more testing as I only did run selftests=20 with no regression, check dmesg output for no regression, run reproducer=20 with no bug. fs/super.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/super.c b/fs/super.c index 5bab94fb7e03..8fadf97fcc42 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1690,6 +1690,11 @@ int get_tree_bdev_flags(struct fs_context *fc, if (!error) error =3D fill_super(s, fc); if (error) { + /* + * return s_fs_info ownership to fc to be cleaned up by put_fs_context() + */ + fc->s_fs_info =3D s->s_fs_info; + s->s_fs_info =3D NULL; deactivate_locked_super(s); return error; } --=20 2.51.2