From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) (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 05D6939184C for ; Tue, 17 Mar 2026 07:36:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.70 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773733007; cv=none; b=J/RG4/6J1qcwmv60Ohv9gQ6lXZ6BZn1PlrUYq9SfISEyN9vDukP1OeytF8C9iIa2lUx0mPDmN5uzcA/7nRkbt1Am+gmAQzbhgPJPwlpcmG84tSu35IrUUz4f2xMZ1mdQDklQh5UebaWHP7aaaJD+0EKWtXmpkW7Q2N4EKnStY3E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773733007; c=relaxed/simple; bh=89zluwJtnCCqgMwdmCku1z4MzhyftN7AL4h+/CT58pI=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=XR5q8ZqDgJwK5JwCH7jah1iPpgLCEQ7rzoF9enDOPC0MZ1P0R1oTcj4Gf2BldvMFfahXjv5O49zeynja/O0H097Wr4rTbs6npMLV4kwzqhmR0ApZv9wf3pxWIWdxqWL2Xio1qAotxR0cQJZ8JHZvbfgQ4z87nB5OcxOdqqmWeKg= 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.161.70 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-oo1-f70.google.com with SMTP id 006d021491bc7-67bab42bbe3so20459685eaf.1 for ; Tue, 17 Mar 2026 00:36:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773733004; x=1774337804; 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=brI5IT97eYr5FAZVyFnGNSlXinuhVbYZOoSf4pg9kW4=; b=s0cziip3B3tSUh3FeugmngzAvXW+zMXYYn2FmpOkb22Q5ndji8emA8ebML91qWVLLh SXaXq0an8xI/fqQJh00x2NnTqJg48whzOaTbnHKtABTBRRsxAltYnGO/ToKNHn3QB6Xg fHVLYUKfEACN/wgMV1t3ZiYTugbeJ6IQD/9KYTZhwnzQa6oSBNzDfzsiBici/GsEXC5S ubktj+LHXIKjYxSnSf026QaQCGIes0qHAomJ3SdolK360PTNDJsgFERzTKsgLcsHAn/h GdOyEJfrGoQtSQZuedi2rF1VuhJ0h7hOMtJyVGxJmZWDdDxALh3H9Fj+q1pjrG82wWOc 1iXg== X-Gm-Message-State: AOJu0Yzcd+tEF6GcmvuxBjN/jOCZJist0rq/Q++jQnp6HfKvjnKxda+c r+W+166ghfVnF082mW9WMVrbIa/vqKSpnOTAvD00jVEDDK4LV7V2gEJ4C1ZkKOWvrI9bEuWHxU6 onOAnFn9Wg3VG8tYjgfkUxyj+9kESy0HxHCAX8nNJpSCwVu2X/6imXBXe0pg= 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:829:b0:67b:bd6e:61c2 with SMTP id 006d021491bc7-67bda97f55cmr10434346eaf.13.1773733003975; Tue, 17 Mar 2026 00:36:43 -0700 (PDT) Date: Tue, 17 Mar 2026 00:36:43 -0700 In-Reply-To: <69b8c713.a00a0220.3b25d1.0029.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69b9048b.a00a0220.3b25d1.002c.GAE@google.com> Subject: Forwarded: [PATCH] nilfs2: fix uninitialized btree node cache in nilfs_attach_btree_node_cache From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com 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] nilfs2: fix uninitialized btree node cache in nilfs_attach_btree_node_cache Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master When nilfs_attach_btree_node_cache() finds a cached btnc_inode that is not I_NEW, it skips nilfs_init_btnc_inode() leaving the btree node cache in a stale or uninitialized state from a previous failed mount. This causes i_assoc_inode to point to a broken inode, leading to a null-ptr-deref in nilfs_mdt_save_to_shadow_map() when NILFS_IOCTL_CLEAN_SEGMENTS is invoked. Fix this by calling nilfs_init_btnc_inode() for cached btnc inodes as well to ensure proper initialization regardless of inode cache state. Reported-by: syzbot+4b4093b1f24ad789bf37@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=4b4093b1f24ad789bf37 Signed-off-by: Deepanshu Kartikey --- fs/nilfs2/inode.c | 7 +++++++ fs/nilfs2/mdt.c | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index 51bde45d5865..8312abbe343d 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c @@ -631,6 +631,9 @@ int nilfs_attach_btree_node_cache(struct inode *inode) nilfs_iget_set, &args); if (unlikely(!btnc_inode)) return -ENOMEM; + pr_err("NILFS DEBUG btnc: btnc=%px I_NEW=%d\n", + btnc_inode, + !!(inode_state_read_once(btnc_inode) & I_NEW)); if (inode_state_read_once(btnc_inode) & I_NEW) { nilfs_init_btnc_inode(btnc_inode); unlock_new_inode(btnc_inode); @@ -686,6 +689,10 @@ struct inode *nilfs_iget_for_shadow(struct inode *inode) nilfs_iget_set, &args); if (unlikely(!s_inode)) return ERR_PTR(-ENOMEM); + pr_err("NILFS DEBUG: s_inode=%px I_NEW=%d i_assoc=%px\n", + s_inode, + !!(inode_state_read_once(s_inode) & I_NEW), + NILFS_I(s_inode)->i_assoc_inode); if (!(inode_state_read_once(s_inode) & I_NEW)) return inode; diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c index 946b0d3534a5..968a5be834cc 100644 --- a/fs/nilfs2/mdt.c +++ b/fs/nilfs2/mdt.c @@ -551,6 +551,14 @@ int nilfs_mdt_save_to_shadow_map(struct inode *inode) struct inode *s_inode = shadow->inode; int ret; + if (!ii->i_assoc_inode) { + pr_err("NILFS DEBUG: ii->i_assoc_inode is NULL, attaching\n"); + dump_stack(); + ret = nilfs_attach_btree_node_cache(inode); + if (ret) { + pr_err("NILFS: failed to attach btree node cache: %d\n", ret); + } + } ret = nilfs_copy_dirty_pages(s_inode->i_mapping, inode->i_mapping); if (ret) goto out; -- 2.43.0