From patchwork Tue Dec 6 01:58:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 30057 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2574428wrr; Mon, 5 Dec 2022 17:39:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf4O/EKEwZlThT2fYC7extLgvaM5VgjxwqCOo1tYvgoTuuTOsjQrAXdmSIkcQQfbSmc29rzC X-Received: by 2002:a17:90a:7885:b0:217:e32e:e931 with SMTP id x5-20020a17090a788500b00217e32ee931mr97255249pjk.146.1670290780020; Mon, 05 Dec 2022 17:39:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670290780; cv=none; d=google.com; s=arc-20160816; b=rRD7lBtNjxblS76gtPu5b6M63AG/vJTaUtkZsVxoTm0YrwsqjcnztrqCIK/tKe2HIj UGHLFRNHKTqHf5+2ScdbcqiO3Ty+Vf1fITQfkB7TjPkmYT5P5H7jk2FVG5RkmcydR/sT lCWtPJLFRPSbdbooPXVQzXjBh+tZAHttmbmVOkEhpUfStiFrccaHdRXptkqyswJ1u/Rr 7qITSpHSiF1j6Y5IAGLioNGZd3KxhfylRUycGiwk3UXwewGevWZnvBKuvh3W0IZNkW8t 3f/XQkaLL4Da/vWM1oDhJxiwKYbWc6Ighb0zWDht4bb5v4anvK7B7I2oFnbWWv7d6gCJ 4azA== 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=uhpIKDvikoeHqoW/TYvGeKHzbukhjBbmcPvqqBvLL9M=; b=pB0Ags4pbkvEQZ9N3WHZaU/TmDxmGaXz4ZMfLKMeMyXBE5yAFCChz02WchS11fXOy6 U0JpPXdDC604MCuj63UV/T1B/CZBwbTIx+NQMrzi88ODjBKaFMXI7CuV82lAA3Y/vczf qcZAiqHZG0s2cv4WRtpJIXMwYfkbMAquRNYMPm046RW3CF9nx01QiEp4FkkLTKHyGpJp VsPVGbk0vI8nF8jzmsZx5Dd90iW9w0ZbXrs3zFjRF26OlRHc4eOITJfjCcj4YcJ9fuyP dWBUx3RnBwFfhJ457980xp2v+h6kf73iWL33O5HkAI6Tb8DSxdBAuYGDZtEANrfYxPSA Rbww== 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 e64-20020a636943000000b00478a53c6715si6635027pgc.289.2022.12.05.17.39.26; Mon, 05 Dec 2022 17:39:40 -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 S233497AbiLFBhc (ORCPT + 99 others); Mon, 5 Dec 2022 20:37:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233008AbiLFBhQ (ORCPT ); Mon, 5 Dec 2022 20:37:16 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C512B201BD; Mon, 5 Dec 2022 17:37:15 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4NR31f2C1Kz4f3k6S; Tue, 6 Dec 2022 09:37:10 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgDH69jFnI5jZpTsBg--.65169S10; Tue, 06 Dec 2022 09:37:13 +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 -next 6/6] ext4: fix inode leak in 'ext4_xattr_inode_create()' Date: Tue, 6 Dec 2022 09:58:06 +0800 Message-Id: <20221206015806.3420321-7-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221206015806.3420321-1-yebin@huaweicloud.com> References: <20221206015806.3420321-1-yebin@huaweicloud.com> MIME-Version: 1.0 X-CM-TRANSID: gCh0CgDH69jFnI5jZpTsBg--.65169S10 X-Coremail-Antispam: 1UD129KBjvJXoW7Aw4ftr4kJr4DAF13Xw17trb_yoW8Gry7pr sxJr18Kr4UuFyqg3yrKFs7Z3srKasrGr4UXFyUKw1rAF98Xasaqa45KF4rAF1UJr4ktw1F qF4UCrWFvw13A3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvEb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUAV Cq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0 rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267 AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E 14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7 xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Y z7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7 v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF 1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_JFI_Gr1lIx 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?1751426824846801776?= X-GMAIL-MSGID: =?utf-8?q?1751426824846801776?= 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 Above issue occur in 'ext4_xattr_inode_create()', if 'ext4_mark_inode_dirty()' failed need to drop inode's i_nlink. 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 003fe1f2d6a8..734f787ae7ed 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -1464,6 +1464,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); }