From patchwork Thu Dec 8 02:32:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 31111 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp516295wrr; Wed, 7 Dec 2022 18:13:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf7n4Acb9fEJhZX9iSeTcDP2IVF1JQNZDEfIE8Qgxr7nCvl2cINXSIP7qO6AgpyRBPam87t/ X-Received: by 2002:a17:90b:1950:b0:21a:1f64:6fd0 with SMTP id nk16-20020a17090b195000b0021a1f646fd0mr3081472pjb.151.1670465625624; Wed, 07 Dec 2022 18:13:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670465625; cv=none; d=google.com; s=arc-20160816; b=ttCIuSCOWOTius+FpSX6kevKaDn/eO+R0PYat1RmlozRg9u1/c6yqaIkfeMEgtvLHE P6zQLoJmPDPrHwOcvtZPWmbDARCwLims4EB6ncPMHDB9e5x4DrEPCnZjaSQQdMfsi7Ui LhAcbwcaC6fVl7hwh0lWHH8XyxhQo1IY2afDXe0e14pSJxjKYFcH6fKBKOPr6GRKE+8v gpR2y5qaq3Xv6qJW7wpb2or3rwjllLl1y13lcTD/4us4IYWFULNC5SL5PwpGqweiZo4o aAg2jfZJuq2/ECFBZlHQEuFMJIp33nnKQKere8xAnG3OyNh7l52tSp3pc81gWDraGbTY G5Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vCkpTs96vkFUohjCNdBtdjuG5krAq4VWs5O+EW1Sw5s=; b=Bdr1g6qD6F6/FlywdZJGkmgyKptda5/Lvpmda2AwzBZeDGNafOHkRUUrDHC+/SZ09M 74zKG5jiWvBoO3bGIYyfGIIvEZ9A8tPr2RYn3yR/1HPD4znF+BwLeULyzY9wwxuGlR/z Fmnyzrbk0LlAA1UKxfwcOA8bdqyEujhfPPnjLEuD7iAfleDmz34aX62V70J1YNFWgk4M FcjDPlEQKKg9h2Xes8RyhazL/RWG4NJ/rg1bMzmW4G6L2/W3D9VSBFCwvJd8OnL7ymf+ 5LLB28hiqDNIR7mpsdng1rH25KjonAxv0N/oiCPRDGWkiviWgvip7dHaauTutpUaU/zU GSgA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h69-20020a638348000000b00478f0ed0a68si3860091pge.575.2022.12.07.18.13.32; Wed, 07 Dec 2022 18:13:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229776AbiLHCLt (ORCPT + 99 others); Wed, 7 Dec 2022 21:11:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229692AbiLHCLp (ORCPT ); Wed, 7 Dec 2022 21:11:45 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9391B92FD2; Wed, 7 Dec 2022 18:11:44 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4NSHhW02ykz4f3jLG; Thu, 8 Dec 2022 10:11:39 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgB3m9jbR5Fjj5BiBw--.22193S8; Thu, 08 Dec 2022 10:11:42 +0800 (CST) From: Ye Bin To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jack@suse.cz, Ye Bin Subject: [PATCH v3 4/4] ext4: fix inode leak in 'ext4_xattr_inode_create()' Date: Thu, 8 Dec 2022 10:32:33 +0800 Message-Id: <20221208023233.1231330-5-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221208023233.1231330-1-yebin@huaweicloud.com> References: <20221208023233.1231330-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgB3m9jbR5Fjj5BiBw--.22193S8 X-Coremail-Antispam: 1UD129KBjvJXoW7Aw4ftr4kJr4DAF13XFWkZwb_yoW8GFy8pw 43Jw18tr48uFyvk39YkFs7Z347KasrGr4UXFyjkw1rZF98Xa4Sqa45KF4rAF1UJr4ktw1Y qF45CrWrZF15AaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvEb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7 v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF 1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIx AIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI 42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWI evJa73UjIFyTuYvjxUFgAwUUUUU X-CM-SenderInfo: p1hex046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751610163927395509?= X-GMAIL-MSGID: =?utf-8?q?1751610163927395509?= From: Ye Bin There is issue as follows when do setxattr with inject fault: [localhost]#fsck.ext4 -fn /dev/sda e2fsck 1.46.6-rc1 (12-Sep-2022) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Unattached zero-length inode 15. Clear? no Unattached inode 15 Connect to /lost+found? no Pass 5: Checking group summary information /dev/sda: ********** WARNING: Filesystem still has errors ********** /dev/sda: 15/655360 files (0.0% non-contiguous), 66755/2621440 blocks This occurs in 'ext4_xattr_inode_create()'. If 'ext4_mark_inode_dirty()' fails, dropping i_nlink of the inode is needed. Or will lead to inode leak. Signed-off-by: Ye Bin Reviewed-by: Jan Kara --- fs/ext4/xattr.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 99dacb0393fa..aad7de2e366a 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -1442,6 +1442,9 @@ static struct inode *ext4_xattr_inode_create(handle_t *handle, if (!err) err = ext4_inode_attach_jinode(ea_inode); if (err) { + if (ext4_xattr_inode_dec_ref(handle, ea_inode)) + ext4_warning_inode(ea_inode, + "cleanup dec ref error %d", err); iput(ea_inode); return ERR_PTR(err); }