From nobody Wed Dec 17 03:14:50 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D42ECD68E3 for ; Tue, 10 Oct 2023 02:09:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379392AbjJJCJb (ORCPT ); Mon, 9 Oct 2023 22:09:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379354AbjJJCJa (ORCPT ); Mon, 9 Oct 2023 22:09:30 -0400 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56F0DAF; Mon, 9 Oct 2023 19:09:21 -0700 (PDT) Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4S4K8Y5MRRz8XrRC; Tue, 10 Oct 2023 10:09:17 +0800 (CST) Received: from szxlzmapp03.zte.com.cn ([10.5.231.207]) by mse-fl1.zte.com.cn with SMTP id 39A28xCV002979; Tue, 10 Oct 2023 10:08:59 +0800 (+08) (envelope-from cheng.lin130@zte.com.cn) Received: from mapi (szxlzmapp07[null]) by mapi (Zmail) with MAPI id mid14; Tue, 10 Oct 2023 10:09:01 +0800 (CST) Date: Tue, 10 Oct 2023 10:09:01 +0800 (CST) X-Zmail-TransId: 2b096524b23d550-fc3a0 X-Mailer: Zmail v1.0 Message-ID: <202310101009011817522@zte.com.cn> Mime-Version: 1.0 From: To: , Cc: , , , , Subject: =?UTF-8?B?W1BBVENIIHY2XSB4ZnM6IGludHJvZHVjZSBwcm90ZWN0aW9uIGZvciBkcm9wIG5saW5r?= X-MAIL: mse-fl1.zte.com.cn 39A28xCV002979 X-Fangmail-Gw-Spam-Type: 0 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6524B24D.000/4S4K8Y5MRRz8XrRC Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cheng Lin When abnormal drop_nlink are detected on the inode, return error, to avoid corruption propagation. Signed-off-by: Cheng Lin Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_inode.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 9e62cc500..0fa1ac5e0 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -919,6 +919,13 @@ xfs_droplink( xfs_trans_t *tp, xfs_inode_t *ip) { + if (VFS_I(ip)->i_nlink =3D=3D 0) { + xfs_alert(ip->i_mount, + "%s: Attempt to drop inode (%llu) with nlink zero.", + __func__, ip->i_ino); + return -EFSCORRUPTED; + } + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG); drop_nlink(VFS_I(ip)); --=20 2.18.1