From nobody Fri Dec 19 19:18:03 2025 Received: from mx0b-0064b401.pphosted.com (mx0b-0064b401.pphosted.com [205.220.178.238]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 605C513E02D for ; Thu, 9 Jan 2025 04:29:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.178.238 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736396976; cv=none; b=Z3iumYSj7c9o0UrQBY/4xxKVdyDby2L7s1wGxTema7PdpAQYBPOiqSgsLagmaaqcC8+PHDxBIZGqxOP5UH9g4e1TrCDRHy3gapjyIuZR70lIugs3AmZ6iuw/y/IyQB+4Ut7QMKxd0JmKfy1IYApEQAdqWX+t7NfZa+8Rfh84doQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736396976; c=relaxed/simple; bh=MggFQfe2/AFVIfrk8BtYLZC/t6WUCjfi2DGaLVbBxaE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LMwZHgigbSjVrLgX/li5WcTTH6VUglrhGvbdzYpU4WeWeUsnHgSB0rdKXD7zACoTyETkNdZ0Fw+iudWPX7IztrX+lSXgsKID/PGm/3UIwWAxeoi9B7FLPWDbOKQ8umWGfUH6phbRgztQg+GJNlMHtc+IRXMWzFw9DexJCX9a2yY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=windriver.com; spf=pass smtp.mailfrom=windriver.com; arc=none smtp.client-ip=205.220.178.238 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=windriver.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=windriver.com Received: from pps.filterd (m0250811.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 5092sdkX032645; Thu, 9 Jan 2025 03:49:49 GMT Received: from ala-exchng02.corp.ad.wrs.com (ala-exchng02.wrs.com [147.11.82.254]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 441fv3sb7a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Thu, 09 Jan 2025 03:49:49 +0000 (GMT) Received: from ala-exchng01.corp.ad.wrs.com (147.11.82.252) by ALA-EXCHNG02.corp.ad.wrs.com (147.11.82.254) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.43; Wed, 8 Jan 2025 19:49:48 -0800 Received: from pek-lpd-ccm6.wrs.com (147.11.136.210) by ala-exchng01.corp.ad.wrs.com (147.11.82.252) with Microsoft SMTP Server id 15.1.2507.43 via Frontend Transport; Wed, 8 Jan 2025 19:49:47 -0800 From: Lizhi Xu To: CC: , , Subject: [PATCH] bfs: put a inode if link count is 0 Date: Thu, 9 Jan 2025 11:49:46 +0800 Message-ID: <20250109034946.1386748-1-lizhi.xu@windriver.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <6776b5fb.050a0220.3a8527.0043.GAE@google.com> References: <6776b5fb.050a0220.3a8527.0043.GAE@google.com> 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 X-Proofpoint-GUID: qxZnInW1x0okrkFUgc2O7xPpVGYl2ipd X-Authority-Analysis: v=2.4 cv=NIUv+16g c=1 sm=1 tr=0 ts=677f475d cx=c_pps a=K4BcnWQioVPsTJd46EJO2w==:117 a=K4BcnWQioVPsTJd46EJO2w==:17 a=VdSt8ZQiCzkA:10 a=edf1wS77AAAA:8 a=hSkVLCK3AAAA:8 a=t7CeM3EgAAAA:8 a=kzhpyt5GazuMIt-plYoA:9 a=DcSpbTIhAlouE1Uv7lRv:22 a=cQPPKAXgyycSBL8etih5:22 a=FdTzh2GWekK77mhwV6Dw:22 X-Proofpoint-ORIG-GUID: qxZnInW1x0okrkFUgc2O7xPpVGYl2ipd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-09_01,2025-01-08_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 mlxscore=0 clxscore=1011 malwarescore=0 mlxlogscore=590 phishscore=0 adultscore=0 spamscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.21.0-2411120000 definitions=main-2501090027 Content-Type: text/plain; charset="utf-8" syzbot reported a warning in drop_nlink. [1] The reproducer performs the rename operation on the file twice in succession and changes the file to the same file name. After the first rename operati= on, the number of links in the inode is set to 0. In the second execution, the same inode is used, resulting in a 0 value warning for i_nlink.=20 To avoid this issue, put the target inode before exiting the bfs_rename. [1] WARNING: CPU: 0 PID: 5819 at fs/inode.c:407 drop_nlink+0xc4/0x110 fs/inode.= c:407 Modules linked in: CPU: 0 UID: 0 PID: 5819 Comm: syz-executor232 Not tainted 6.13.0-rc5-syzkal= ler-00161-g63676eefb7a0 #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Goo= gle 09/13/2024 RIP: 0010:drop_nlink+0xc4/0x110 fs/inode.c:407 Code: bb 70 07 00 00 be 08 00 00 00 e8 37 3b e7 ff f0 48 ff 83 70 07 00 00 = 5b 41 5c 41 5e 41 5f 5d c3 cc cc cc cc e8 8d 5b 83 ff 90 <0f> 0b 90 eb 83 4= 4 89 e1 80 e1 07 80 c1 03 38 c1 0f 8c 5c ff ff ff RSP: 0018:ffffc90003c6f950 EFLAGS: 00010293 RAX: ffffffff821c1843 RBX: 1ffff1100e5181f8 RCX: ffff8880351d9e00 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: ffffffff821c17c3 R09: 1ffffffff2030ad6 R10: dffffc0000000000 R11: fffffbfff2030ad7 R12: ffff8880728c0fc0 R13: dffffc0000000000 R14: ffff8880728c0f78 R15: dffffc0000000000 FS: 0000555562096380(0000) GS:ffff8880b8600000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000558ecae7b0d8 CR3: 0000000012a66000 CR4: 00000000003526f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: inode_dec_link_count include/linux/fs.h:2521 [inline] bfs_rename+0x44e/0x530 fs/bfs/dir.c:247 vfs_rename+0xbdb/0xf00 fs/namei.c:5067 do_renameat2+0xd94/0x13f0 fs/namei.c:5224 __do_sys_rename fs/namei.c:5271 [inline] __se_sys_rename fs/namei.c:5269 [inline] __x64_sys_rename+0x82/0x90 fs/namei.c:5269 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83 Reported-by: syzbot+80e60df48923e1b7691d@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D80e60df48923e1b7691d Signed-off-by: Lizhi Xu --- fs/bfs/dir.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c index c375e22c4c0c..3d67e7c5b1fa 100644 --- a/fs/bfs/dir.c +++ b/fs/bfs/dir.c @@ -251,6 +251,8 @@ static int bfs_rename(struct mnt_idmap *idmap, struct i= node *old_dir, =20 end_rename: mutex_unlock(&info->bfs_lock); + if (new_inode && !new_inode->i_nlink) + iput(new_inode); brelse(old_bh); brelse(new_bh); return error; --=20 2.43.0