From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 55DD935CEA3; Tue, 26 Aug 2025 14:40:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756219204; cv=none; b=d9ekPvVdhlA/dI4osy0VpYhmG6kzq0JOqBbXzcmQui8+/qePxW4O09UYt9c3ze55SuRLy0CGJnOOFJD7ixmFEI7+2IWkF0kJBsHErMkZGLx3YrTMx1HZRMolRpFDiVTZDJGC9RIqph59hDmAAmCslxsvfqShnRU7eARQRP+vhYs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756219204; c=relaxed/simple; bh=62Fx0h58kHNTd2l9LbmDPR0Rtg9k/GUdDBoP64OSkAY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Co5vhMObQmCy+gTJfdhEFIDAJkTIzqdBv2FjqjbY0vaKJhT5hSRtqMN++KMwfwLRvCHVXV3X+w6Ba1TBGrvgza8kbGXfk0CTrOdUajwy9Xr0Hk4KCKQEEsvNKdHAJymkivoapnNNBxSIBvoTe17w46P8S+3tNbTp+QDUv7RpPfE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=agyEM6S7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="agyEM6S7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7CB4C113D0; Tue, 26 Aug 2025 14:40:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1756219204; bh=62Fx0h58kHNTd2l9LbmDPR0Rtg9k/GUdDBoP64OSkAY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=agyEM6S7O7t7ziqHCggAjP+GwptbHjrJWk9+3P+7Q6mnFDCE2iNOKNZmT+6zUcH3L rM8phOhmG+ngTM9Bdw1uCedLa6aeivlhKvKlxBY/qLEpAQoQGhgVpdvAcwJB0LsGEq r4il1kEmGulwlfFPfLPS058/UryOx7qdOaZ18mPU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable@kernel.org, Ojaswin Mujoo , "Darrick J. Wong" , Theodore Tso Subject: [PATCH 5.4 293/403] ext4: fix reserved gdt blocks handling in fsmap Date: Tue, 26 Aug 2025 13:10:19 +0200 Message-ID: <20250826110914.903683802@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250826110905.607690791@linuxfoundation.org> References: <20250826110905.607690791@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ojaswin Mujoo commit 3ffbdd1f1165f1b2d6a94d1b1aabef57120deaf7 upstream. In some cases like small FSes with no meta_bg and where the resize doesn't need extra gdt blocks as it can fit in the current one, s_reserved_gdt_blocks is set as 0, which causes fsmap to emit a 0 length entry, which is incorrect. $ mkfs.ext4 -b 65536 -O bigalloc /dev/sda 5G $ mount /dev/sda /mnt/scratch $ xfs_io -c "fsmap -d" /mnt/scartch 0: 253:48 [0..127]: static fs metadata 128 1: 253:48 [128..255]: special 102:1 128 2: 253:48 [256..255]: special 102:2 0 <---- 0 len entry 3: 253:48 [256..383]: special 102:3 128 Fix this by adding a check for this case. Cc: stable@kernel.org Fixes: 0c9ec4beecac ("ext4: support GETFSMAP ioctls") Signed-off-by: Ojaswin Mujoo Reviewed-by: Darrick J. Wong Link: https://patch.msgid.link/08781b796453a5770112aa96ad14c864fbf31935.1754377641.git.ojaswin@linux.ibm.com Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/fsmap.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/fs/ext4/fsmap.c +++ b/fs/ext4/fsmap.c @@ -393,6 +393,14 @@ static unsigned int ext4_getfsmap_find_s /* Reserved GDT blocks */ if (!ext4_has_feature_meta_bg(sb) || metagroup < first_meta_bg) { len = le16_to_cpu(sbi->s_es->s_reserved_gdt_blocks); + + /* + * mkfs.ext4 can set s_reserved_gdt_blocks as 0 in some cases, + * check for that. + */ + if (!len) + return 0; + error = ext4_getfsmap_fill(meta_list, fsb, len, EXT4_FMR_OWN_RESV_GDT); if (error)