Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3686390rdg; Wed, 18 Oct 2023 03:09:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIoA/a2rIwjC/D8LVgzj3WXOq3PJPU6/3s60Nz5vYHRARoR48C7SQuD+B9Zb78ghpuJCOu X-Received: by 2002:a05:6a20:1609:b0:13f:c40c:379 with SMTP id l9-20020a056a20160900b0013fc40c0379mr4495567pzj.13.1697623750026; Wed, 18 Oct 2023 03:09:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697623750; cv=none; d=google.com; s=arc-20160816; b=qoraSWXfxKAAzuxWolIqVl2qQzAAz/xE+xsEF2ekmwKQ4DWT6cv2AggyHH3RA4ax9g faEoX/J2GzbRRgZKe/Z2d/5HjU3XWOKXqcVB4xNn1MxCza6vYNt5TSvUf9s9cqhl6+lS RgiIckX5TlYQMohkXwRtjC27cS8CpXN3l/d7SeO5y0dCibT8uHKDGC6Q0Vv1UvRkHgGu C8j3VWPWoxySFxotqwOr3K4tzaFPEv2RnFh4XIdcmL0b3gBrUQ50zlnpH619KxViicCb IVJDqRXRTMPaqy4G0/42VpootXNE4EmyU5a/YhGX32mRqz1hJkVjpGyBlPPJI+jg3eqc JMMg== 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=eFcw2YWAB59+T18G4hSQQmtOaMn6MQPyz+SjvuVLR+E=; fh=+RqeyWLHGwXkNa0WVYiIz7xvJTh875wzDaxfh0uGFEs=; b=Jqy2W3778NEJBNoyFJ3brd6kewPlwvtkGXHhUtwRqFlujGic0A9HgBbV3zFMVz48zl m6MZnP1DqHPOHHQYRF5MxhqO6CcPmO1IQd4O4kAQk41FCVbDvq3IBxYUSiYoPUCgqb66 JbFCieuPb1K8Tp8DdVWuHt6zM0XQp1kMO2h75ax09/mJIPVdLXUa7d/qhasOcqYkGayw /ckSL6rl2Ey/hR1+L6ThVFJclB3Q6l+NOmuqA9vZWBKicdvWXeqG0SHJRjZ+KkFtAad9 j8Tn3ZmuPEPn9iFbXZAXfjQSt3BIPLNELHb8QiPHfgk7gf7cdBBIvSvSkzdveMc6Hzxp ga6Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id b11-20020a170902ed0b00b001c9dfd47959si3534254pld.602.2023.10.18.03.09.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 03:09:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id EDD448025AC1; Wed, 18 Oct 2023 03:09:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230386AbjJRKI5 (ORCPT + 99 others); Wed, 18 Oct 2023 06:08:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229552AbjJRKI4 (ORCPT ); Wed, 18 Oct 2023 06:08:56 -0400 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6539410A; Wed, 18 Oct 2023 03:08:53 -0700 (PDT) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (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 4S9RQ70LnDz8XrRC; Wed, 18 Oct 2023 18:08:47 +0800 (CST) Received: from szxlzmapp05.zte.com.cn ([10.5.230.85]) by mse-fl2.zte.com.cn with SMTP id 39IA8ghC093171; Wed, 18 Oct 2023 18:08:42 +0800 (+08) (envelope-from cheng.lin130@zte.com.cn) Received: from mapi (szxlzmapp04[null]) by mapi (Zmail) with MAPI id mid14; Wed, 18 Oct 2023 18:08:45 +0800 (CST) Date: Wed, 18 Oct 2023 18:08:45 +0800 (CST) X-Zmail-TransId: 2b06652faeadffffffffbf8-6e3ce X-Mailer: Zmail v1.0 Message-ID: <202310181808454230330@zte.com.cn> Mime-Version: 1.0 From: To: , , Cc: , , , , , , Subject: =?UTF-8?B?W1JGQyBQQVRDSCB2Ml0gZnM6IGludHJvZHVjZSBjaGVjayBmb3IgaW5vZGUgbmxpbmsgd2hlbiBkZWxldGU=?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl2.zte.com.cn 39IA8ghC093171 X-Fangmail-Gw-Spam-Type: 0 X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 652FAEAF.000/4S9RQ70LnDz8XrRC X-Spam-Status: No, score=-0.7 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 howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 18 Oct 2023 03:09:07 -0700 (PDT) From: Cheng Lin Do not delete inode which nlink already zero to avoid inode nlink underflow. Signed-off-by: Cheng Lin --- fs/namei.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/namei.c b/fs/namei.c index e56ff39a7..30bc0d0a6 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -4197,6 +4197,11 @@ int vfs_rmdir(struct mnt_idmap *idmap, struct inode *dir, if (error) goto out; + if (unlikely(dir->i_nlink == 0) || + unlikely(dentry->d_inode->i_nlink == 0)) { + error = -EUCLEAN; + goto out; + } error = dir->i_op->rmdir(dir, dentry); if (error) goto out; @@ -4326,6 +4331,10 @@ int vfs_unlink(struct mnt_idmap *idmap, struct inode *dir, error = try_break_deleg(target, delegated_inode); if (error) goto out; + if (unlikely(target->i_nlink == 0)) { + error = -EUCLEAN; + goto out; + } error = dir->i_op->unlink(dir, dentry); if (!error) { dont_mount(dentry); -- 2.18.1