Message ID | 202309181450509388561@zte.com.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2471580vqi; Sun, 17 Sep 2023 23:53:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHfyi8Xxj3LbdQH5T1lsNctDjK8eENqVl2QeENp0SthmFtGetGWJsdfw+nhQ+QAj6mwT4DO X-Received: by 2002:a17:90a:cb0e:b0:274:748c:9c55 with SMTP id z14-20020a17090acb0e00b00274748c9c55mr5673429pjt.20.1695019986161; Sun, 17 Sep 2023 23:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695019986; cv=none; d=google.com; s=arc-20160816; b=YZk9ps73G3y9cU6cxZXVu1G/T+GbZ7fStS8XsbzypnOn+RoaeqIhFF787EwcS4GkRb vqYNS7Lj4aMU+90hMrcIAyeDjpZTB7GuFTS0RnZ6IoSCw3vGcp89TW0P4Abbv4jkrrjD oyCWLVT3wm1v/vZlgCjs7mQnEx7Bd7aNMK3Us0Z7iN+lezfGnGTzSel0P6/6DcvIb0QV czYYoaeK6GoBMZtEOYJ96t2yFq0LifoCxs+3dtkPYMBUW6/JQ0CBZiYlgosuVUvlG6tF HhPHEDWIq7XCJX3beeyW8loFnTAEqER6ZkBDogh74pks9PD6W7raabdj1quXT419qOrv POwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=LqoXsNiOpdyqoLt2oqnGRfgdDfVauopGq4iP8BSAeZE=; fh=hFgfcaIVoyhXbF2UwJZsnqb6ugEoYRhxDBvi1f/p9Jo=; b=uffQrOxOavm439OOVCpf8QzxqmdtfMBs9QJWN0MyIOIkXrQn9cN8L67GbTpNAh6O8V y05j7Ez+y2s3Kk4ql9uW8oXW5rR7O9A6c7Ke3sUT4046RApduneEDarVBZCbEot6Uwk+ 9D6tL5RjjYrziWOFtVc92pmHAMhL3nh0lMkrqRRVVTZ4pQLOgV7F5gTbIIdvEL198g3G 6MlYcFxYYTPLvXdmqMP6m0tWIwReUOeSKuQ2iwORhP9uKlKySklVKKqYsOW/lAvyYlua 6qaeF3hhNxaBg5XCAy25ItKb7eSrrJyeAP3HepbOsVm7iIWg8HHsCR/oqNMjxa76guur OoLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id l7-20020a17090a850700b00268307ac3cfsi9567963pjn.185.2023.09.17.23.53.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 23:53:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id E531B819802D; Sun, 17 Sep 2023 23:52:56 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238411AbjIRGvy (ORCPT <rfc822;kernel.ruili@gmail.com> + 27 others); Mon, 18 Sep 2023 02:51:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239854AbjIRGvX (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 18 Sep 2023 02:51:23 -0400 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EF2F12F; Sun, 17 Sep 2023 23:51:12 -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 4RpwRv18VQz4xPYd; Mon, 18 Sep 2023 14:51:07 +0800 (CST) Received: from szxlzmapp05.zte.com.cn ([10.5.230.85]) by mse-fl1.zte.com.cn with SMTP id 38I6omNN027269; Mon, 18 Sep 2023 14:50:48 +0800 (+08) (envelope-from cheng.lin130@zte.com.cn) Received: from mapi (szxlzmapp07[null]) by mapi (Zmail) with MAPI id mid14; Mon, 18 Sep 2023 14:50:50 +0800 (CST) Date: Mon, 18 Sep 2023 14:50:50 +0800 (CST) X-Zmail-TransId: 2b096507f34a368-08e64 X-Mailer: Zmail v1.0 Message-ID: <202309181450509388561@zte.com.cn> Mime-Version: 1.0 From: <cheng.lin130@zte.com.cn> To: <david@fromorbit.com>, <djwong@kernel.org> Cc: <linux-xfs@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <jiang.yong5@zte.com.cn>, <wang.liang82@zte.com.cn>, <liu.dong3@zte.com.cn> Subject: =?utf-8?q?=5BPATCH_v4=5D_xfs=3A_introduce_protection_for_drop_nlink?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 38I6omNN027269 X-Fangmail-Gw-Spam-Type: 0 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6507F35B.000/4RpwRv18VQz4xPYd X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sun, 17 Sep 2023 23:52:57 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777356334174389054 X-GMAIL-MSGID: 1777357276942451194 |
Series |
[v4] xfs: introduce protection for drop nlink
|
|
Commit Message
cheng.lin130@zte.com.cn
Sept. 18, 2023, 6:50 a.m. UTC
From: Cheng Lin <cheng.lin130@zte.com.cn> When abnormal drop_nlink are detected on the inode, return error, to avoid corruption propagation. Signed-off-by: Cheng Lin <cheng.lin130@zte.com.cn> --- fs/xfs/xfs_inode.c | 8 ++++++++ 1 file changed, 8 insertions(+)
Comments
On Mon, Sep 18, 2023 at 02:50:50PM +0800, cheng.lin130@zte.com.cn wrote: > From: Cheng Lin <cheng.lin130@zte.com.cn> > > When abnormal drop_nlink are detected on the inode, > return error, to avoid corruption propagation. > > Signed-off-by: Cheng Lin <cheng.lin130@zte.com.cn> > --- > fs/xfs/xfs_inode.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c > index 9e62cc500..d16cb62ce 100644 > --- a/fs/xfs/xfs_inode.c > +++ b/fs/xfs/xfs_inode.c > @@ -919,6 +919,14 @@ xfs_droplink( > xfs_trans_t *tp, > xfs_inode_t *ip) > { > + > + if (VFS_I(ip)->i_nlink == 0) { > + xfs_alert(ip->i_mount, > + "%s: Deleting inode %llu with no links.", > + __func__, ip->i_ino); We're not deleting the zero-nlink file, since we return without changing the link count. Also wondering why this doesn't use XFS_IS_CORRUPT? That macro already logs a message about there being problems: struct xfs_mount *mp = ip->i_mount; if (XFS_IS_CORRUPT(mp, VFS_I(ip)->i_nlink == 0)) return -EFSCORRUPTED; --D > + return -EFSCORRUPTED; > + } > + > xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG); > > drop_nlink(VFS_I(ip)); > -- > 2.18.1
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 9e62cc500..d16cb62ce 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -919,6 +919,14 @@ xfs_droplink( xfs_trans_t *tp, xfs_inode_t *ip) { + + if (VFS_I(ip)->i_nlink == 0) { + xfs_alert(ip->i_mount, + "%s: Deleting inode %llu with no links.", + __func__, ip->i_ino); + return -EFSCORRUPTED; + } + xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG); drop_nlink(VFS_I(ip));