Message ID | 202310091645572092816@zte.com.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp1728782vqo; Mon, 9 Oct 2023 01:46:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXelFMulV8ywCO0be9z4k87I8MYhbMJcfYDBQdp+dE0GZY/Cq2zLaOsN8bCpamq5jlaS3O X-Received: by 2002:a05:6a20:42a8:b0:158:f65:12d5 with SMTP id o40-20020a056a2042a800b001580f6512d5mr15234291pzj.43.1696841203596; Mon, 09 Oct 2023 01:46:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696841203; cv=none; d=google.com; s=arc-20160816; b=N1TTDfsuz8rd8iizNt+mighuCk+pQqurvpHw2B28ob4rp/wK1lS5hwVKQRiwKWYqHF xQLCKIMwm+xK/BkFQ08OZ9T6GbgSBiN6+9kLZHepol0ELN65hXLDFPZkkajODEmtvIYP EqETVN6MRTPKE0A6/ZAlchNhfblS1Y8LfwG3y62CVLybpXqfUC8x/s337kL2I3VsRxlg TgYHKUqLLiwa8yjXy3ZGXeOMOBluFzPBt6bRtNTlIATl6+qxMPV1Q7kqKBH7boPw2enr PasQJPgL85Ep4Yk/y7YZSAEPTOkRIodLUt9GM7YooZJxnfBaurYq4trl0DYRtY/CjC9L M9Og== 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=rpjHzPHXv/01nX7V1BGKLIWQ/I7eJ1F4/dQWxRPcyZA=; fh=hFgfcaIVoyhXbF2UwJZsnqb6ugEoYRhxDBvi1f/p9Jo=; b=PDgL/MoXF0py5Y8fdKxT7PPOpIVkD0vOMLT3BYoyRIpRbcT5TZhA9dtQHO7DzLrjHD ZF5hmtP0wHKIlM6RaAcMhCKHPg4lNhXaXic3F12+Tirvc/cZVgoVbdyGHHoDHQZ5el1T 4euDWy1YO076CShrbwiVFwuDtEJX3Zgaj/bxb5b7zxUafP8W2KLuAc557IAJgEfoF5EX vGzDgGU47LgPyuGARPlHrA5sX6b8Sz41W+bjy0GHEajAhZsHsYHhlt6S/m2ULOQoIfcL UDcJmhtztuXvZ+HA4P/jB0/b8uO+oce2UI982HrBC5Zq5PDuNreOBJS9ndSG+IWHpr/s HNeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id r184-20020a632bc1000000b00566022bbcafsi8792139pgr.566.2023.10.09.01.46.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 01:46:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id B2E6F805FD27; Mon, 9 Oct 2023 01:46:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345544AbjJIIqU (ORCPT <rfc822;ezelljr.billy@gmail.com> + 18 others); Mon, 9 Oct 2023 04:46:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345511AbjJIIqO (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 9 Oct 2023 04:46:14 -0400 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 542AC97; Mon, 9 Oct 2023 01:46:11 -0700 (PDT) Received: from mxct.zte.com.cn (unknown [192.168.251.13]) (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 4S3t0r6Pm7z4xPYj; Mon, 9 Oct 2023 16:46:04 +0800 (CST) 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 mxct.zte.com.cn (FangMail) with ESMTPS id 4S3t0p1x7Tz4xVc6; Mon, 9 Oct 2023 16:46:02 +0800 (CST) Received: from szxlzmapp01.zte.com.cn ([10.5.231.85]) by mse-fl1.zte.com.cn with SMTP id 3998jsF3007730; Mon, 9 Oct 2023 16:45:54 +0800 (+08) (envelope-from cheng.lin130@zte.com.cn) Received: from mapi (szxlzmapp02[null]) by mapi (Zmail) with MAPI id mid14; Mon, 9 Oct 2023 16:45:57 +0800 (CST) Date: Mon, 9 Oct 2023 16:45:57 +0800 (CST) X-Zmail-TransId: 2b046523bdc5410-b5a72 X-Mailer: Zmail v1.0 Message-ID: <202310091645572092816@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_v5=5D_xfs=3A_introduce_protection_for_drop_nlink?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 3998jsF3007730 X-Fangmail-Gw-Spam-Type: 0 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6523BDCC.002/4S3t0r6Pm7z4xPYj X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 09 Oct 2023 01:46:41 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779266961850589117 X-GMAIL-MSGID: 1779266961850589117 |
Series |
[v5] xfs: introduce protection for drop nlink
|
|
Commit Message
cheng.lin130@zte.com.cn
Oct. 9, 2023, 8:45 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, Oct 09, 2023 at 04:45:57PM +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..752e6aeba 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) > { > + No need for the extra whitespace here. > + if (VFS_I(ip)->i_nlink == 0) { > + xfs_alert(ip->i_mount, > + "%s: Attempt to drop inode (%llu) with nlink zero.", > + __func__, ip->i_ino); > + return -EFSCORRUPTED; > + } With that fixed, Reviewed-by: Darrick J. Wong <djwong@kernel.org> --D > + > 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..752e6aeba 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: 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));