From nobody Sun Dec 14 06:36:31 2025 Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) (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 7421D25F98B for ; Wed, 10 Dec 2025 13:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765371641; cv=none; b=RqJP0/qWd8BUhpu/jeZ17VUki8PfoSeoQ5SlVFRJLLHyEt1pVIwERj0NbSwJLEswPUZLV48+orbuvO2eIxMQr+G+qfbGinMF+V4WEm7nPA0pgyww5EiS55uzcLiPfmO4KsQLfRjqo76ZuRwDWiUD9sxXeD3L6XGgyc5mwwDx90Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765371641; c=relaxed/simple; bh=v+PiFPB5tDw+5CfA/EJVDNbFpbXivUdafVEQ3+G5lqo=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=tRf/SPT7WyEcMrU4MkeNm+4rw+TDQN5OKwl+EHJ/mTj6xFQArQ2n1XcSbz1Nnj2yhk1FArGniQndoBBW2KUy15uX4cL6obNeAzpymyvhkBDcGecPac4pS2oytv92opTGi4kbebq7pm0XyMGSm8TGXsBWCQlFO/v6KP/9X1lxcsY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.167.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oi1-f198.google.com with SMTP id 5614622812f47-450fd003480so9417676b6e.2 for ; Wed, 10 Dec 2025 05:00:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765371638; x=1765976438; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vXcqBjHSI+2WeVTqHVeH9q/k9OaXV477Zh705YVr8DE=; b=NxIy8lJcdCGZN7fLCadASFzVj/m+ICKxoz1yavKSIbQJmo+np/Z1bRfcRbIOd5q0kn i51DIrFy1hYBNrHFsgB66/LDxOqpSrz8ME8IkfadVkMwCTI2QkRIomgJWX6jGuhhhmC6 XvRCcerQCbw3E3f8D2KiKGhAJsrKhizeaW0ChJro4GskttNFgG4ZzKv/E4wTz+6eO4GU 0BLPeGGr21Z2PCVPAJfHXS60aMRLyVUHhiB6Ma6sHIPxg8rO0CnShCYTm/ag6HwRHslT BpG6d2ShjwrsgrTTpUvYdrGcxO1wlVAfYYwQqFrY72yxkKW6AjnUw26IEl79w+of0eeS J2Mg== X-Gm-Message-State: AOJu0YzQWlLmRFLDXlTvCnJ8fU7/oql7odmOUjFI6PDcX3cBydPSq3w3 1DIRMCJLHOLQGWylTOyS1AGlyeK8IS4CxGFu8jlmyIOtbGTYMbWcrup87Ll98s0Cj81YyCFWmrV +5SslJZ+HJtmN6RtV/55igiR1YhHKV+WcWPBe2b8/w4Jvgjaj0LSDdGxujBA= X-Google-Smtp-Source: AGHT+IEm/yoq8YV0c+mJu5crrbhiBX1IMzeZYIAIcL7l2BYtRFx/c+mISP8uJ/SsslVluiCwmCS8RXw8aAfhHeRgDgHOzBf/AL+t Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:c8c:b0:659:9a49:9048 with SMTP id 006d021491bc7-65b2ac1cfc1mr1486015eaf.19.1765371638518; Wed, 10 Dec 2025 05:00:38 -0800 (PST) Date: Wed, 10 Dec 2025 05:00:38 -0800 In-Reply-To: <69369331.a70a0220.38f243.009e.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69396ef6.a70a0220.33cd7b.000c.GAE@google.com> Subject: Forwarded: [PATCH] btrfs: fix memory leak of fs_devices in degraded seed device path From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] btrfs: fix memory leak of fs_devices in degraded seed devi= ce path Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= master In open_seed_devices(), when find_fsid() fails and we're in DEGRADED mode, a new fs_devices is allocated via alloc_fs_devices() but is never added to the seed_list before returning. This contrasts with the normal path where fs_devices is properly added via list_add(). If any error occurs later in read_one_dev() or btrfs_read_chunk_tree(), the cleanup code iterates seed_list to free seed devices, but this orphaned fs_devices is never found and never freed, causing a memory leak. Any devices allocated via add_missing_dev() and attached to this fs_devices are also leaked. Fix this by adding the newly allocated fs_devices to seed_list in the degraded path, consistent with the normal path. Fixes: 7239ff4b6f5b ("btrfs: handle missing seed devices when starting degr= aded") Reported-by: syzbot+eadd98df8bceb15d7fed@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3Deadd98df8bceb15d7fed Signed-off-by: Deepanshu Kartikey --- fs/btrfs/volumes.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index ae1742a35e76..13c514684cfb 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -7128,6 +7128,7 @@ static struct btrfs_fs_devices *open_seed_devices(str= uct btrfs_fs_info *fs_info, =20 fs_devices->seeding =3D true; fs_devices->opened =3D 1; + list_add(&fs_devices->seed_list, &fs_info->fs_devices->seed_list); return fs_devices; } =20 --=20 2.43.0