From patchwork Thu Dec 8 02:32:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 31113 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp516518wrr; Wed, 7 Dec 2022 18:14:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf7xLEqNbBzc990nU8MTO76NIQWTBeZdKv07AKmimhMpD9Lp/NYv4KTPSk+9B0GITlY7gb77 X-Received: by 2002:a17:902:c1cd:b0:189:6b31:dc53 with SMTP id c13-20020a170902c1cd00b001896b31dc53mr60711959plc.58.1670465671734; Wed, 07 Dec 2022 18:14:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670465671; cv=none; d=google.com; s=arc-20160816; b=wX9rJblC6zYwxjSMhDypmOJez67Vp7KneClm4NvTi9F2Yf9MuxYBxR346nRqy16NdP bYHBom14RjWPmPkKgVF19tagLSfs8dR/DT+DMiFCJWOcibnMw9BAKAFwh/WYslA1J9WW G/GIAzVtU9VBFxWggAfvFdqgXf9qikFHjqx/SE5PEeXWzwVmj+4qEQh6PU7wTCQQTbZn aVVIFhz+gvIfiTerVCL+V3JWA10Vfs/thtkGb7c0aK5ppbi/nyi36dh569Mwf1XaIcz7 N+y6FDWGebOyk32ixGpDGaMh9XdKXNYmJE7Pc19sevrQCNmjxjM7RbkFV6XDfHy+qgZf 55+w== 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=UHOHASLecbS7Yb7BfyG8eiiHHx7AEpC2ocH7RbM1MDA=; b=VMyl9TdwfFeAClqNaj9zvVD08G7rF4J6b/Sic3DnPljxosRoqLm5zgtJXg70cqxnyh H1pN41II5r5DHZLucq3v0rIKDfLGDDZ7E1EH9clLaJnjq3dinF9f4wKR8MEAGro2yESk nNK6J49N+U64K5vSHP/LyRIJY/c8aUMyPitxsbI4XqxWBg3rIkchSOZ90MdhZn+D2HLm eamz5Wo4GpLBdyX+BA8asnxIKnyqH3kW3jn51V7NUbRqyE8vdlUl0alRPT6ckEGIg8bd QQw4BIDingmLbKh0RXGIYBY8Ivh6oIl204/iAJtsCL5ZQ1QMUueEe+vo74TGH3qCIuQO +8GQ== 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 ij27-20020a170902ab5b00b0018990b83e0esi21160480plb.422.2022.12.07.18.14.18; Wed, 07 Dec 2022 18:14:31 -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 S229750AbiLHCLq (ORCPT + 99 others); Wed, 7 Dec 2022 21:11:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229689AbiLHCLp (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 BABD792A3F; Wed, 7 Dec 2022 18:11:43 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4NSHhV0pM2z4f3m6k; Thu, 8 Dec 2022 10:11:38 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgB3m9jbR5Fjj5BiBw--.22193S5; Thu, 08 Dec 2022 10:11:41 +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 , syzbot+4d99a966fd74bdeeec36@syzkaller.appspotmail.com Subject: [PATCH v3 1/4] ext4: fix WARNING in ext4_expand_extra_isize_ea Date: Thu, 8 Dec 2022 10:32:30 +0800 Message-Id: <20221208023233.1231330-2-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--.22193S5 X-Coremail-Antispam: 1UD129KBjvJXoWxGrW3JFy5KrWkJr4rZr4kXrb_yoWrtFW5pw 43A347Cr48XF9rCF4xAr1jqw1DWwn3CF4UAryxWrn7ZFy3Xw1xKa95Kr4SqFyxtrW8Jry2 qFn8J34rKw15GaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGw A2048vs2IY020Ec7CjxVAFwI0_JFI_Gr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxUzl1vUUUUU 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?1751610212490425318?= X-GMAIL-MSGID: =?utf-8?q?1751610212490425318?= From: Ye Bin Syzbot found the following issue: ------------[ cut here ]------------ WARNING: CPU: 1 PID: 3631 at mm/page_alloc.c:5534 __alloc_pages+0x30a/0x560 mm/page_alloc.c:5534 Modules linked in: CPU: 1 PID: 3631 Comm: syz-executor261 Not tainted 6.1.0-rc6-syzkaller-00308-g644e9524388a #0 Hardware name: Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022 RIP: 0010:__alloc_pages+0x30a/0x560 mm/page_alloc.c:5534 RSP: 0018:ffffc90003ccf080 EFLAGS: 00010246 RAX: ffffc90003ccf0e0 RBX: 000000000000000c RCX: 0000000000000000 RDX: 0000000000000028 RSI: 0000000000000000 RDI: ffffc90003ccf108 RBP: ffffc90003ccf198 R08: dffffc0000000000 R09: ffffc90003ccf0e0 R10: fffff52000799e21 R11: 1ffff92000799e1c R12: 0000000000040c40 R13: 1ffff92000799e18 R14: dffffc0000000000 R15: 1ffff92000799e14 FS: 0000555555c10300(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007ffc36f70000 CR3: 00000000744ad000 CR4: 00000000003506e0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: __alloc_pages_node include/linux/gfp.h:223 [inline] alloc_pages_node include/linux/gfp.h:246 [inline] __kmalloc_large_node+0x8a/0x1a0 mm/slab_common.c:1096 __do_kmalloc_node mm/slab_common.c:943 [inline] __kmalloc+0xfe/0x1a0 mm/slab_common.c:968 kmalloc include/linux/slab.h:558 [inline] ext4_xattr_move_to_block fs/ext4/xattr.c:2558 [inline] ext4_xattr_make_inode_space fs/ext4/xattr.c:2673 [inline] ext4_expand_extra_isize_ea+0xe3f/0x1cd0 fs/ext4/xattr.c:2765 __ext4_expand_extra_isize+0x2b8/0x3f0 fs/ext4/inode.c:5857 ext4_try_to_expand_extra_isize fs/ext4/inode.c:5900 [inline] __ext4_mark_inode_dirty+0x51a/0x670 fs/ext4/inode.c:5978 ext4_inline_data_truncate+0x548/0xd00 fs/ext4/inline.c:2021 ext4_truncate+0x341/0xeb0 fs/ext4/inode.c:4221 ext4_process_orphan+0x1aa/0x2d0 fs/ext4/orphan.c:339 ext4_orphan_cleanup+0xb60/0x1340 fs/ext4/orphan.c:474 __ext4_fill_super fs/ext4/super.c:5515 [inline] ext4_fill_super+0x80ed/0x8610 fs/ext4/super.c:5643 get_tree_bdev+0x400/0x620 fs/super.c:1324 vfs_get_tree+0x88/0x270 fs/super.c:1531 do_new_mount+0x289/0xad0 fs/namespace.c:3040 do_mount fs/namespace.c:3383 [inline] __do_sys_mount fs/namespace.c:3591 [inline] __se_sys_mount+0x2d3/0x3c0 fs/namespace.c:3568 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd Reason is allocate 16M memory by kmalloc, but MAX_ORDER is 11, kmalloc can allocate maximum size memory is 4M. XATTR_SIZE_MAX is currently 64K, but EXT4_XATTR_SIZE_MAX is 16M, so 'ext4_xattr_check_entries()' regards this length as legal. Then trigger warning in 'ext4_xattr_move_to_block()'. To solve above issue, change EXT4_XATTR_SIZE_MAX from 16M to 64K. As VFS limit extended attribute maximum size to 64K. So we can assume that there will be no extended attribute with a length greater than 64K. Reported-by: syzbot+4d99a966fd74bdeeec36@syzkaller.appspotmail.com Fixes: 54dd0e0a1b25 ("ext4: add extra checks to ext4_xattr_block_get()") Signed-off-by: Ye Bin --- fs/ext4/xattr.h | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/fs/ext4/xattr.h b/fs/ext4/xattr.h index 824faf0b15a8..c71e582b1007 100644 --- a/fs/ext4/xattr.h +++ b/fs/ext4/xattr.h @@ -71,15 +71,10 @@ struct ext4_xattr_entry { #define IFIRST(hdr) ((struct ext4_xattr_entry *)((hdr)+1)) /* - * XATTR_SIZE_MAX is currently 64k, but for the purposes of checking - * for file system consistency errors, we use a somewhat bigger value. - * This allows XATTR_SIZE_MAX to grow in the future, but by using this - * instead of INT_MAX for certain consistency checks, we don't need to - * worry about arithmetic overflows. (Actually XATTR_SIZE_MAX is - * defined in include/uapi/linux/limits.h, so changing it is going - * not going to be trivial....) + * Use XATTR_SIZE_MAX to checking for file system consistency errors. Extended + * attribute length exceed XATTR_SIZE_MAX is illegal. */ -#define EXT4_XATTR_SIZE_MAX (1 << 24) +#define EXT4_XATTR_SIZE_MAX XATTR_SIZE_MAX /* * The minimum size of EA value when you start storing it in an external inode From patchwork Thu Dec 8 02:32:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 31110 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp516181wrr; Wed, 7 Dec 2022 18:13:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf516qrQK4SczjApuoVza5ZPRSVm+kPKTCnno1Z7G5pLw9zk38nwgc8b8VOJtaOd3KCpeC5M X-Received: by 2002:a63:117:0:b0:476:f43d:913e with SMTP id 23-20020a630117000000b00476f43d913emr66503486pgb.386.1670465605802; Wed, 07 Dec 2022 18:13:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670465605; cv=none; d=google.com; s=arc-20160816; b=f/JnWSmzmyt9srb97ikW4Rze/YOcEFTfsiGvQ/ibncNhXp6XaReC4LXEc7Hb/SiNIM xCRZXyc8fRER3PT+GXZ7KY3Zp9dbgr/DrIHizOZ16i5CXdKq01OkIRNi0EV/HOSWgy5Y fHxVXf8Lzl2ZLqGF+kF/Ywt3/AWXqasrGOvrSwIeTs943n9D80qvbN9ng5PjDJa9Pvrz rlcaoO7d7lnEB05G9+8KmvgGd3FD/5kwBHvfey8QOP3ZOTFLeLvM2Wkfap754x/C36nA wMYkPnW/i0K7UzMGrNcoyOIWkOuSJlDY4TVp5izJEcqVdq2ulYKGua0R9IGOpAuVu/xq m3wA== 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=WS0VEdUYxxgm1DR1qDpUSG/hGYIeTCdM+l+kJt5a6SU=; b=Z/RG0Osxl9sjmOGQTOuIFAwvOJxq5plZ6BPMgZtWlTx+VcCr2nBycT0m25uEktEoPH jceitmordvcP4iLbFuTZ4twCLzzuFb+COuaSkZvlHdrSwX31zfQBx5W87C0cHQmkcwx/ k7yhDJwP6RZ40IfLg05bcL5FfBXYhjUeFePwqTAe6AYHW/LIaO7knSbPDv8bVZkOj+AB U33238Ri5+0gXh1mruT4XdcmnMCe498boKpkERyewMyLU/BZVuyACyBGvH2iAw64eAvz o1lw1kqmJEVJZVf1nlQ0qLoF5WCmbsN0/0fxBVPD6PmN0AGitWONLZ3Y5ku2ggGZhRIs SOkQ== 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 j4-20020a170903028400b00189734b4f02si21593352plr.69.2022.12.07.18.13.12; Wed, 07 Dec 2022 18:13:25 -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 S229879AbiLHCL4 (ORCPT + 99 others); Wed, 7 Dec 2022 21:11:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229696AbiLHCLp (ORCPT ); Wed, 7 Dec 2022 21:11:45 -0500 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EEAC92FCD; Wed, 7 Dec 2022 18:11:44 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4NSHhV6vk3z4f3lGs; Thu, 8 Dec 2022 10:11:38 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgB3m9jbR5Fjj5BiBw--.22193S6; Thu, 08 Dec 2022 10:11:41 +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 2/4] ext4: allocate extended attribute value in vmalloc area Date: Thu, 8 Dec 2022 10:32:31 +0800 Message-Id: <20221208023233.1231330-3-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--.22193S6 X-Coremail-Antispam: 1UD129KBjvJXoW7ArWfur4kXF4kZFWrtF1xuFg_yoW8Gr1Upa 9xKa40kr13Xry7uFWIkr48Z342g3ZrGr47uay3Xw40vFy5Xwn2gFyayFWYvF15ZFWftr1v qF1Dtr18Zw43t3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUXw A2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxU2_MaUUUUU 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?1751610143053203287?= X-GMAIL-MSGID: =?utf-8?q?1751610143053203287?= From: Ye Bin Now, extended attribute value maximum length is 64K. The memory requested here does not need continuous physical addresses, so it is appropriate to use kvmalloc to request memory. At the same time, it can also cope with the situation that the extended attribute will become longer in the future. Signed-off-by: Ye Bin Reviewed-by: Jan Kara --- fs/ext4/xattr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 718ef3987f94..23cfefc6d262 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -2556,7 +2556,7 @@ static int ext4_xattr_move_to_block(handle_t *handle, struct inode *inode, is = kzalloc(sizeof(struct ext4_xattr_ibody_find), GFP_NOFS); bs = kzalloc(sizeof(struct ext4_xattr_block_find), GFP_NOFS); - buffer = kmalloc(value_size, GFP_NOFS); + buffer = kvmalloc(value_size, GFP_NOFS); b_entry_name = kmalloc(entry->e_name_len + 1, GFP_NOFS); if (!is || !bs || !buffer || !b_entry_name) { error = -ENOMEM; @@ -2608,7 +2608,7 @@ static int ext4_xattr_move_to_block(handle_t *handle, struct inode *inode, error = 0; out: kfree(b_entry_name); - kfree(buffer); + kvfree(buffer); if (is) brelse(is->iloc.bh); if (bs) From patchwork Thu Dec 8 02:32:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ye Bin X-Patchwork-Id: 31112 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp516301wrr; Wed, 7 Dec 2022 18:13:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf4gvYACC0TUYm3tQOeWdBetedzuhTKKfviMHkSLu0vgZ0JD1WgYEGtQQguw3+PltlOSYc8I X-Received: by 2002:a17:90a:7885:b0:20a:d81d:a8 with SMTP id x5-20020a17090a788500b0020ad81d00a8mr105930765pjk.177.1670465628466; Wed, 07 Dec 2022 18:13:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670465628; cv=none; d=google.com; s=arc-20160816; b=C5zn5qSgXgvMkJklP+cnKiF6aDWhURMUCiOUZ00qn/uvbeB5/ayG/3a6bLkhWfzjBv vJzX1axuYGFxiB9B+RW2UXUGmSz6xPmCPdO96QiCMia+uTreCfV6uYuWtYGLolCQOLhc SefjfUa671JujqQ+76ijFBT3/MmoPT5fK1/Q/ghZxgpj2Am87BDVXcs0XsuaUea2S49J JqI65O8174foOC7dgP2SpXCp02MpG0Hghgjgwd1HBh2vluFoieKjScHWMLUZZ2dAg5qI nqQKsA1vvDqQZo44tslJc4VhbkiBRKtDH5iIwz3+tMClVDgDMcLoD01uhOfgC6kgiatF U00A== 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=Z4BBn59KnebMSkDpzvhH6Ny8FUDpIpAPU35JQ+/TAaw=; b=b8eNl5TaQnSq6XAw7TfsLfmlbvoIm/NgFXG2n8H7lbCasyLJndnCevy6/0edh4O/3D Nu5X9il4oUIDkDzWNhmatc7wBuwEOacf8XkUyvvfETJ3Hd7z46J3pSxyGonnqVmR7nR4 X6QzXL+0S5oGaWmZ7JDmZn/OTJxCy/pPrJ3VPRmA53wkm8wRpR45FECIsAZZA0OXtjQg x1IcYGXZcSGBYH09P3sae8jgZ212KgFZqKb1b7YQiRx2/QP7PsEDP+pRGOtDo5ydjVxb +HYBPit1brtEhJVUaOBDZiRWcMXHvgB0UU3x780BLiLqqv7yl+nfiwbiEREeCoKdHsQd vDxw== 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 f2-20020a63f102000000b00477abe15f06si22327477pgi.63.2022.12.07.18.13.35; Wed, 07 Dec 2022 18:13:48 -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 S229894AbiLHCMA (ORCPT + 99 others); Wed, 7 Dec 2022 21:12:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229701AbiLHCLp (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 3411192FD0; 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 4NSHhV5GS9z4f3jLy; Thu, 8 Dec 2022 10:11:38 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.127.227]) by APP4 (Coremail) with SMTP id gCh0CgB3m9jbR5Fjj5BiBw--.22193S7; Thu, 08 Dec 2022 10:11:41 +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 3/4] ext4: rename xattr_find_entry() and __xattr_check_inode() Date: Thu, 8 Dec 2022 10:32:32 +0800 Message-Id: <20221208023233.1231330-4-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--.22193S7 X-Coremail-Antispam: 1UD129KBjvJXoW3ArW8KF1kArW8Wr18uF4fAFb_yoW7XF15pF yUta4DJr48JryUur40yr17Zw1ag3W7Ga17ZayxC3WftF1kX3s7tFyFkFn5CFyUWr4kWw42 qF43K348u3WSk3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUWw A2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxU2PEfUUUUU 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?1751610166668276639?= X-GMAIL-MSGID: =?utf-8?q?1751610166668276639?= From: Ye Bin Prepend ext4 prefix to function names of xattr_find_entry() and __xattr_check_inode() for consistency with other functions in ext4 xattr module. Signed-off-by: Ye Bin Reviewed-by: Jan Kara --- fs/ext4/xattr.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 23cfefc6d262..99dacb0393fa 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -260,8 +260,9 @@ __ext4_xattr_check_block(struct inode *inode, struct buffer_head *bh, static int -__xattr_check_inode(struct inode *inode, struct ext4_xattr_ibody_header *header, - void *end, const char *function, unsigned int line) +__ext4_xattr_check_inode(struct inode *inode, + struct ext4_xattr_ibody_header *header, void *end, + const char *function, unsigned int line) { int error = -EFSCORRUPTED; @@ -276,12 +277,12 @@ __xattr_check_inode(struct inode *inode, struct ext4_xattr_ibody_header *header, return error; } -#define xattr_check_inode(inode, header, end) \ - __xattr_check_inode((inode), (header), (end), __func__, __LINE__) +#define ext4_xattr_check_inode(inode, header, end) \ + __ext4_xattr_check_inode((inode), (header), (end), __func__, __LINE__) static int -xattr_find_entry(struct inode *inode, struct ext4_xattr_entry **pentry, - void *end, int name_index, const char *name, int sorted) +ext4_xattr_find_entry(struct inode *inode, struct ext4_xattr_entry **pentry, + void *end, int name_index, const char *name, int sorted) { struct ext4_xattr_entry *entry, *next; size_t name_len; @@ -554,7 +555,7 @@ ext4_xattr_block_get(struct inode *inode, int name_index, const char *name, ext4_xattr_block_cache_insert(ea_block_cache, bh); entry = BFIRST(bh); end = bh->b_data + bh->b_size; - error = xattr_find_entry(inode, &entry, end, name_index, name, 1); + error = ext4_xattr_find_entry(inode, &entry, end, name_index, name, 1); if (error) goto cleanup; size = le32_to_cpu(entry->e_value_size); @@ -605,11 +606,11 @@ ext4_xattr_ibody_get(struct inode *inode, int name_index, const char *name, raw_inode = ext4_raw_inode(&iloc); header = IHDR(inode, raw_inode); end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size; - error = xattr_check_inode(inode, header, end); + error = ext4_xattr_check_inode(inode, header, end); if (error) goto cleanup; entry = IFIRST(header); - error = xattr_find_entry(inode, &entry, end, name_index, name, 0); + error = ext4_xattr_find_entry(inode, &entry, end, name_index, name, 0); if (error) goto cleanup; size = le32_to_cpu(entry->e_value_size); @@ -750,7 +751,7 @@ ext4_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size) raw_inode = ext4_raw_inode(&iloc); header = IHDR(inode, raw_inode); end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size; - error = xattr_check_inode(inode, header, end); + error = ext4_xattr_check_inode(inode, header, end); if (error) goto cleanup; error = ext4_xattr_list_entries(dentry, IFIRST(header), @@ -836,7 +837,7 @@ int ext4_get_inode_usage(struct inode *inode, qsize_t *usage) raw_inode = ext4_raw_inode(&iloc); header = IHDR(inode, raw_inode); end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size; - ret = xattr_check_inode(inode, header, end); + ret = ext4_xattr_check_inode(inode, header, end); if (ret) goto out; @@ -1839,8 +1840,8 @@ ext4_xattr_block_find(struct inode *inode, struct ext4_xattr_info *i, bs->s.first = BFIRST(bs->bh); bs->s.end = bs->bh->b_data + bs->bh->b_size; bs->s.here = bs->s.first; - error = xattr_find_entry(inode, &bs->s.here, bs->s.end, - i->name_index, i->name, 1); + error = ext4_xattr_find_entry(inode, &bs->s.here, bs->s.end, + i->name_index, i->name, 1); if (error && error != -ENODATA) return error; bs->s.not_found = error; @@ -2199,12 +2200,12 @@ int ext4_xattr_ibody_find(struct inode *inode, struct ext4_xattr_info *i, is->s.here = is->s.first; is->s.end = (void *)raw_inode + EXT4_SB(inode->i_sb)->s_inode_size; if (ext4_test_inode_state(inode, EXT4_STATE_XATTR)) { - error = xattr_check_inode(inode, header, is->s.end); + error = ext4_xattr_check_inode(inode, header, is->s.end); if (error) return error; /* Find the named attribute. */ - error = xattr_find_entry(inode, &is->s.here, is->s.end, - i->name_index, i->name, 0); + error = ext4_xattr_find_entry(inode, &is->s.here, is->s.end, + i->name_index, i->name, 0); if (error && error != -ENODATA) return error; is->s.not_found = error; @@ -2719,7 +2720,7 @@ int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize, min_offs = end - base; total_ino = sizeof(struct ext4_xattr_ibody_header) + sizeof(u32); - error = xattr_check_inode(inode, header, end); + error = ext4_xattr_check_inode(inode, header, end); if (error) goto cleanup; 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); }