From patchwork Thu Sep 24 12:23:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 2311013 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BnoJfrRl; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=dQknURvo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=hfaw=hq=vger.kernel.org=linux-ext4+bounces-19799-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (secp384r1 raw public key) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hrT6d40J0z1y0M for ; Fri, 25 Sep 2026 08:30:01 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hrT686Wb7z4wJh for ; Fri, 25 Sep 2026 08:29:36 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hrT686Tl8z4wJr; Fri, 25 Sep 2026 08:29:36 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=104.64.211.4 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790288976; cv=pass; b=C52+5fwTK669iBbZ3FIiPGBJGSuGXXCpZpAHYbulyj0H0ECTz4XQJBOEWDI0utUkKz6VFqxqoSaJ5QNrPPwdoLeUbYKU0mtkPHXL/NFEr/ZCTiF3lZ+ArsP0a28dtvKn3TWIzjX9jn9RHfBtgwNqYjFpA9u7rxaTNRkUL9D8XXZsnfwyMc62y4MNTF9AT/cXMNrO4ZAaFEY7IkXYuAVVZDxCwhVP+sYh9ZANBfjX6l65W/ag6XHXm0ucVnRXLj8tXl522LkmnNG/toqAbAcslX/xKYlgGVMqowAqp5vllVpQsvJh5fFJsE9a4BMUtzbRMm71VX8lqmPNBmgNOOWLaQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790288976; c=relaxed/relaxed; bh=rTB2RO/CzG7LyVzrq9FrGnKwZC4VXatX5TG2iW5jeXo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gjfY0kbfp5QlBlb864puX/jvV6wE4BcRcs7Qxnb147B3yEsiQJo0KJVIBkyqkO2v6T9e+3EzY8xPGWWSOTAlozSr+wIc3H/e/d44X7wQxfOCSIvn8xICnZpGEF+P+QzYHlk2PL7Kt/cdyvC7XPal5clgHJdk3Lwh32mJmnk6PTXm2TYkoxVfhpteHmo5N4RQm5PDdsc16d/71bnNDogJr71Vst4+xxaHoR5DhYxjXEZx1IwbxmlhiWVumIySpMoquSll5yq4JhcH7FZKRxfIwGV8N/taULExXfp0mI5W1lQMtpZjdNIxuVs97B0IJiWW9YWOa2ZSpPXxv1p1GG9HQQ== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BnoJfrRl; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=dQknURvo; dkim-atps=neutral; spf=pass (client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=linux-ext4+bounces-19799-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: gandalf.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BnoJfrRl; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=dQknURvo; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=linux-ext4+bounces-19799-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hrT650KQZz4wJh for ; Fri, 25 Sep 2026 08:29:32 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id 59CAE29D0D for ; Thu, 24 Sep 2026 22:29:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A058A40B110; Thu, 24 Sep 2026 22:29:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BnoJfrRl"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="dQknURvo" X-Original-To: linux-ext4@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEC63401A14 for ; Thu, 24 Sep 2026 22:29:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790288993; cv=none; b=TcL3sdcyKX5FOmNu75v/RRIUChZKdddCevC7xW4FL8fyTyh8ueSFnA72ZEO9McU89gB+38m27Ey9Cr5BponzTaCBYAa6gsseeQrbe2UKBp1gTwKl+9ZPoNO13d7QYfk2GcaATnfEAW49EYIBwwXrauS+2xfga/Jg25tP2qUbTJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790288993; c=relaxed/simple; bh=YKewhQV3t+qXR7VOIoLQfn8r58VjM08NCAraoc9ncrA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tn+dSLrlt4yFmsNXemqyvwAXEL+dWgvhHJs+RG5JAdnhhWZ64nKzPautbhdwpbmM08glMsvbBilNI85ySh4jEQOtqY8nQLdoZIY7h/lxyb70f58QevHim3wPZEh/YUj6eVK4QpJ9WgPtDfBEgzr3BG57vTRaaQpvi6iIZcG1hBw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BnoJfrRl; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=dQknURvo; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790288990; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rTB2RO/CzG7LyVzrq9FrGnKwZC4VXatX5TG2iW5jeXo=; b=BnoJfrRlWozTkDUBTNME/RhjQ+pCiNWOHY/bLVZuNQv32F7HLFC5U1nGIRxkbxqiF/p1kC bBkl9m17UQqBUxvqk84IeCL/jRWFCIXOK76za5HTxK/Czg7d3beYYo05mVh0KXDE9Smq5d J+8e+jv47bDlJViDe/4YTafy/lNg89I= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-120-S-O1j5vdP0m9ITuwaYRekw-1; Thu, 24 Sep 2026 18:29:49 -0400 X-MC-Unique: S-O1j5vdP0m9ITuwaYRekw-1 X-Mimecast-MFC-AGG-ID: S-O1j5vdP0m9ITuwaYRekw_1790288989 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-93bfb2da664so81716685a.1 for ; Thu, 24 Sep 2026 15:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790288989; x=1790893789; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=rTB2RO/CzG7LyVzrq9FrGnKwZC4VXatX5TG2iW5jeXo=; b=dQknURvoGanRSkMGtcD1VEtR4nHKYt0wUTmOhTjEDZs1uroJi3JhE5AZ9SMzr6O0zg Rqdmt3ADv3kkQr3PUS09RE8XANh3+9gCQP4hlFBcSNbOs20DEWicWHoINQ8IPOtghoJE rflVxLTgEfg4mALfc74RtPfov8MS/c/o9tFNcdTS01tWaAMSRy1a8Hn+nLl8WBa78A5X LtAki5ZTO01v9rttv429PvdgShNthDDnkfPOHr1Uy9caGVU1o0abyK40n1YNlfZfXpOe IAKR7oxKOaKGKXCLskE0wF7VB7jZ+jyBJ0zTdOKWsi4IK/j1sb8YaFTCz30G74X6xrbl wsQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790288989; x=1790893789; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=rTB2RO/CzG7LyVzrq9FrGnKwZC4VXatX5TG2iW5jeXo=; b=NjrMUDKAxkx4xMjqdK21UzeUouyBhDIhyfWr+MKO3BmpfNy5JDnNj4df7ikx6tLPFl 6veDJBuVIl1srsKVfMerhvCDb/8EbakDTXcItyI9veZuLD7GZPcY96uR/WKMdC+fax94 DrGoJdWRZ9rg3ql6tE5x+zaHqtMyCce9/XbkUxgSKpZJc2MH9dw+1DQBnmOB6A/n08XL 7fqZ5Hqay6TRyUFdsTqlJDfLdbca6DYc/TIqD5mFe8FIDQMtDjD+154qtbF0qRitztdP blrBQDPnD5qiJXW0cBVpaj882N+eCfxzg1mCysIm7FyyN44PM7/uTToISitBoZqYtSMW T9GQ== X-Gm-Message-State: AFuF++l/j4BcB0eiP/B2K5naSSv5LRgVStRDuUM8ffqWQlyVML+o3SEi zov8MNxshBVFQeqOeC2FkoonKpLWxQGPcXbIi79rJkr8P1fwBpWqRH4g6ZVMhHuqj5fGNXxizqS GxvfYLS3s1xP9QqRJ9xIeiHkZRXoZgPdbO8BUEarRV3M21Nmyw0w5kW+cBjJNbs7O8m2z59KGmm 8TAuB8HXDhFEyUabx1Ue1hP+4Tap2aZrPIEYMoH5cGbkqfJInQ X-Gm-Gg: AYBFou1KLQnT7aKQBTJJOyGKzLzdW/oKv1w3jpR7K8Vh5JMAMcUPyl0GZoMEDK7ers/ 6/Jfe9dIsVfVycBuEsGURefULRiGPsGROE/IAgpAH9ntI8mVSUDhL1pMIP+DmuXDZmcHufssGsE 1QQqTnQQb8IZEWPxwSKrQ/X98Mm7nWac1+3DLt+Ky6sP4vKSayFzriyP3ZtV8D7FHCwpIQPf9jj yRGvYHgCPIsu2wrjaI7bP/sMr903P6Ayhhl+6+1196Yr5GMj6yeW4uB1PB+7YSsMWfO/6aIeBaa 0utNUnJxcutBTqayY1nWSBQxIg+Qq35er11Li5C+PQEs5NKSD1ATBo8xil3c8ceCCpua7l7huYq aJOOpzXtkQ9q+qEZB9oyNjuFrzhFCNd5/KX4Fmw== X-Received: by 2002:a05:620a:1d05:b0:93c:739:dd5c with SMTP id af79cd13be357-93c4738b2e3mr30115685a.25.1790288988954; Thu, 24 Sep 2026 15:29:48 -0700 (PDT) X-Received: by 2002:a05:620a:1d05:b0:93c:739:dd5c with SMTP id af79cd13be357-93c4738b2e3mr30112285a.25.1790288988306; Thu, 24 Sep 2026 15:29:48 -0700 (PDT) Received: from big24.sandeen.net (97-116-156-223.mpls.qwest.net. [97.116.156.223]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93c44972febsm37216985a.39.2026.09.24.15.29.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2026 15:29:47 -0700 (PDT) From: Eric Sandeen To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, sandeen@redhat.com, agruenba@redhat.com Subject: [PATCH 1/8] e2fsck: fix in-inode extended attribute checking Date: Thu, 24 Sep 2026 17:23:35 -0500 Message-ID: <20260924222944.3683556-2-sandeen@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260924222944.3683556-1-sandeen@redhat.com> References: <20260924222944.3683556-1-sandeen@redhat.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Andreas Gruenbacher Extended attribute areas in inodes and on separate blocks are stored in the following format: (1) first comes the list of name records, (2) followed by an end marker, followed by any (3) free space that remains, followed by (4) any attribute values that are not stored in separate inodes. The name records and values are all variable-length and 4-byte aligned. The end marker is mandatory. A lot of the loops iterating over those extended attribute areas get this wrong. This patch fixes the loop in check_ea_in_inode: - First, we can safely assume that the total size is at least 4 bytes. Take 4 bytes (the size of the end marker) off of the remaining space to make sure that enough space remains available for the end marker. (We can safely assume that the total size is at least 4 bytes.) - Second, at the top of the loop, we can assume that the area contains at least an end marker, but we cannot assume that the list still contains an entire ext2_ext_attr_entry header. - Third, since the loop condition now no longer checks if we have a complete ext2_ext_attr_entry header, check if we still have a complete name record of size EXT2_EXT_ATTR_LEN(entry->e_name_len). The length of the name is stored in the first byte of the entry, so we can safely access it. - Fourth, value are 4-byte aligned, so take that into consideration when calculating the remaining free space. With these changes to check_ea_in_inode(), an 'Extended attribute in inode has Aa namelen which is invalid' error is detected before allocation is checked, which masks the previous 'Inode extended attribute is corrupt (allocation collision)' error in test f_inode_ea_collision. Adjust the expected test result. Signed-off-by: Andreas Gruenbacher Signed-off-by: Eric Sandeen --- e2fsck/pass1.c | 32 ++++++++++------------------- tests/f_inode_ea_collision/expect.1 | 3 ++- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index c9711446..555429b6 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -501,36 +501,31 @@ static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx, goto fix; } - while (remain >= sizeof(struct ext2_ext_attr_entry) && - !EXT2_EXT_IS_LAST_ENTRY(entry)) { + while (!EXT2_EXT_IS_LAST_ENTRY(entry)) { __u32 hash; - if (region_allocate(region, (char *)entry - (char *)header, - EXT2_EXT_ATTR_LEN(entry->e_name_len))) { - problem = PR_1_INODE_EA_ALLOC_COLLISION; - goto fix; - } - - /* header eats this space */ - remain -= sizeof(struct ext2_ext_attr_entry); - - /* is attribute name valid? */ - if (EXT2_EXT_ATTR_SIZE(entry->e_name_len) > remain) { + /* entry->e_name_len is within the first four bytes */ + if (EXT2_EXT_ATTR_LEN(entry->e_name_len) > remain) { pctx->num = entry->e_name_len; problem = PR_1_ATTR_NAME_LEN; goto fix; } + remain -= EXT2_EXT_ATTR_LEN(entry->e_name_len); - /* attribute len eats this space */ - remain -= EXT2_EXT_ATTR_SIZE(entry->e_name_len); + if (region_allocate(region, (char *)entry - (char *)header, + EXT2_EXT_ATTR_LEN(entry->e_name_len))) { + problem = PR_1_INODE_EA_ALLOC_COLLISION; + goto fix; + } if (entry->e_value_inum == 0) { /* check value size */ - if (entry->e_value_size > remain) { + if (EXT2_EXT_ATTR_SIZE(entry->e_value_size) > remain) { pctx->num = entry->e_value_size; problem = PR_1_ATTR_VALUE_SIZE; goto fix; } + remain -= EXT2_EXT_ATTR_SIZE(entry->e_value_size); if (entry->e_value_size && region_allocate(region, @@ -571,11 +566,6 @@ static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx, ea_ibody_quota->inodes++; } - /* If EA value is stored in external inode then it does not - * consume space here */ - if (entry->e_value_inum == 0) - remain -= entry->e_value_size; - entry = EXT2_EXT_ATTR_NEXT(entry); } diff --git a/tests/f_inode_ea_collision/expect.1 b/tests/f_inode_ea_collision/expect.1 index a67a5f19..dfe49a9f 100644 --- a/tests/f_inode_ea_collision/expect.1 +++ b/tests/f_inode_ea_collision/expect.1 @@ -1,7 +1,8 @@ Pass 1: Checking inodes, blocks, and sizes Inode 12 extended attribute is corrupt (allocation collision). Clear? yes -Inode 13 extended attribute is corrupt (allocation collision). Clear? yes +Extended attribute in inode 13 has a namelen (98) which is invalid +Clear? yes Inode 14 extended attribute is corrupt (allocation collision). Clear? yes From patchwork Thu Sep 24 12:23:36 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 2311017 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dqgtbIEK; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=OiZxXP3H; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=ng2m=hq=vger.kernel.org=linux-ext4+bounces-19800-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hrT6w1ZS9z1y0M for ; Fri, 25 Sep 2026 08:30:16 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hrT6R3rcRz4wCp for ; Fri, 25 Sep 2026 08:29:51 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hrT6R3nkDz4wJj; Fri, 25 Sep 2026 08:29:51 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=172.234.253.10 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790288991; cv=pass; b=YdyJz0vWVASfeZzc4v/0Vm9hzshTc9IbatnDC0JI238VFd7SzRD3mNQfrWkQphkMYx7u/zvSbXFSu2ZCO4cNwO9B9gcurZPdKxjUjKg5l968+QhzvDKOcgupiU5tqk/7YX7gtmkImevSSCLBjZCPuN6CrVHl8lhV6F2G4O9YPDvmJUbCUGfOc5UJLm6gj16Vh+ffEd5WKidCwERRuJAHUnfjo+F1S/16fH8dIfMaWzMRYusbIPJqSzaih4oBW17JzTmOfK/A6vuSLzJ4LKWF/MwkpFSPZ9W8xxDMcOZ5GuzkDcA3YRNgzqxS+MybWZTSoEdiezyk3ZtfwdpsR8WBOg== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790288991; c=relaxed/relaxed; bh=Jnx16kM9dVUjgz9S3hg7CrUBs+H3vT/ogFfVT/rQd9w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=x2+TvEO/NAw7873Po9nAZ3UMkcf8cUO6RQGRUh7eG8SO9M6D3VP+9fEdhh6yAyn90YxJVNWh4LeFweVc3J3Q6ewNRqK5vSDxjQTxGTx0rCr2PCr/ddszRYgltX6XaONoK9JEsvj98oW1P2dkO7EkbtL1sAZ0zWpEVTC/h+G6d2RplYLl0NYOp3y0ALTAGfwkCZ+xeN8y2Jtwxky86a5lTvAS0bLLt9/lnILYIfKIBkKs/wNLLXSNUSX6FVJHKDfO5x25l8dZGgClxMhI0a79jOD845HUXVnmftHWBSSZ30JXEahAu4+AkyhFZKuSJbwW2nj50+jkFPrzpUBrmwIJug== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dqgtbIEK; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=OiZxXP3H; dkim-atps=neutral; spf=pass (client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19800-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: gandalf.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dqgtbIEK; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=OiZxXP3H; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19800-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hrT6M6Gndz4wCp for ; Fri, 25 Sep 2026 08:29:47 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 1C4B367DFD for ; Thu, 24 Sep 2026 22:29:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C0881408031; Thu, 24 Sep 2026 22:29:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dqgtbIEK"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="OiZxXP3H" X-Original-To: linux-ext4@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13C333BFE3B for ; Thu, 24 Sep 2026 22:29:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790288994; cv=none; b=jqBv5c+Zc6fiGMWBWF+fAeC9XhUQObO7HjQICuJwczwrFnXZ9IYPQ4Sobe8YI5uaoss5rkD92+aTswap48/TbTnnayBpFK3c1Jcf3vgbFaYhKeHcj5dWJrG4H6ACzbtBMSTV8ZsZO1GZU2+T2VXlJ3RklI8GWhB61D3veLFIRhs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790288994; c=relaxed/simple; bh=jk2W4qW5Jvcpd0GdJiPdJSDciJZlk0IZGptCLebEpKg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jhest3avc0yXJjQpiINyyMVBb2YgwL2GjJ7jgRqFgGgCQ9d3jtD1E7+fSab05yUd4p6b8VEubO7B+szrANQXvP19/BMuWj0u/DGYCOCwzxTMgF4X7KPj9ytOUXkGBNYFhckzz8qvwliBDhX6dQWFw0ymR7dS98GE9Oq0kQNhPyI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=dqgtbIEK; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=OiZxXP3H; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790288992; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jnx16kM9dVUjgz9S3hg7CrUBs+H3vT/ogFfVT/rQd9w=; b=dqgtbIEK3o7c3JDm+PFELYdfiY1VN0eEltTBm6myFdBEA0jbuBP/fiSEOCHfIFzjyIg+qY sUx/cftx5DEhQ6bxGS4kUudy5hZyDQ9bbihT6sW9YrENTphj52Z/eWju8SrZXdr7p6T0P9 kxpYZn/6dvEKDybf5dx5eYXAA8FoKhw= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-691-LvQ3HQoeOZGG8urBHcsZdQ-1; Thu, 24 Sep 2026 18:29:50 -0400 X-MC-Unique: LvQ3HQoeOZGG8urBHcsZdQ-1 X-Mimecast-MFC-AGG-ID: LvQ3HQoeOZGG8urBHcsZdQ_1790288990 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-9390a2c895bso81142585a.0 for ; Thu, 24 Sep 2026 15:29:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790288990; x=1790893790; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Jnx16kM9dVUjgz9S3hg7CrUBs+H3vT/ogFfVT/rQd9w=; b=OiZxXP3HNQHvt7F+9RaRoIKn5fb9DbSBO5ZQzxEFCsIbLZM3YI96FE68CCp0Vvgj8z 8ebf+v03OQtIr83upgS0iN0FKsHYY4Xx9U18HV2B/WxFmZkZ1kAYMtMohn8q6dtBK7Vb IJUjSYuYjred27ff54yFO6fORs7vFrSNnNqBdEdYpV03iHOCFHECMz9kV+f2rHP1LdH4 A+a1rmM13v6UBg1rTGlWcKnBTQKVNK0k/+5qxquJSKr+sUIAOGj8rgUXol3sIXL8Rcux 36EwSQzztxXzmuE95TN0GORmrOnqVMTPjvLdYf2DbCRPiBTcOvmb2xMAE4T25PMl4Mef TzaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790288990; x=1790893790; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Jnx16kM9dVUjgz9S3hg7CrUBs+H3vT/ogFfVT/rQd9w=; b=WYDVaaEgmVExcNGU1opXTQ3i3rs4IRRQY80CgAytIK7stiDSZXdwpCJMr2ZetLVKHL Q4n+F78l5QuLJb7nY9gGAIwXI38fL/lbRgd11ZOUvTaZ7axDvRRglprUCXrNAZE4NCTD SgpPsHzbuqnXOJn3MP/kipJkbJo4wSVZg+FzQS1R2dhd7NYjOoY9B7aPG8o+i7vIPTtR iK8khGfW+DmpVdjx4rReQsaoahNjXvkEiYCjQzXKSUoSy0496/iKeK3j3pA9c7T4BoWO JFoMQxF6hIbqzx7mHy07z0UVvTgK41h489roI42MkbiViCai+GHtQYmn54xfguUFKMfe Fo5Q== X-Gm-Message-State: AFuF++mqlYMqCVALfZ7xRtRfBFiPk/WqwOEXBK1m7i78kxDQEvljDmbR ASn6tcdi9QBYHQvIHpzGfy9VeveP8CD9n++6p3RN7YLTc8xpy4Q1/N/IDnz3bfaNfMTNbmT1kKN bcQt3OmJ/ZMfggvbPLLQKubAmeBD2fyjlw4PnJaUpG4ukRZUjvgdBveZkTvZE2P9LG1YERvzF74 IIYoxoxdkUN8yZVglY7k/DUKzrUCu1ntdCajAZTUTkjJ55YfT3 X-Gm-Gg: AYBFou2qW3K+RU/o8DreGfCyrQEtwQg6tRdt9Xav9oE6eXrIigt7dBZ6ePJrJ7KI+Hy yUMafsn5r5j1UkHtJdirjPsB//2QjsiddmMrlTR8zn9sfidceP5rcu7Yqtwd7q52U+S2iJIUAh1 c5OpogYsyZFZFESwcv7Ct9Q+DIgzBpUi4i4ZOgH7e/I0bpBxdx+FPnWEXw9YUMxEoUZNyC1Iok8 vn4naSrwLNpD8pD2ayPW3dZfJ3tIGSuiso5dZv8Q30ha82suBbUG1PQZbKjkIzr22luRbain+XF YpAXiZCJYWCI65+giqo2F5KRTEDQIgA2+eHA+hCM51a98g1fPAkgCKO+2AU4o1gY7dTDoQQqMrf jK+L+egt0V+aLlIXkijhPzm25T6HwTejcUNP+LA== X-Received: by 2002:a05:620a:2727:b0:93b:eac0:ddd5 with SMTP id af79cd13be357-93c43e480bbmr141770685a.51.1790288990110; Thu, 24 Sep 2026 15:29:50 -0700 (PDT) X-Received: by 2002:a05:620a:2727:b0:93b:eac0:ddd5 with SMTP id af79cd13be357-93c43e480bbmr141766785a.51.1790288989639; Thu, 24 Sep 2026 15:29:49 -0700 (PDT) Received: from big24.sandeen.net (97-116-156-223.mpls.qwest.net. [97.116.156.223]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93c44972febsm37216985a.39.2026.09.24.15.29.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2026 15:29:48 -0700 (PDT) From: Eric Sandeen To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, sandeen@redhat.com, agruenba@redhat.com Subject: [PATCH 2/8] e2fsck: fix extended attribute block checking Date: Thu, 24 Sep 2026 17:23:36 -0500 Message-ID: <20260924222944.3683556-3-sandeen@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260924222944.3683556-1-sandeen@redhat.com> References: <20260924222944.3683556-1-sandeen@redhat.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Andreas Gruenbacher Fix the same problems as in check_ea_in_inode(). The 'entry->e_value_offs + entry->e_value_size > fs->blocksize' check is covered by the region_allocate() check that follows it, so it can be removed. Signed-off-by: Andreas Gruenbacher Signed-off-by: Eric Sandeen --- e2fsck/pass1.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index 555429b6..f66a2908 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -2493,6 +2493,7 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx, char * end; struct ext2_ext_attr_header *header; struct ext2_ext_attr_entry *first, *entry; + unsigned int remain; blk64_t quota_blocks = EXT2FS_C2B(fs, 1); __u64 quota_inodes = 0; region_t region = 0; @@ -2630,10 +2631,19 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx, first = (struct ext2_ext_attr_entry *)(header+1); end = block_buf + fs->blocksize; + /* take finish entry 0UL into account */ + remain = end - (char *)first - sizeof(__u32); entry = first; - while ((char *)entry < end && *(__u32 *)entry) { + while (!EXT2_EXT_IS_LAST_ENTRY(entry)) { __u32 hash; + /* entry->e_name_len is within the first four bytes */ + if (EXT2_EXT_ATTR_LEN(entry->e_name_len) > remain) { + if (fix_problem(ctx, PR_1_EA_BAD_NAME, pctx)) + goto clear_extattr; + break; + } + remain -= EXT2_EXT_ATTR_LEN(entry->e_name_len); if (region_allocate(region, (char *)entry - (char *)header, EXT2_EXT_ATTR_LEN(entry->e_name_len))) { if (fix_problem(ctx, PR_1_EA_ALLOC_COLLISION, pctx)) @@ -2649,13 +2659,12 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx, break; } if (entry->e_value_inum == 0) { - if (entry->e_value_size > EXT2_XATTR_SIZE_MAX || - (entry->e_value_offs + entry->e_value_size > - fs->blocksize)) { + if (EXT2_EXT_ATTR_SIZE(entry->e_value_size) > remain) { if (fix_problem(ctx, PR_1_EA_BAD_VALUE, pctx)) goto clear_extattr; break; } + remain -= EXT2_EXT_ATTR_SIZE(entry->e_value_size); if (entry->e_value_size && region_allocate(region, entry->e_value_offs, EXT2_EXT_ATTR_SIZE(entry->e_value_size))) { @@ -2697,7 +2706,7 @@ static int check_ext_attr(e2fsck_t ctx, struct problem_context *pctx, entry = EXT2_EXT_ATTR_NEXT(entry); } - if (region_allocate(region, (char *)entry - (char *)header, 4)) { + if (region_allocate(region, (char *)entry - (char *)header, sizeof(__u32))) { if (fix_problem(ctx, PR_1_EA_ALLOC_COLLISION, pctx)) goto clear_extattr; } From patchwork Thu Sep 24 12:23:37 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 2311014 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BAPKda22; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=OYCAy0CK; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=i46m=hq=vger.kernel.org=linux-ext4+bounces-19801-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hrT6f1Z2Jz1yGD for ; Fri, 25 Sep 2026 08:30:02 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hrT693pvpz4wJj for ; Fri, 25 Sep 2026 08:29:37 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hrT693kzmz4wJh; Fri, 25 Sep 2026 08:29:37 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=104.64.211.4 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790288977; cv=pass; b=IxS7Ww0O7hN+l9f7N39b1tokSQaMT8oa4S7sKb1Ik5kie8kmCM8V8TvTicKpetQ/uOGalZL/ZYIBctqBXMdxEBB/DhxEw9lwgOjNuWfC7Hcqhhk2BZ9C1LexTcyBH28/SA1EftKLamopHkbWYYcMgN/BjsixxvjlKIY5z75t+7SaIof3Fvc4Cy2SrrLythYfGFiI5Jr9xgmFqatjCG5IlppfofN6Hqfgr6I3+Ir/D1SO+Gz1ayX5acwrp+xCbw5RRDllIvv4B99xBdr61fbKyWr6HPR5nrtReZt5RUn4aLYdk2Sb7WDRv7v8vUhQ9x4qHuDQIQP7rgHHWgyYRkEyUA== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790288977; c=relaxed/relaxed; bh=5p57mMRlnlaa7EgtP52VlBRGCyHIZngOUyWVhdE+mZ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ERpa2nkJqQ/7jD/Q4/stBmMMdWEZ5y30kF6/Kj8q+MiBWBJrpgrX4MXwtbBeCZWkUcsh39Plaeg/g7hEbN8x3e6mBAGcl12uakkuRyzz34ILaf6HSrgA2xzJzEM/I7V58KrcjtyJ+MfSmWYRS+EHC+MVNlLgSoLEC/kXl4Vks+Z9EbumiUwA23aKL6YxZVPYQ0t9Cd4/ihJszitdWb4QsC8gmXYL/gnHfkZgnlBirY2R6kwmESNyhVkRrsdm9dpJtRHG5KXbALoB2+2heEwosT3d5pPB1mItQLXvAhUxirJSCaKAWmVUwWtOhKwIax8ZjPtze5UzD0WXkay86p/Lpg== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BAPKda22; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=OYCAy0CK; dkim-atps=neutral; spf=pass (client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=linux-ext4+bounces-19801-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: gandalf.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=BAPKda22; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=OYCAy0CK; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=linux-ext4+bounces-19801-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hrT654pYWz4wJj for ; Fri, 25 Sep 2026 08:29:33 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id E185B29D34 for ; Thu, 24 Sep 2026 22:29:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80C4D40963A; Thu, 24 Sep 2026 22:29:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="BAPKda22"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="OYCAy0CK" X-Original-To: linux-ext4@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0610540F73B for ; Thu, 24 Sep 2026 22:29:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790288995; cv=none; b=XgPTh+eDC2fnPnSDMDPumwTsoPNMm/FGjOnNOq2ti9FD8uyAe0/jsDh9qRwJkDZ1Pmk53jilovbYdJcw+wr0txypE2ZzU0cRaDF5iNnWt8feoBQrJKUIOtW/4+t5uWb5EHWX7qF17ycddDHeB5nQ9yhVxvyISEgdblonk3hIeWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790288995; c=relaxed/simple; bh=p4nXpfoqtEO/7pgk84Gd5u1p/zkdwQCRHndegxEOGzs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NLaTS8Npi64WwDS2p97fZpirMuzYY5FrscCmrN4UOieL6b3qVkESTqbUHidOqUtsExgmC5cnI1xt/1HQxi0mNERKGA2H/p+kMz0Te1n5jUuiEruWDJGYD01MTWHHVlv+JfvZLLqO7e3JnDcwQWHTuMY4zq6MA37vxZPL8tCyKh4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=BAPKda22; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=OYCAy0CK; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790288992; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5p57mMRlnlaa7EgtP52VlBRGCyHIZngOUyWVhdE+mZ4=; b=BAPKda22y3rCqPgDMuMq3u4Z6MNeIxFqr60fVW4iiWQQYSHn42wtdaNNoUvEEJFNZwo2R0 dDi8eXtBt7Sl527vDq4tfywfb+uqiUe4F3zTjfikbbn5cBOwOZ+gcXGm+W8/ddn4LI56bp FMQ332gd3e8w1+8elF7RYLCS405oRw4= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-DjdS-0UtN_2-nKRJZROuWw-1; Thu, 24 Sep 2026 18:29:51 -0400 X-MC-Unique: DjdS-0UtN_2-nKRJZROuWw-1 X-Mimecast-MFC-AGG-ID: DjdS-0UtN_2-nKRJZROuWw_1790288991 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-93a05d645acso58173085a.2 for ; Thu, 24 Sep 2026 15:29:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790288991; x=1790893791; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=5p57mMRlnlaa7EgtP52VlBRGCyHIZngOUyWVhdE+mZ4=; b=OYCAy0CKFE8CBqtOBam1v8IlPD3PeeqhkwB7GggNSc+CH6uiXkVPNl9+wmE+aN0gzi fMDDokvyWj4XlVHcCCoevtlUtG2VwWmlV9imTa0Fw1k6Yvxl5IQTIXimQvsigMMujlPP hNPilu77Ccuen+/wXhtyUuaFlgXFYRg9svCTkPt5yD7IJjQ2Pd9Jkaoi6rfSQ5Xim3QG yT0JMtfxrWbh7lpKW7ONGCN5NqCozoda4nKxCGjlMy49w83RFzZBJkuzjx5FVyolw/FD X9BF7M6CDcBnWJsz9A/hgFFtJB8vbOQTDEdeeF8i1Dwfy1AVIgkJf5mRH6Azsl4CIHJA MNAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790288991; x=1790893791; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=5p57mMRlnlaa7EgtP52VlBRGCyHIZngOUyWVhdE+mZ4=; b=Ddpui3rnDSUAOTVCShKckpQhQCJeTfw+8/kRdUJ4yUA4Cpf6L+uHmHPNVX0y48WGT4 l65b22F/COSnvFChUCghrHhG5QU8UiFteZD+uoMcsrBkGsMTWudSNdq7pIL46ySrjM80 T8tyUlvroJ3IpQPFq6kQEumaL+fJ38EFWsJ54foJ72aynZLPACsXFRV893TFCIXJJTC0 xb+v7nyJOcB6B7s0ptzriHOE0HVeesNActDdCXPvdh1V/iaBdhPpyQCbCFVKF5vmKi7H rpqyu2RwbnOMDX0GOorpTNBfE2Q4JUPTTTP35OY+MiF8Moy7f2ubjAJAiwqncqKXG74B mN7A== X-Gm-Message-State: AFuF++mRMLktqps1rar/1lGWrUG+sVeYYyoVz9p2iW4mCy5gNtjSkoz/ TXZ42uIGDvw8il9HgAp5wIsM10Q1gPF2r6nckyXqU6OLpPC0Yx/XVfWnzs3QKWqGl0rv6fMqxlu CqewpQWbbC5y3wT4NkpSL3pOYNVJ1BSmtB8r415LF186t9WWKoZ1PN4s6QbANjl7yCCBm1sQme9 5yq3xHlbFsoIqQZE/5Vqw4pwDctG0nUYOpJ4s4ixKd03ACJJci X-Gm-Gg: AYBFou3+aDqFNOpGHXoylVpwKrwGk5hCnfnF7yCzBguqiMvLMY6ReDsUl/ySlbZ5OiI X6CPuFWt88Zofw9K8FYmFrWOFski8dpnvtpGrHUqt0ZAUu2IgMpzFXZaw3FmUkP5TNyysycFaeV 55BOpIzd8CCptDMfULN/e5fkD2nuKCT/jEL183q1ewyfr05EQoz8Xc0x2aKt64lL1NAA0SGyjBj Y4A6x+CxF155Smhbo8Mp8S04mAVrfSBECWSDBPR8pStK+TN5Q9zaIrDsDRNiKmjkgI2XP/YlcDo mjMHq/DCI47KalEmp9DzGDnel9uS0QXwkNoqTpj9an5ZJUcO2Z/2zTRskrPRBas7brpk//F4ZSB mfBTJHnI1MlpnmAtI0AeWQYU2WTuiPI+MKVuqVg== X-Received: by 2002:a05:620a:2954:b0:936:d360:2eb7 with SMTP id af79cd13be357-93c43bb9eeamr132128185a.20.1790288991204; Thu, 24 Sep 2026 15:29:51 -0700 (PDT) X-Received: by 2002:a05:620a:2954:b0:936:d360:2eb7 with SMTP id af79cd13be357-93c43bb9eeamr132124485a.20.1790288990709; Thu, 24 Sep 2026 15:29:50 -0700 (PDT) Received: from big24.sandeen.net (97-116-156-223.mpls.qwest.net. [97.116.156.223]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93c44972febsm37216985a.39.2026.09.24.15.29.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2026 15:29:50 -0700 (PDT) From: Eric Sandeen To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, sandeen@redhat.com, agruenba@redhat.com Subject: [PATCH 3/8] e2fsck: fix ea loop in inc_ea_inode_refs Date: Thu, 24 Sep 2026 17:23:37 -0500 Message-ID: <20260924222944.3683556-4-sandeen@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260924222944.3683556-1-sandeen@redhat.com> References: <20260924222944.3683556-1-sandeen@redhat.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Andreas Gruenbacher Fix the same problems as in check_ea_in_inode(). Signed-off-by: Andreas Gruenbacher Signed-off-by: Eric Sandeen --- e2fsck/pass1.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index f66a2908..e47e3b04 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -412,11 +412,16 @@ static void inc_ea_inode_refs(e2fsck_t ctx, struct problem_context *pctx, struct ext2_ext_attr_entry *first, void *end) { struct ext2_ext_attr_entry *entry = first; - struct ext2_ext_attr_entry *np = EXT2_EXT_ATTR_NEXT(entry); + unsigned int remain; ea_value_t refs; - while ((void *) entry < end && (void *) np < end && - !EXT2_EXT_IS_LAST_ENTRY(entry)) { + /* take finish entry 0UL into account */ + remain = end - (void *)first - sizeof(__u32); + + while (!EXT2_EXT_IS_LAST_ENTRY(entry)) { + if (EXT2_EXT_ATTR_LEN(entry->e_name_len) > remain) + break; + remain -= EXT2_EXT_ATTR_LEN(entry->e_name_len); if (!entry->e_value_inum) goto next; if (!ctx->ea_inode_refs && !alloc_ea_inode_refs(ctx, pctx)) @@ -429,8 +434,7 @@ static void inc_ea_inode_refs(e2fsck_t ctx, struct problem_context *pctx, refs += 1; ea_refcount_store(ctx->ea_inode_refs, entry->e_value_inum, refs); next: - entry = np; - np = EXT2_EXT_ATTR_NEXT(entry); + entry = EXT2_EXT_ATTR_NEXT(entry); } } From patchwork Thu Sep 24 12:23:38 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 2311018 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Fhxri+hQ; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=kAPAj8M2; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=og0e=hq=vger.kernel.org=linux-ext4+bounces-19802-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hrT764K4bz1y0M for ; Fri, 25 Sep 2026 08:30:26 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hrT6d6b9qz4w9b for ; Fri, 25 Sep 2026 08:30:01 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hrT6d6Tt3z4wCp; Fri, 25 Sep 2026 08:30:01 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=172.234.253.10 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790289001; cv=pass; b=m0qs6sDFOq7qySBzIw9TAy/EsG0nkZedZn+9PxIErKNqFEB+uiV/iEiYplVBEnmvDDhzNd1tEplbcTfyu0B2zQrK1zHHWvxJKOjOYCqipxqd7v/1zGajQt5rP2VjpeSssB4l7+k/ZDa+788MhFvc6LoTHnGcw66e8v1+D5MYv4xxby6nyMLVcFkzqDmuIoDxt9YDSlfkxe932aOjiBSIb+JGOM2pTXaK08PynwyMHFBJigNMPJuX97Ng41WRuMDhYxMm6/kfV1mvt3sTcD3xie03uWeQ3s5ASwtc6nTrXDqSvTZ3tk/B8n3K0lBiF72jNUcu+V1EmTbDRI7P5KUf3w== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790289001; c=relaxed/relaxed; bh=uj4ZEezBbLqzG6SLUO8frwWEZvEoztuY9E9eoB5GByg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IM2o2TEXCOqdZjOWEDQTbzDRoYcwXoIc8nR3EZcNNa6yhFalJsiRSzvgndMYRGo7O9vDVne6MmNI2HhAAuDgSLqeEzNpIO25IrgDEpO5sQ7t/rYyHRt2R/LHKa+DZMassUiIvWCq+0tGKf9MpWajeLn3ZvtlSwQ15DyYFztt1yM/Wgj4XA86NqDCWf67K4gL1A+euMYjAaTnPPcuGrfIxVklQjMqW9jfTR/qmE72I26ZbouudtHErY9ikLChfNMj3Bg5JldKcdGaK2GoSTws80ogc3sjdVcqmSfxoTt1GUiCnaUSA2dMvXw/HH4S2prcHGHwzfFvxRiKaN45G6W6UQ== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Fhxri+hQ; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=kAPAj8M2; dkim-atps=neutral; spf=pass (client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19802-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: gandalf.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Fhxri+hQ; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=kAPAj8M2; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19802-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hrT6Z2rv5z4w9b for ; Fri, 25 Sep 2026 08:29:58 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 55E2568447 for ; Thu, 24 Sep 2026 22:29:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1CBDE401A14; Thu, 24 Sep 2026 22:29:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Fhxri+hQ"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="kAPAj8M2" X-Original-To: linux-ext4@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78087408031 for ; Thu, 24 Sep 2026 22:29:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790288996; cv=none; b=nuIFmRhF+YPx5UoDylUAlbWeZuy/jSnVJxZvd0o4eT3FiXyFsvssB3xzH9pnUYZV7Yaveskg77dyKO2nSCBIdlvsk35JVqumW+9DsW8mpil+npVna+3CdqRQv+RzCzNZiViHLb7PVvuPNlnK9C0HlHdri3yWw3FX5zWYBP7AUPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790288996; c=relaxed/simple; bh=VaR0LHHzy+BPFpibJZDxbc+2EhNc/NiPSGMTWqdYFBc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NqGbGLn/ol4nSJkDrLLDEZfdHPk7Ffxo5QIgUFwIINvIib0BbOkluNQeXvEPV4dut6S0HblRuqEtPdwN034Hy7UCmj8HElRDmmXWfgbLK99KZ/NOm93pgR7yEq0uQ6j5e1CSZMQboEd5XyYlsAng9pvJjc5eMfiz7s1grV/5p88= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Fhxri+hQ; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=kAPAj8M2; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790288994; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uj4ZEezBbLqzG6SLUO8frwWEZvEoztuY9E9eoB5GByg=; b=Fhxri+hQIl8zZn/Hg3Etahi8et+r4e8pJPRNADB66Arxv0QaJLPgh4/ZiZv9xB6SxZf2J2 fOGYL7qjziG6AzpQmCB39fADQ+VRTZjXkoZEXNfNIPJEOSDDfVD3jO52ehwkViUzqijFKB QKTUpE3b4UMp2KAGgll4hHODI8BrX24= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-682-yIQgc4yhPPi4hz8g4PhLBA-1; Thu, 24 Sep 2026 18:29:53 -0400 X-MC-Unique: yIQgc4yhPPi4hz8g4PhLBA-1 X-Mimecast-MFC-AGG-ID: yIQgc4yhPPi4hz8g4PhLBA_1790288993 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-93a3f673221so79249785a.0 for ; Thu, 24 Sep 2026 15:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790288992; x=1790893792; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=uj4ZEezBbLqzG6SLUO8frwWEZvEoztuY9E9eoB5GByg=; b=kAPAj8M2H/+zvrSEM9mH81sqJGS6iVJmo5VIa4bLkrhnZOsXaF3fXctkmvhiGVN0d+ 1Ij3cnPp6lbX17bPKuzuZ2ks47ApsmXA58GrRlvl72KtdohnthNvMKBEMnkAxyXMwyYw U4Wj27TRwBFP4WPoL21l1lN4gsyUq0F4q27/RxboHG6dUJlccDUA93HtN1bTedmkEBAv XjtG8adtp+ykV7v+yBLRpbs92YApPg4GFmGsle6UkO5iK7Xe2mvu2vXBRbgAhOC+wst4 jn6hKUFjsLQDeoNyqn6dTjh5L3A/wFHhFQTQQC5uRVfmAs7yP9ZTUf/h/bQf7nJs8AvN /AFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790288992; x=1790893792; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=uj4ZEezBbLqzG6SLUO8frwWEZvEoztuY9E9eoB5GByg=; b=WyB9+y9EgchUixou29Gakyt6s1IIBPKb9j1fVkCtwIKhtnTpBwYu4GK3ohRk6SD8ns rLHc/TBE9GkgBkkYw9P1IS4tt+EzvJ7pz93071KzmWx8DABjfAD00eNp1tUYc2Mt6giW ubTcOvF743AXYvkcAVsujboa26svvJvewORNqJjXJazHCZnzMPAjc96AqIy74b/RZxTN IQ85oj70/JCLo5JntBGemqtQD8FA5QU8CcgybvzXdHWRrRN5XqyIEeaoYqO/bt7sa7e0 kb5EeKFNFfESqxlveJTfVnyaX6CxrdOlgIajQeL0V2+1/vqgzBhCGks5xNaS0M5ntXHY Cnfg== X-Gm-Message-State: AFuF++mNQutvqrPxKitRYlDh2Ej69umBzy2b+UwfddYQELYXgq9vYYAg BWEdiIOJ3oIpfv3NBAla/AT3D0a5nzdRuA1mroEPfeeqq93DQvkm3zfObZ411M2In/ObFbPEGtT TCyqAmLPNlBUoZ8Z5PKQXfELMtvXf5reS7DzSdmHC1Ya8kDFyF7jvHxBDHVgZxNB5yOiTa6OajR stZD/aXkiHt01umiFXKbtoQgRXx1IIijKRetpCNCJykMe9Xr93 X-Gm-Gg: AYBFou3l1B2/3noE7gifFow9sh141HZA6hYXataJao9P5QOrE306xzUnlVtHt+FQp+g nQAyDU3F6MlX5eQB7GNIkZ+Y5M22fPvjRDlEmNHoMGXW6jmQxwbApuB48aYZdEo0ezZnzjfymv+ vqyqUOR4diSlfWPVGhqXXXG1ZwqzkT5pN1mxAIkhVbxF+ztbG1EXP6/hXJzp1tZ/8o5YFjFYPb9 oh5JtyQgwPjDo+ioVo+ZFNXmuxPLuRwB+OdBdORow0lwfS5Xo8AsErCTFn1Fsj+cN9Er8HlQ5FZ 9nC3tje3uc3i1vqwRiFj+HFahwS4nplfxKnQSiTfoTBuYiZiTWr+ZLED7pPEB6wgNRtmCk5KbUz KKJ0fpVJ/FmsyN1EHD2fFiCTzzcnW9LtfSf4+cA== X-Received: by 2002:a05:620a:6602:b0:939:3a81:326 with SMTP id af79cd13be357-93c47498e61mr29985785a.37.1790288992445; Thu, 24 Sep 2026 15:29:52 -0700 (PDT) X-Received: by 2002:a05:620a:6602:b0:939:3a81:326 with SMTP id af79cd13be357-93c47498e61mr29981285a.37.1790288991760; Thu, 24 Sep 2026 15:29:51 -0700 (PDT) Received: from big24.sandeen.net (97-116-156-223.mpls.qwest.net. [97.116.156.223]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93c44972febsm37216985a.39.2026.09.24.15.29.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2026 15:29:51 -0700 (PDT) From: Eric Sandeen To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, sandeen@redhat.com, agruenba@redhat.com Subject: [PATCH 4/8] libext2fs: fix ea loop in ext2fs_ext_attr_block_rehash Date: Thu, 24 Sep 2026 17:23:38 -0500 Message-ID: <20260924222944.3683556-5-sandeen@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260924222944.3683556-1-sandeen@redhat.com> References: <20260924222944.3683556-1-sandeen@redhat.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Andreas Gruenbacher Fix the same problems as in check_ea_in_inode(). Signed-off-by: Andreas Gruenbacher Signed-off-by: Eric Sandeen --- lib/ext2fs/ext_attr.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c index 7723d0f9..914bff1d 100644 --- a/lib/ext2fs/ext_attr.c +++ b/lib/ext2fs/ext_attr.c @@ -163,10 +163,17 @@ void ext2fs_ext_attr_block_rehash(struct ext2_ext_attr_header *header, struct ext2_ext_attr_entry *end) { struct ext2_ext_attr_entry *here; + unsigned int remain; __u32 hash = 0; here = (struct ext2_ext_attr_entry *)(header+1); - while (here < end && !EXT2_EXT_IS_LAST_ENTRY(here)) { + /* take finish entry 0UL into account */ + remain = (void *)end - (void *)here - sizeof(__u32); + while (!EXT2_EXT_IS_LAST_ENTRY(here)) { + /* entry->e_name_len is within the first four bytes */ + if (EXT2_EXT_ATTR_LEN(here->e_name_len) > remain) + break; + remain -= EXT2_EXT_ATTR_LEN(here->e_name_len); if (!here->e_hash) { /* Block is not shared if an entry's hash value == 0 */ hash = 0; From patchwork Thu Sep 24 12:23:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 2311022 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Xm2sOxLS; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=Y7d2yDN7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=lxa3=hq=vger.kernel.org=linux-ext4+bounces-19805-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hrT7W2klkz1y0M for ; Fri, 25 Sep 2026 08:30:47 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hrT724TfSz4w9b for ; Fri, 25 Sep 2026 08:30:22 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hrT724Rz9z4wJr; Fri, 25 Sep 2026 08:30:22 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2600:3c0a:e001:db::12fc:5321" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790289022; cv=pass; b=NDV7MzyPLOhz0koSyMunTc7/XzHbx7CMzZzN8BIOHChao60Zz0ZUsS2oT6rEERjaguZpDMtH8ifqoKqf54NXS0a42X1U1TtTppIXseY2JMP5pA88fx4BYzi386DKd6/sxzJn8ycpzWYoduYGlK40Mu5/GbED5qjLeo0SWDsc0BYC/6au43SOUGLUlL/pLJu9FVDI+btrse6JwW2AcinHSWSbPtzzMSZ8oESJ5G2vXDDbMNvouTGBZnIVn9YtSKreqJxreIzxdUZixLxCuN+fe/J/ZaYtBLGMUFn0FpsGiGTjMWY1WYBr6PtOYJQ7Sgywlth9bEauwmp4Rc7fxgV29g== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790289022; c=relaxed/relaxed; bh=maziDtTtq6Bths82FexowbFXRko7tUV+THFhllPjGS0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XGSXfs9PkYcaZcnI6Nbp5BWv+hba0KdT3yn+rvswuYM6XgU01KkREiF2yi5DZQal2v4DlDQpuWJodcs4D5nIVGZ0gFRBrqGoJEp/gu8V3gHwiMHF0TpoqB/Vlp+gl72LfTS4/pBu8aRL32Z7yN9dfRdmnbd2Xkx9ankpjmz7IRz/QFO4sq9G3qzWAs3fEOQRiIDc63/eH4N8eAlucY2ikzGpoY5vZV1452z21Dw6jcLarebWa4xXCHfJ+lIyWp4OQC1yVNv6IZBS3qxttmwwajOoFvf57JZk5aV74ToQJ+4HKWWdStva834G/QMLqRfoSMLf3ot4XvDK2fuyFXj8MA== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Xm2sOxLS; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=Y7d2yDN7; dkim-atps=neutral; spf=pass (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19805-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: gandalf.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Xm2sOxLS; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=Y7d2yDN7; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19805-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [IPv6:2600:3c0a:e001:db::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hrT6y5fFRz4w9b for ; Fri, 25 Sep 2026 08:30:18 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 0B7E068A0B for ; Thu, 24 Sep 2026 22:30:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B5A5408031; Thu, 24 Sep 2026 22:30:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Xm2sOxLS"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Y7d2yDN7" X-Original-To: linux-ext4@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0087A40B6FC for ; Thu, 24 Sep 2026 22:29:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790289000; cv=none; b=XYBJgnrRvLcFY/8pQhxjSX8IG4KDII8YCFmjIdHVWyTXeEjm8hvWCNdbt/niEBAFkl1yRXunI+tZiy5pVpkxyH8xmg++Ge+tQoKEQe6fIUO1iTxKr5dNAjuRW5bb5PNEKOLKSPfWtnYwcx9VkjoCS8vI5V7MerB0UMYFSVqzOqM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790289000; c=relaxed/simple; bh=IhRNBpMOLPaoAruJSr1anXnxKzHCYaHizvngL6qDbzM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F8xul/kMlY1nQpNy7te/l0Ygaa4kDNJqeryaoHErpnVMFd5s/nvvicLSVUj8os0R4BBEWNdCpoJOR3uCkGBIjL0TtPVXzNuJsYh0om7wTDBPStAwiS6zyqz2Ib/T5zqsl+y0jKwh0gDXNBp1XnS/QHQ+K+dMLb2TKPEXM7jDK9s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Xm2sOxLS; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Y7d2yDN7; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790288998; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=maziDtTtq6Bths82FexowbFXRko7tUV+THFhllPjGS0=; b=Xm2sOxLSITFE4vBA+/eUxxtxKkI2dN+/H9GuLgb5WLk14LESppYRLLUGX6ckRtRMJz4+ZJ U1ATukOFx+NoSwB2Y+eeR0r4ASnFktsba6o1DdlaPn4vBY5IlHZv6Z7DrQ8LpPcxJ1WV6p hr9Y3vOhk+uJX2r0duaYPhC9Qy8IP3g= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-629-TtwmM2hxPV-lXTeBPD4DOQ-1; Thu, 24 Sep 2026 18:29:54 -0400 X-MC-Unique: TtwmM2hxPV-lXTeBPD4DOQ-1 X-Mimecast-MFC-AGG-ID: TtwmM2hxPV-lXTeBPD4DOQ_1790288993 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-93a0c7126e7so50948485a.2 for ; Thu, 24 Sep 2026 15:29:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790288993; x=1790893793; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=maziDtTtq6Bths82FexowbFXRko7tUV+THFhllPjGS0=; b=Y7d2yDN72NwBuiZE4jPJq2orxX5CUKmIb3pYrmetP8W9GiXAiqV5movHHPlR7LRUqs neh+Sypu7AeN/2ENm82GRM6vyIPax/a8VoQPnuF0HC9DfYyqxQOD4R/efLm+0528xx3f uulo+xUXP43Ph7V9B5g8T1nMLyVuCYuui9oz2xfE2Fm8Qs4vDOcYznzJv15+zJusD7OW vu7SdRDaKjw3xAMBBc+qnx90URl+0CLyLTN/Z4ihTBJjPHZSTH1EmMCTam3mik9/6voA dpKfofq7bN5i3DdNDwNDpTKo45Tn6CvNxr7T73v5yD2YqDZ72gZ1qne5J0w9dbJXmSDs 5yGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790288993; x=1790893793; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=maziDtTtq6Bths82FexowbFXRko7tUV+THFhllPjGS0=; b=H6LLLn+PDx6en+yjZS9JfjzrymazJIHpOIb6bp9QOzrkV608FCFBGZjTKl7+CILj0e j70zRW/FZAfJiZEyZKbVS9XVYTeG1uxcXOfhHTNHag3w25ZMh+d80Qlus4uTd8rNMVkG U3GbPYwQYAKDD458g7gXBZnQx5lmNaQetabxF+U2v/AffDDumF5jVlSZjVDVpc4CzYMU d/WxsqQqvwonkiCES3oWPl7eFEcQQaSUTgza6va+ZTexExsVR03W0saacHfLVa7/oWlC X9RQLhT8wpgnn97+EO8V53uExq7EWn5gbmvTBK6qPgkWhHSaTruOrVDyr3FnXKjHc8It fgcg== X-Gm-Message-State: AFuF++m4LygAPGsalMOFZnZDkCQQmii56sZibaDuCqTEalnQGsYy4IRY vlwmYaNAMu2AOGaT0hLX4XKc0nUHFL2sV7xgA6u4iTn7jUVPXd+eHF8PVo7adXfgorCEZ0NJh7+ NrtxB4BVUTFu1WIqkbUVH7zV1SHTnclr0qW3tqQ/VCfQHK8EHCg0qO4tT8RN+VNL2y/zJboE3Iq KTMbr/1pGNI+27xN23asETDcmbBuPLgW7uLoRWUntC5BvRRZ3w X-Gm-Gg: AYBFou3J1747ULWvzW+v2zH3y9UK5zwtOXJlZJaKg2c63cYGFHMIECvV8oJiGk/B1dW 79jTAiKFENG8aT7AkpQnuKz30BUxWbfaROziTwrH0K/i45dzE8UIW5yV6RqoNWHTmZOHT/YSJmY plMwyQP1LT1/9YLSiJ+Yb1cLiea8x1lvXJLYumJCUcy+wFPD9c8V2isGpvBsFNHCZWVxlpg3eu9 gfJL+fIhaTFz4qTccnlMZxw+gJLqB5v1K/lElgCytdiNDgehjFnu31BJguhux1dSot/SfCIB377 dFWQyNRvQs2g2fPDlfjTJ0HlFzcBjbqlAJ7ZLNMLOgKiekI3tWQDvRYETEwenklrTvtLibqweK+ Bq/AaGnKl0Milnebar/rLXPZK7kL0RTV0I8LMJA== X-Received: by 2002:a05:620a:4515:b0:939:6df9:6547 with SMTP id af79cd13be357-93c43d16ae4mr140140785a.51.1790288993355; Thu, 24 Sep 2026 15:29:53 -0700 (PDT) X-Received: by 2002:a05:620a:4515:b0:939:6df9:6547 with SMTP id af79cd13be357-93c43d16ae4mr140137485a.51.1790288992867; Thu, 24 Sep 2026 15:29:52 -0700 (PDT) Received: from big24.sandeen.net (97-116-156-223.mpls.qwest.net. [97.116.156.223]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93c44972febsm37216985a.39.2026.09.24.15.29.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2026 15:29:52 -0700 (PDT) From: Eric Sandeen To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, sandeen@redhat.com, agruenba@redhat.com Subject: [PATCH 5/8] libext2fs: fix ea loop in read_xattrs_from_buffer Date: Thu, 24 Sep 2026 17:23:39 -0500 Message-ID: <20260924222944.3683556-6-sandeen@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260924222944.3683556-1-sandeen@redhat.com> References: <20260924222944.3683556-1-sandeen@redhat.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Andreas Gruenbacher Fix the same problems as in check_ea_in_inode(). There is no need for recalculating the remaining space in the second iteration. Signed-off-by: Andreas Gruenbacher Signed-off-by: Eric Sandeen --- lib/ext2fs/ext_attr.c | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c index 914bff1d..6f6d2f4f 100644 --- a/lib/ext2fs/ext_attr.c +++ b/lib/ext2fs/ext_attr.c @@ -884,26 +884,23 @@ static errcode_t read_xattrs_from_buffer(struct ext2_xattr_handle *handle, /* find the end */ end = entries; - remain = storage_size; - while (remain >= sizeof(struct ext2_ext_attr_entry) && - !EXT2_EXT_IS_LAST_ENTRY(end)) { - - /* header eats this space */ - remain -= sizeof(struct ext2_ext_attr_entry); - - /* is attribute name valid? */ - if (EXT2_EXT_ATTR_SIZE(end->e_name_len) > remain) + /* take finish entry 0UL into account */ + remain = storage_size - sizeof(__u32); + while (!EXT2_EXT_IS_LAST_ENTRY(end)) { + /* end->e_name_len is within the first four bytes */ + if (EXT2_EXT_ATTR_LEN(end->e_name_len) > remain) return EXT2_ET_EA_BAD_NAME_LEN; - - /* attribute len eats this space */ - remain -= EXT2_EXT_ATTR_SIZE(end->e_name_len); + remain -= EXT2_EXT_ATTR_LEN(end->e_name_len); + if (!end->e_value_inum) { + if (EXT2_EXT_ATTR_SIZE(end->e_value_size) > remain) + return EXT2_ET_EA_BAD_VALUE_SIZE; + remain -= EXT2_EXT_ATTR_SIZE(end->e_value_size); + } end = EXT2_EXT_ATTR_NEXT(end); } entry = entries; - remain = storage_size; - while (remain >= sizeof(struct ext2_ext_attr_entry) && - !EXT2_EXT_IS_LAST_ENTRY(entry)) { + while (!EXT2_EXT_IS_LAST_ENTRY(entry)) { /* Allocate space for more attrs? */ if (handle->count == handle->capacity) { @@ -914,12 +911,6 @@ static errcode_t read_xattrs_from_buffer(struct ext2_xattr_handle *handle, x = handle->attrs + handle->count; - /* header eats this space */ - remain -= sizeof(struct ext2_ext_attr_entry); - - /* attribute len eats this space */ - remain -= EXT2_EXT_ATTR_SIZE(entry->e_name_len); - /* Extract name */ prefix = find_ea_prefix(entry->e_name_index); prefix_len = (prefix ? strlen(prefix) : 0); @@ -942,9 +933,6 @@ static errcode_t read_xattrs_from_buffer(struct ext2_xattr_handle *handle, return EXT2_ET_BAD_EA_BLOCK_NUM; if (entry->e_value_inum == 0) { - if (entry->e_value_size > remain) - return EXT2_ET_EA_BAD_VALUE_SIZE; - if (entry->e_value_offs + entry->e_value_size > values_size) return EXT2_ET_EA_BAD_VALUE_OFFSET; @@ -953,8 +941,6 @@ static errcode_t read_xattrs_from_buffer(struct ext2_xattr_handle *handle, (char *)end + sizeof(__u32)) return EXT2_ET_EA_BAD_VALUE_OFFSET; - remain -= entry->e_value_size; - err = ext2fs_get_mem(entry->e_value_size, &x->value); if (err) return err; From patchwork Thu Sep 24 12:23:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 2311016 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LgB5nyfp; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=Zwv6qwof; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=oue1=hq=vger.kernel.org=linux-ext4+bounces-19803-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hrT6k6k5hz1y0M for ; Fri, 25 Sep 2026 08:30:06 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hrT6G1x6Lz4wJh for ; Fri, 25 Sep 2026 08:29:42 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hrT6G1tzFz4vyd; Fri, 25 Sep 2026 08:29:42 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2600:3c15:e001:75::12fc:5321" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790288982; cv=pass; b=uDr6RT0vDReaBWJP1OKvgW1gLc3HlTujwPWMje985+A7BQChyvT7SIwz+ysVUnCMvS44cKWric1duOG8HD2+nluqZyfyF8IybNvunDnm1xQwATqJ5fzDP3aEMu9+RQZ+xs8VIVMaRZXTImcAOxombqsTZMMGKp8qxkSan/TcadHdeXpeOPZF+l6Fy0msBmnjZU6gNYbwEkghGoozbbv3CpwkkaL9Rm6X8O5suP+a6OdlE1wkUAW3R6gQLR99LqNS3RMT0hjud8EvYjSzbs3a6ZcE2gkWW1WDK8PXX7M6IoXU0+N7oKO8SetqzyB6/1dmz9+H4bDME/OMQvAGcHltdA== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790288982; c=relaxed/relaxed; bh=RRnKSw29LPfBR39OwnUDPjIAAzlsglHeeVWlyGhlZ48=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fwfkb5yc6/uQwgg+8eGp50fQ5ygtRFo18qz/1NigDmtZdRRRkvVOKjf3Y8EImeKTcCySSkLhB8jRe0cPPTfjngYUjS5YTWpY7UxKZkyVTaMh33n9uPWVxi8v7mquuM3Va5sQ56h9YGJZY5YAJ+mmBi6D2rBn8CNfeft2hvYh6NGp8xZJa3egpk7JZTwLs3aJ9C0aRYxfJlbkRqmH60napoksc8Jf/niMHErbDme1HosvFXLHeF5YLmfpIrC5/7Po6AI2iAujjPdfEtZ36cDFHuwzKMHqxRy/tz8FeebfKMRHw2z26gO9tCqqCgQwXS1VUMVOXXDrmTDL+5rLwXevaA== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LgB5nyfp; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=Zwv6qwof; dkim-atps=neutral; spf=pass (client-ip=2600:3c15:e001:75::12fc:5321; helo=sin.lore.kernel.org; envelope-from=linux-ext4+bounces-19803-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: gandalf.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LgB5nyfp; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=Zwv6qwof; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c15:e001:75::12fc:5321; helo=sin.lore.kernel.org; envelope-from=linux-ext4+bounces-19803-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sin.lore.kernel.org (sin.lore.kernel.org [IPv6:2600:3c15:e001:75::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hrT6B4jPYz4wJh for ; Fri, 25 Sep 2026 08:29:38 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id B9E5529D27 for ; Thu, 24 Sep 2026 22:30:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ECCC940B110; Thu, 24 Sep 2026 22:29:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LgB5nyfp"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="Zwv6qwof" X-Original-To: linux-ext4@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D345409298 for ; Thu, 24 Sep 2026 22:29:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790288998; cv=none; b=sRb06EihIEVeW9j4rbxfO0ydKR8XykiONumSh7/LjZPNRJNNHwlWijec+vmrBFZmG6y8KtaBEF/z2YfXz3xJVT8XBM1UzB3Bre5yUa1jvL4c6hInPiF090JLo+w7tu5dri21okcONDEPWzr6Dh6BF+wI86H6kOSycjUrJCPik2U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790288998; c=relaxed/simple; bh=JAv4eCIf9DAWqH1mt1mZ4UR+MvLY6DLtquzfEX3xSeo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uCD1+xHbG+yhHoR0P/m93zDvIdpGqkB570NPXdN0TaSxfRJ0xqnJcDzK/xu25Dk8UAQuXGXON7c8RgtBk8+vNf0KJOMVMXNyaR5MCuoxq18HY1ZqzbSxs0f/oByweZwyTBf3XLOYr7wAHKeRoTWCjQ29Vts3X6JqQZBmgF9HNSE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LgB5nyfp; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=Zwv6qwof; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790288996; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RRnKSw29LPfBR39OwnUDPjIAAzlsglHeeVWlyGhlZ48=; b=LgB5nyfpNekkIyqb1AmUkoKtJgK/kh2AaFPLMQNGCZcqdx7T7hbShD5I97m9ZZVxv8Wl18 eDvmTxhjMUvY1ecOiWtwjLEkQpq2kFn0zucH+73STp73bpo6w9hcX2FFKJWHEnVgRACOGS +5rbMEL1jQ0KzboYhTMVVkfYoTKy8Ho= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-189-vTK2QgKXN-WdEjsjYUSDvw-1; Thu, 24 Sep 2026 18:29:54 -0400 X-MC-Unique: vTK2QgKXN-WdEjsjYUSDvw-1 X-Mimecast-MFC-AGG-ID: vTK2QgKXN-WdEjsjYUSDvw_1790288994 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-93a1de6d5c3so67865285a.3 for ; Thu, 24 Sep 2026 15:29:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790288994; x=1790893794; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RRnKSw29LPfBR39OwnUDPjIAAzlsglHeeVWlyGhlZ48=; b=Zwv6qwofedw0uw/RP8eVF6jSlAYRmQ0mmlb/PD4IICKdDS58CMPSRST0YEJ4hLm+mN Y75Zx1Pi8KFjfKQDFqZprmP6lLkX9WXOp2OoJBvEIIg6avZAIG8XELS0J1J9P2IiKhwj pxcK9LVvrO0jYKAOM82Vo625okNCYaQNWanhULIbDzLaR2zdmABFTfBE+AqB1TtXt1v8 bS3jCrUQ1QwsFhyq52N3RAGz/UTCa9qL/lrflz9lJ/CmRq6jKWQ5rW047XfJ8QqQJdZP zi4WA0z9wYHAjFDhHWP7yVhcAYE0CaRoEd/Yr/Kw7UOL/KZyWnpWouDfRLCo1c40atst oCQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790288994; x=1790893794; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=RRnKSw29LPfBR39OwnUDPjIAAzlsglHeeVWlyGhlZ48=; b=lqlN9csNUNtfS9uXr1nFjyUqo+n4cY31QlbqpS9kdUtWnBN1EeZ9vJcXy6jmuXQO/k /ZoI902QrOBjtq00ah2rcfepS2HpHuHFkyR2H3uhP+rTxdweTIki8YHwdjua+xhqbYFI uebW3t2DMrtx+pxIdU6nDxbcOW9zhWJK1gAa76rr2mvSzYe7x3MwLlSFstXxo95t8l4k iNboYGnzlm1xkr/orlSK0N/DLl7nWLrCAGR67WPr3Mkb5Tq6hy37o3RXMy+dy0ihXK34 VcR2Tt1GBg9Fn+2irDwscElhVoizdvf0mGDCFXoAvT2LRKiizWbBZOIDSaley7mFh7eW dk2A== X-Gm-Message-State: AFuF++lzwZLPJQ0wrpMHKglo+m9OWdsRtXV2AxK1s7Cw90dOd8Pwlrsb 0Oxuo5EkVzhNt+QFYuPh7461BsQ4sa4r0ztGfkKRdz0WxGt10Sc6q70ftt+2N73vW29pPeTF6+q FSipVq5T8NmjhGbHdRWAGrxGrdFDjYgM+1af8Z3PNYRFrdmO3v7eoNtki6xj2biuXTodpk6q1Gy AehSoVcn2OgOFRRiGtW5UrmzvbZms5AXmtDIlXEs6ILCWnSu7A X-Gm-Gg: AYBFou3VmnNQIUJbQ6KTjTY/ph6OZISv2fnqDA+Me/78k84XttJWD/2Jj2lSg3514c2 Ws8zMinhqKcRV44C9M2c0zXQZe4vY/T3R0cf2/uXWsW/vap/3DkQjKU/qGjcYhfKn8N2obDVV2N ahDeG9ytGaoBD8HuiBaNrR84DBa2/NPpqEZRmVZB07xGyCsOtVkMIDDVVkj3iWz2Gwp9eiZDxon IhrSvj7iL2PzqTPl6JXo/yjktkaLs6hQysTLqQM2mNWQ7Kev5T7TmYT+BGQt+OuHuAoP7/AIaA7 VNp5LswG3f3hn6pJ3WQrXdByjBmHJg3JyFCduvIZxG9KKGkupD4E+d0DXCNO94njxZb8+OuVrDC XBPhiLZn1tyFOe973JAHw/YjzlL0M3sQaQ/Okrw== X-Received: by 2002:a05:620a:700c:b0:92e:bd39:9993 with SMTP id af79cd13be357-93c43e0e3ccmr120933485a.31.1790288994352; Thu, 24 Sep 2026 15:29:54 -0700 (PDT) X-Received: by 2002:a05:620a:700c:b0:92e:bd39:9993 with SMTP id af79cd13be357-93c43e0e3ccmr120929785a.31.1790288993822; Thu, 24 Sep 2026 15:29:53 -0700 (PDT) Received: from big24.sandeen.net (97-116-156-223.mpls.qwest.net. [97.116.156.223]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93c44972febsm37216985a.39.2026.09.24.15.29.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2026 15:29:53 -0700 (PDT) From: Eric Sandeen To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, sandeen@redhat.com, agruenba@redhat.com Subject: [PATCH 6/8] tune2fs: fix ea loop in update_xattr_entry_hashes Date: Thu, 24 Sep 2026 17:23:40 -0500 Message-ID: <20260924222944.3683556-7-sandeen@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260924222944.3683556-1-sandeen@redhat.com> References: <20260924222944.3683556-1-sandeen@redhat.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Andreas Gruenbacher Fix the same problems as in check_ea_in_inode(). Signed-off-by: Andreas Gruenbacher Signed-off-by: Eric Sandeen --- misc/tune2fs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 2d85fb70..53a7a1b2 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -774,13 +774,19 @@ static int update_xattr_entry_hashes(ext2_filsys fs, struct ext2_ext_attr_entry *entry, struct ext2_ext_attr_entry *end) { + unsigned int remain; int modified = 0; errcode_t retval; - while (entry < end && !EXT2_EXT_IS_LAST_ENTRY(entry)) { - if ((char *) entry + sizeof(struct ext2_ext_attr_entry) >= - (char *) end) + /* take finish entry 0UL into account */ + remain = (void *)end - (void *)entry - sizeof(__u32); + + while (!EXT2_EXT_IS_LAST_ENTRY(entry)) { + /* end->e_name_len is within the first four bytes */ + if (EXT2_EXT_ATTR_LEN(entry->e_name_len) > remain) fatal_err(0, "corrupted extended attribute field"); + remain -= EXT2_EXT_ATTR_LEN(entry->e_name_len); + if (entry->e_value_inum) { retval = ext2fs_ext_attr_hash_entry2(fs, entry, NULL, &entry->e_hash); From patchwork Thu Sep 24 12:23:41 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 2311019 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DViykgxw; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=VZltkrsn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=bt2m=hq=vger.kernel.org=linux-ext4+bounces-19804-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hrT7L2yrVz1y0M for ; Fri, 25 Sep 2026 08:30:38 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hrT6s5GZzz4w9b for ; Fri, 25 Sep 2026 08:30:13 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hrT6s5CWTz4wCp; Fri, 25 Sep 2026 08:30:13 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2600:3c0a:e001:db::12fc:5321" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790289013; cv=pass; b=QlX8D2j86WBD88dsWNRgjjQJH9qmwMa776fuQlpHDRwYhRVzk6pGYcBEtXnZUX67K+4451Y/8G0i3eUwV3etQqkJaesWWc/t7etZbyDKNj+azcgxBc8W129EzYnpqYx0eG/QZc9XhFe+wlRkOQCpK3e/e6SM+6nhXNUAwddq0xA2O+HqJ12hWl9c4lTYkCXbn4Xm9h2mUPzpp1zpbDvP25WLC8MdnYKwNPaLNBPdsIV+XsNQXIp4zJ2Yl47VxZfMHkBK0zjAQtmT62z3wwlngdQCGYr87iuN4g6wJf526g1ofEHN/FcISOHdH3o167D1PEZjsFM4gBNpdmabWrwnEA== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790289013; c=relaxed/relaxed; bh=xMcSTPpN5kocTVflAfMX/xt5pG0WUj+FRla3DJ1xx94=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JSt6dbEoJUxkb6w+jHNv5U8QVbZaykvcfTao7Q7i4k8VYXisTqgdYCHZjJ2NDK++P0NNlXIidBVz/K+plEgByY0AoEKBfxe6RKtJ9txgUsnIKBmcH7FicRTpaCNTu7QmLM0mV5ZzayXw+Uzh9gdbSszRAXXYUX6SVzUJqZIYQolrpRMW8uAnrQoK6qAR6OZyAxNMgJ7KZpSWeEizhRKnvOXH7U62cuza+61rrIqLmmQOeOJcGY8iw2IPTXzpy72aa6OXVznopqLZgz+uX2RDRkG055kAV8rj0zzZUa3WPL1hxAThLCaTYvgnD0QJRmwi0BnSnasZiH4YzGUFDmta+w== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DViykgxw; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=VZltkrsn; dkim-atps=neutral; spf=pass (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19804-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: gandalf.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DViykgxw; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=VZltkrsn; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19804-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [IPv6:2600:3c0a:e001:db::12fc:5321]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hrT6n6pGTz4w9b for ; Fri, 25 Sep 2026 08:30:09 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 7554E68774 for ; Thu, 24 Sep 2026 22:30:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 21D34409298; Thu, 24 Sep 2026 22:30:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DViykgxw"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="VZltkrsn" X-Original-To: linux-ext4@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9CB54408031 for ; Thu, 24 Sep 2026 22:29:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790288999; cv=none; b=TnPahlcOjT8GhQr/jh42FnqxqcW+xWbfV3U0IDa8UbyOULkwCEva70cG4EKwgp9ObSkvX7mOzUSQjlFWu9h3064I4IwTTamvo7F9LsWzrmYHpaqzkd+3EYqDKAf1m4EBUk/RB7MzRbVaUqb4Ht7DUMHo1cYmVm8RPfznNXlzQv4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790288999; c=relaxed/simple; bh=UdERNbAB8vlra4wXL0TO2IlxSkvg4HTfl53kERB8wy4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IP+uPqA1a+eOx5uZ4t+4cgd3+YXd4eZY2V6/hDGvNPnT7/KSeSikLRxo6or85dDkqLxJGJYe9n0usQDrMR8PukXkFaDuK8BxUb3s2V74IWHE8tGjsHJK8rISHIpnAx/SeD0joov9JAwMpSXiA/hUjpi2Dalzl0Ff6RWuAYVSivU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DViykgxw; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=VZltkrsn; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790288997; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xMcSTPpN5kocTVflAfMX/xt5pG0WUj+FRla3DJ1xx94=; b=DViykgxwD1ymFPlOHaQv0eBB+pa5m/46p0QfZNiOkluXtaMtNASffa50Map7URvGIY/KhG wNn2RLJQ6m8BsdV+I7YVf2xQqFS1iHWe6rc34/9Qso3S+AM/t9ygtm8G+HeHF3RzU39mh1 IqjKySeoj7X7Fr77U8cGCT8Sn1ymNUU= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-696-0EkR1kx0MBelTyfSbBnWew-1; Thu, 24 Sep 2026 18:29:55 -0400 X-MC-Unique: 0EkR1kx0MBelTyfSbBnWew-1 X-Mimecast-MFC-AGG-ID: 0EkR1kx0MBelTyfSbBnWew_1790288995 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-93a183a0e93so64303085a.1 for ; Thu, 24 Sep 2026 15:29:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790288995; x=1790893795; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=xMcSTPpN5kocTVflAfMX/xt5pG0WUj+FRla3DJ1xx94=; b=VZltkrsn13iaErBytvAt656Ky/i2+xuKIH++3pFY7XTOsh4BC2+TwYDDGPBSeS6G3q gRZOFdTG+x4i/IJUrgriq4CM/x/5mAj9ZbmW53wNpkYx/dQYwq54RGrvGcCyYxhbdodX iD0CF+TJ5IUo+gIDcYLw5DvopdjruS4t74kxRDTWV9XS5BYPMdgVO+lABULh8ZlWcp1u ikfqk47aiP/DbmNWZmGbYYo9L0eGdQq1+66BohslNqsZrg7ucbGJuzn0gvQ4gC4kvNAm 22NJ/j+Nvy3jjouaJRQsFw628fdGsccY/dIu9vkdk+ws0HylF0u/h/I1Jm+ZkgpzvRBT TdnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790288995; x=1790893795; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=xMcSTPpN5kocTVflAfMX/xt5pG0WUj+FRla3DJ1xx94=; b=dxbx6NbeeWwgB2jKibdlp/8YLyjNoC+Z1IX8jbfFuODz0AMig6w445vsCu+80P9e/K alhlQKV3YKF5WJ91DXs6TQNpa+ZMWNdq6ZWScoN+DEuo2Djnl2ajmQm71V8QG/owudV/ 1mnVDqtTG57p47PcvPPzusbFn5x+lLrRJuVEc6b+wTdLrdt+oZxC5o8AL7dOX3EkO/CZ vIXTZky3sDdYcLxueVawz4DHP6yiCiZcwpXxg2pNduUM7ZT7hOxCkTNRaqKOrt4qc7Qa aV1SIAESyOVRdV3jwRTE0esdRkGSSrgmAmDn+q9tEDI4PFfe/w9YwifNBX7xyJaXgH86 YhEA== X-Gm-Message-State: AFuF++kS7o9ii1UfK19HrFL2YHcLHfr5Yk2i55j5bnfBosB2ZDwY4+qN BjDkv5lHqeE+fJrwemCqDD6KfcO3YVcCwJE3pFxQQuDQmNCLchdNCBLV1MpP44z369XuIIQmuLz xZfxkW47BTJz6+FIlW2nCWdLIziok/12lGw3ssURk3iv4UJ6rPVt7YGtdOFXh3hhOtYsgzhkUaG P3ok5byWDNB/oJV7p95bTTmu7+tdeKefNOvXiKO7XRJ4BmVGZp X-Gm-Gg: AYBFou0XI/xMvJDiAO299dVUF7qfVc518S5SY7nUHMKlW/bv1BGXgWet8zMhIh//aFN N5lVkXB8ZndrS1LLitlnd0TPnoOWAnGtsM5kkzrbsJc/ztgPwA1aCYxnNNZlDmj4ljGcsY6zZKa elGXHlLjLhVXMmrEpO/ef3RRGjN+JU8p9pGpBMAv7XtQb4JmWmL/c78aNIpWMt6GpbQvHF/VLH2 AO0FRKHwDxf5SjJwEJhwb5GOePwwEJL1UiTNmOLdEtVMtnPMhDzrP7NPiBWsJciY13uM3lUyJUI OqAIC2VRFmBptIC2z7J4xMuA3OshMsCRRvX47YTfZENEfxus4YinTP2318bp8fRjMhpO6JEw3P1 WwTYLOQpptxBQGJXxlWv2WDgu6da3UbMIzFykVg== X-Received: by 2002:a05:620a:4612:b0:939:5ab4:e6ab with SMTP id af79cd13be357-93c43b8352amr148130185a.5.1790288995140; Thu, 24 Sep 2026 15:29:55 -0700 (PDT) X-Received: by 2002:a05:620a:4612:b0:939:5ab4:e6ab with SMTP id af79cd13be357-93c43b8352amr148127185a.5.1790288994695; Thu, 24 Sep 2026 15:29:54 -0700 (PDT) Received: from big24.sandeen.net (97-116-156-223.mpls.qwest.net. [97.116.156.223]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93c44972febsm37216985a.39.2026.09.24.15.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2026 15:29:54 -0700 (PDT) From: Eric Sandeen To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, sandeen@redhat.com, agruenba@redhat.com Subject: [PATCH 7/8] resize2fs: fix ea loop in update_xattr_entry_hashes Date: Thu, 24 Sep 2026 17:23:41 -0500 Message-ID: <20260924222944.3683556-8-sandeen@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260924222944.3683556-1-sandeen@redhat.com> References: <20260924222944.3683556-1-sandeen@redhat.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Andreas Gruenbacher Fix the same problems as in check_ea_in_inode(). Signed-off-by: Andreas Gruenbacher Signed-off-by: Eric Sandeen --- resize/resize2fs.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/resize/resize2fs.c b/resize/resize2fs.c index c8964af5..49aa039c 100644 --- a/resize/resize2fs.c +++ b/resize/resize2fs.c @@ -2039,13 +2039,28 @@ static void quiet_com_err_proc(const char *whoami EXT2FS_ATTR((unused)), { } +#define fatal_err(code, args...) \ + do { \ + com_err(__func__, code, args); \ + exit(1); \ + } while (0); + static int fix_ea_entries(ext2_extent imap, struct ext2_ext_attr_entry *entry, struct ext2_ext_attr_entry *end, ext2_ino_t last_ino) { + unsigned int remain; int modified = 0; ext2_ino_t new_ino; - while (entry < end && !EXT2_EXT_IS_LAST_ENTRY(entry)) { + /* take finish entry 0UL into account */ + remain = (void *)end - (void *)entry - sizeof(__u32); + + while (!EXT2_EXT_IS_LAST_ENTRY(entry)) { + /* end->e_name_len is within the first four bytes */ + if (EXT2_EXT_ATTR_LEN(entry->e_name_len) > remain) + fatal_err(0, "corrupted extended attribute field"); + remain -= EXT2_EXT_ATTR_LEN(entry->e_name_len); + if (entry->e_value_inum > last_ino) { new_ino = ext2fs_extent_translate(imap, entry->e_value_inum); From patchwork Thu Sep 24 12:23:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 2311023 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=I/mAihiN; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=GYBLjAQq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=9bnh=hq=vger.kernel.org=linux-ext4+bounces-19806-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4hrT7Z46yDz1y0M for ; Fri, 25 Sep 2026 08:30:50 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4hrT756PyNz4wJj for ; Fri, 25 Sep 2026 08:30:25 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4hrT756NT7z4wCp; Fri, 25 Sep 2026 08:30:25 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=172.234.253.10 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790289025; cv=pass; b=b1QJYhSMFYcqRMlOJUeT/bytzefOmr9eFAhT8XFMHc8gde8WkF7oIWp+0slhwx4jXHiOhyIg9vebdOTGCAnCyW5OvYG2mXYrAPyMdayEDyzSJxnfnwczr5uUkmPAGYojmG+syEHUvfl8tMldSOIfJjXdDEPmte6xm0EKryjPpgxNNYdMCezXJ80lp9JI4OWFG5afsr2QWCdj17jLcqlJpC8mhIE/GzNo1w5RVJWJhw7loeQTKovkL0iRFyqmV1d7+fWUf1NrqoMbN5Xq7gsnwuAIs27FVUzFjjC3/NUTdBYn2zBjzZNEjlI/UG4Dk6M6Po491dwfa6HpI8z5XOsonQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1790289025; c=relaxed/relaxed; bh=/JPbKcTBOygIosoT5NJIzt0x/bV8oQDNYyTuHPzROr4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iWLUrbMbuhu/IM+fPnEBBneqa5TVDSiCJ2+uZv9ORJalXajV/aQD5YBbmDMsWp68suy4x1CYMV1C0zZ11pLDFqlUMyjiIu9BsR+fKLtND8NgenV+JwqO8wKOLD/yiAOp1LOKNmfOtOBt1n0xW03llCFATuaQWb2V2S+JL+7oR4dWE+mlAez5dd3J8rr/p3mbt97/EMoT6cK2cv+Cyk5/lIHFXBiBnyie4Ia28kFSFidIKA6+gWcCqz/wRXLLk+1XIRbMVS1iDsdIJ4meVI8W3fFDUMPLEn5z18vYMAYwQRabHrFomYY98MSakMpMbYI2NuE/hhi7z8nuBhsTWGGG9A== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=I/mAihiN; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=GYBLjAQq; dkim-atps=neutral; spf=pass (client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19806-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: gandalf.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=I/mAihiN; dkim=pass (2048-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=GYBLjAQq; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=linux-ext4+bounces-19806-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4hrT6z6nr3z4wJj for ; Fri, 25 Sep 2026 08:30:19 +1000 (AEST) Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 225EA68A80 for ; Thu, 24 Sep 2026 22:30:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8DB441442F; Thu, 24 Sep 2026 22:30:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="I/mAihiN"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="GYBLjAQq" X-Original-To: linux-ext4@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1F0640A926 for ; Thu, 24 Sep 2026 22:29:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790289000; cv=none; b=bGEMCgULIbW6djiy5F3Ao0VtzMWAKAzI1V6MTkGWc7Kg6aYcvVwyv02u47lnKugWBv10r/9Q+Za329Dz1tdAe2qgwW6b8mqF0/WDVPr3KyRPVtHWdXqx+NSXm4dZ3232Ci7YPg5Gpyv5++04gmZqaMxSWr9Y2Pp0aO09rRH+WSk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790289000; c=relaxed/simple; bh=IQZ5Qz3B02DHilP8/lrHynVk/gWCWnZRlP5K2MsqtuI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DVm58Db3SCQvcNnhzCTOkwe71wuW49+S7QcGtRLNn0FJeedSrBD9pj15DANaUeAjDpbDAm6OD1GgYIlC01U7DU0FqQT0726Jg9d3bAil5Z+qW7Oo+c9tJeaQJqHleTSZsqT57JjPJ9h32QxzosFs6sf+fnYe3OIipdHQREZucC8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=I/mAihiN; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=GYBLjAQq; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1790288997; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/JPbKcTBOygIosoT5NJIzt0x/bV8oQDNYyTuHPzROr4=; b=I/mAihiNIPVUz6mZpa44Za2iOAKyfStWhOCj9ZDiBv5/HcPJoDfqFMwQw6ksGYYTXCmVud W2wghTMRVVjCglnk0ctdQdeF/+VjOcQdigEOqr9SrtoWa0DCzBGg7Nstpf63jDuevvE7wH 9OeG+h9vMyegBQZ97uYTbo0Uqw9bk6c= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-269-SYxe64uDMUajuuYBmxTOQw-1; Thu, 24 Sep 2026 18:29:56 -0400 X-MC-Unique: SYxe64uDMUajuuYBmxTOQw-1 X-Mimecast-MFC-AGG-ID: SYxe64uDMUajuuYBmxTOQw_1790288996 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-93ae8e7e546so59587185a.1 for ; Thu, 24 Sep 2026 15:29:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1790288996; x=1790893796; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=/JPbKcTBOygIosoT5NJIzt0x/bV8oQDNYyTuHPzROr4=; b=GYBLjAQq+d5u6do1eLJ3ESihX6qUNACW55NhFnZjDJvxq60VRFeoGnsUY62ynSIEHi sOHG+UdUNqinpVVBIbVOgd3gqeAOyQ7MK4VlCOTqVh6+r9W1m0JZ1NK2RD0Q00eQx8XI NSazJM17TYDR/c1GAFuMplU8OAcZnHlvKSZmuLstSjZiyAuAALVKHnE2wkWZBLokNg2/ glnsaZhWQiaPB62cOsVvoyowMUYLur16qytHUAWOtmgInxjfysZ89X2bm0RJQIbH0xEm x42vPHs5CYjypTUKCnzLFqK5dc64+nw+EvUXIg/eB+v3f99KYC5Bc/ioOmVWhC3+RBCj 3wWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790288996; x=1790893796; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=/JPbKcTBOygIosoT5NJIzt0x/bV8oQDNYyTuHPzROr4=; b=xlE2ggeEKmeKpsENEMOoYyk9SHG05l1NppFJeRTv0d4tF5nbsjwKs4vXe7/SRj0G+U KoZhQ6AA7rYAESXd8vl3Hr8HO6ufD0G/JaGErxSSezF9zXRJmdqghKXQAakzrxg+yWmJ NDn664/Vbjgcw0fzOAoiX8cBNtCvGFZgouCeHZ+KU8/TNRiOeVBmLtpNxg86q+SgsCz+ kaVrnUEtZFMBUeaGFRYBAUzfs2t7QmaQ2ceuGMsB3e7LVwN9JgkZNmXha9tvKcpkDaKm nlIxWXFUvA08zEOxQB0Wtwvb8Qwsl0H0peeL9floXB6iqC7q29Ts9T/eg27TANbmMC02 ueeQ== X-Gm-Message-State: AFuF++lsO4akyQghQonCZPXNUEqPgu6IZXQRFqEQNUaL6Utj1+jsczQR 49x63L4B1d3LqtRAXUblhPIrcdcutALDc9AolGAXAwe47FER76dTptQI5RdDoKLiiVw5AjC2u/S mrzvk/tEoOJo4S22OXoaq8f7JmsPVAtT+lVgB9pY0jtsgc37dLdU29Ni/elvASYUXFN4zfUxTWQ 3sW+DlRCiFDwaRNmRhCkcb6Hk+WxhaSET8aC7GtOjtZ45ABDfj X-Gm-Gg: AYBFou3ipVtvd1UZrKIxr1DmTFO+vD+i9/z5M0OIIDaQa/u/BDb1XUReUJ9WPocn3Es HeBHtOPAB+h6kUCXorIZpLEC4fNCeYCQeY2vra3UwOO6HPb/eDE6StYoMVXD4e682soOKuDr2ol 6xtQZNqDbqVbWhfYa8KdaVqz9LTG7nfJMPfcsVPhc2889ad9/6MsmZFJG+vc9RyJysvVVWIU6td 51Uri4+Sh+V+Tl2t4kbe4qncqEiRcWxBOnJCV+50SGEcaxotpUjsSaG8toZzI0l79DHHhdjVmwa a7miS/vvCzSSEgYW5i70fKY1a3g4x+FdD+7CIo7aH5dzEdtlZGt0P2b5KI44i6HIvN4hvP8yrV5 lskeDx4+4Kp+S2qg1OJKzvejTjkScZT0FhzQI5w== X-Received: by 2002:a05:620a:414a:b0:939:9b1c:ea4c with SMTP id af79cd13be357-93c43bc93b2mr151443385a.28.1790288996044; Thu, 24 Sep 2026 15:29:56 -0700 (PDT) X-Received: by 2002:a05:620a:414a:b0:939:9b1c:ea4c with SMTP id af79cd13be357-93c43bc93b2mr151440685a.28.1790288995533; Thu, 24 Sep 2026 15:29:55 -0700 (PDT) Received: from big24.sandeen.net (97-116-156-223.mpls.qwest.net. [97.116.156.223]) by smtp.gmail.com with ESMTPSA id af79cd13be357-93c44972febsm37216985a.39.2026.09.24.15.29.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2026 15:29:55 -0700 (PDT) From: Eric Sandeen To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, sandeen@redhat.com, agruenba@redhat.com Subject: [PATCH 8/8] libext2fs: fix ea loop in ext2fs_xattr_inode_max_size Date: Thu, 24 Sep 2026 17:23:42 -0500 Message-ID: <20260924222944.3683556-9-sandeen@redhat.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260924222944.3683556-1-sandeen@redhat.com> References: <20260924222944.3683556-1-sandeen@redhat.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DMARC_PASS,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Andreas Gruenbacher Fix the same problems as in check_ea_in_inode(). Found by AISLE in partnership with Red Hat. Signed-off-by: Andreas Gruenbacher Signed-off-by: Eric Sandeen --- lib/ext2fs/ext_attr.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/ext2fs/ext_attr.c b/lib/ext2fs/ext_attr.c index 6f6d2f4f..f2ac8911 100644 --- a/lib/ext2fs/ext_attr.c +++ b/lib/ext2fs/ext_attr.c @@ -1211,8 +1211,8 @@ errcode_t ext2fs_xattr_inode_max_size(ext2_filsys fs, ext2_ino_t ino, struct ext2_ext_attr_entry *entry; struct ext2_inode_large *inode; __u32 ea_inode_magic; - unsigned int minoff; - char *start; + unsigned int minoff, remain; + char *start, *end; size_t i; errcode_t err; @@ -1241,14 +1241,25 @@ errcode_t ext2fs_xattr_inode_max_size(ext2_filsys fs, ext2_ino_t ino, inode->i_extra_isize, sizeof(__u32)); if (ea_inode_magic == EXT2_EXT_ATTR_MAGIC) { /* has xattrs. calculate the size */ - start= ((char *) inode) + EXT2_GOOD_OLD_INODE_SIZE + + start = ((char *) inode) + EXT2_GOOD_OLD_INODE_SIZE + inode->i_extra_isize + sizeof(__u32); + end = (char *)inode + EXT2_INODE_SIZE(fs->super); + /* take finish entry 0UL into account */ + remain = end - (char *)start - sizeof(__u32); entry = (struct ext2_ext_attr_entry *) start; while (!EXT2_EXT_IS_LAST_ENTRY(entry)) { + /* end->e_name_len is within the first four bytes */ + if (EXT2_EXT_ATTR_LEN(entry->e_name_len) > remain) + return EXT2_ET_INLINE_DATA_NO_SPACE; + remain -= EXT2_EXT_ATTR_LEN(entry->e_name_len); + if (!entry->e_value_inum && entry->e_value_size) { unsigned int offs = entry->e_value_offs; if (offs < minoff) minoff = offs; + if (EXT2_EXT_ATTR_SIZE(entry->e_value_size) > remain) + return EXT2_ET_INLINE_DATA_NO_SPACE; + remain -= EXT2_EXT_ATTR_SIZE(entry->e_value_size); } entry = EXT2_EXT_ATTR_NEXT(entry); }