Message ID | 20221207074043.1286731-7-yebin@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp32041wrr; Tue, 6 Dec 2022 23:21:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf5xs+f6me8CmQqjI0jfyNF/+AosVohQXU2L3+Yg+m4nVKYogr1TMb2Zrl7/yX7/hSubN5lr X-Received: by 2002:a05:6a00:408b:b0:56b:ca57:ba8c with SMTP id bw11-20020a056a00408b00b0056bca57ba8cmr73567970pfb.43.1670397700029; Tue, 06 Dec 2022 23:21:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670397700; cv=none; d=google.com; s=arc-20160816; b=easYJMWGwsm9x463sUMynHxaYrAKSVh/HxmLJ4/ry+ecFOFnJPiCX4QyUGLYggTtED CiMj4sNtvmUJjAO10Q487aQq3apGl+tX0gNs1okunX8yUyoyXywAeAFJXdftOJNwPBNE MSKd5uz/n7XJN7MCwDZXnK7K0+7D3dEv7IegWw/sNy4vrvmaow1mbAkdp5xkNtHkDdp2 3g9A1CxLG1ZGtzohM7QH8w5PMDkjDP6TQOFh9zMzBw6qQjU4JSL3ZCydGK0ssoGRWGpY /uISszK/O6N97JJlAvkpz7CVQxJRyZ08h+SKuqVwk2y1wVRk9OiZKdKsZAMSpaKINMdf jRvQ== 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=GswiN5Fl9SB7/VSGPBVAu0XsNrjw7kTuIUeaNxhiB5g=; b=xsAT24dzhT2UhKqdAHonvyz7Vh1SIjUMUSpPAncnLN/EDlbaPBv2dVeRm1ylTBzMzL Yy8NQvMz1Pn/m+02JXkbZ2K836MgkyDKFG4GxIgEVGMITkhqCTf73sW9eOzzKK2yQYy2 ljfgLsaKbrcdFNV6K/8KtJsLOeYqMc7PLMwUCCfWuPEgTktlQoRvnP8dHxbztwjZoadx XQ+H7cjjt8WP0CAPJVAKL7hOUkOuA+XpOFQkwwx2BR9qG/VqG/K9cBSIYHaaV/pm7U27 CpxE0/JSP9KE1w66T7VNgMiJ7D7cVdtUZxFXh6n1/HzK4WmEjE4hA9kHwl5dECZQiaXN NMpQ== 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 l10-20020a170902e2ca00b00189c8b6e603si10295982plc.583.2022.12.06.23.21.26; Tue, 06 Dec 2022 23:21: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 S229785AbiLGHUI (ORCPT <rfc822;b08248@gmail.com> + 99 others); Wed, 7 Dec 2022 02:20:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbiLGHT4 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 7 Dec 2022 02:19:56 -0500 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00E1432058; Tue, 6 Dec 2022 23:19:55 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4NRpZZ3MZRz4f3vfW; Wed, 7 Dec 2022 15:19:50 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgBniteWPpBj6qE0Bw--.52253S10; Wed, 07 Dec 2022 15:19:53 +0800 (CST) From: Ye Bin <yebin@huaweicloud.com> To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Cc: linux-kernel@vger.kernel.org, jack@suse.cz, Ye Bin <yebin10@huawei.com> Subject: [PATCH v2 6/6] ext4: fix inode leak in 'ext4_xattr_inode_create()' Date: Wed, 7 Dec 2022 15:40:43 +0800 Message-Id: <20221207074043.1286731-7-yebin@huaweicloud.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221207074043.1286731-1-yebin@huaweicloud.com> References: <20221207074043.1286731-1-yebin@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgBniteWPpBj6qE0Bw--.52253S10 X-Coremail-Antispam: 1UD129KBjvJXoW7Aw4ftr4kJr4DAF13Xw17trb_yoW8Gry7pr sxJr18Kr48uFyqg3yFyFs7Z3srKasrGr4UJFWUKw1rAF98Wasaqa45Kr4rAF1UJr4ktw1F qF1UCrWFvr45AaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 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=0.3 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, MAY_BE_FORGED,SPF_HELO_NONE,SPF_NONE autolearn=no 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751538938407798183?= X-GMAIL-MSGID: =?utf-8?q?1751538938407798183?= |
Series |
Fix two issue about ext4 extended attribute
|
|
Commit Message
Ye Bin
Dec. 7, 2022, 7:40 a.m. UTC
From: Ye Bin <yebin10@huawei.com> 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 <yebin10@huawei.com> --- fs/ext4/xattr.c | 3 +++ 1 file changed, 3 insertions(+)
Comments
On Wed, Dec 07, 2022 at 03:40:43PM +0800, Ye Bin wrote: > 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. > What about "This occurs in ... . If ... fails, dropping i_nlink of the inode is needed, otherwise inode leak can occur."?
On Wed 07-12-22 15:40:43, Ye Bin wrote: > From: Ye Bin <yebin10@huawei.com> > > 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 <yebin10@huawei.com> I think I've already given my Reviewed-by on this :). Anyway, the patch looks good. Feel free to add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > --- > fs/ext4/xattr.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c > index 5c0476ff62c8..6c19d01ba261 100644 > --- a/fs/ext4/xattr.c > +++ b/fs/ext4/xattr.c > @@ -1465,6 +1465,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); > } > -- > 2.31.1 >
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 5c0476ff62c8..6c19d01ba261 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -1465,6 +1465,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); }