Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (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 E1699258ECA for ; Thu, 8 Jan 2026 15:04:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767884670; cv=none; b=KR+Mpkp8pBbYJ4daZEOhHoqApqK50y9zco648MijJW0h05sohBaaDt0NZd0qcAX8eCIf6uwo9ixS9+YKY2pj2M9lU9Szf124IGlJiPa/f00Cyfejwdl/+vTPkS49BbVFeVCPCCczhydVNhYsE51V4CfVlLRoZR8Na4UEXUHMj44= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767884670; c=relaxed/simple; bh=1o4mkzkbkUcTigaD9w0dU5r+Mnhk6YKkP/OBRDYAYqU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q10lGb+9ReAiRLWgQ2XCGB1N8P9fMCpDNhUQvXCDoJEIf/nzULKYeuFmaeY/sk/2F4JwTGc8wZQ63P63hpwFVm1iqNhpR1NdjVOfx39qEktUqi6TKY6M324OQzAxi8R4asc60S6YCk/4/4nnmoAIvMukGuGKqILJb+Az58Kx6U8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=q9YOdntD; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="q9YOdntD" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=j08428qtSmO4ppBCZpm+EbAaeWYRd+7ilku5OeCLLcc=; b=q9YOdntDc6iQ7Qe5BfnZORDeib 3t7brf9dWdGB2WJvXQSfsA9c5CC/V91dBTjajQ/ScJ7VIrgJAaYOX5+i9tGBS1DB6UlD7psuHR6rM xP/WIuzU58ITe3R5BPqD+VFYZAq20AeVsyi0Tf+pFTMM19bd2qWIDU8prhs6sWnD/y/fS9z8uk1HJ gBgFdpOx5h8vFEUsj1r50h6N4MGSHHYWc9Hs5GG09XyXhIq6pPban/h8fDcb0IfuKJa4oGZGJVlB4 VmG6n6yWUenpwPvbc5HxG5jvjnE9K2uvlcGmpCEOztYsmT5W/84dzteYhB8LDNo+ZxWjZQBH8lT1e rFQ59lxw==; Received: from 179-125-75-246-dinamico.pombonet.net.br ([179.125.75.246] helo=quatroqueijos.lan) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1vdrYn-00339G-5f; Thu, 08 Jan 2026 16:04:25 +0100 From: Thadeu Lima de Souza Cascardo To: stable@vger.kernel.org Cc: Gabriel Krisman Bertazi , Theodore Ts'o , Thadeu Lima de Souza Cascardo Subject: [PATCH 6.1 3/3] ext4: fix error message when rejecting the default hash Date: Thu, 8 Jan 2026 12:04:09 -0300 Message-ID: <20260108150409.3354721-3-cascardo@igalia.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260108150409.3354721-1-cascardo@igalia.com> References: <20260108150409.3354721-1-cascardo@igalia.com> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Gabriel Krisman Bertazi commit a2187431c395cdfbf144e3536f25468c64fc7cfa upstream. Commit 985b67cd8639 ("ext4: filesystems without casefold feature cannot be mounted with siphash") properly rejects volumes where s_def_hash_version is set to DX_HASH_SIPHASH, but the check and the error message should not look into casefold setup - a filesystem should never have DX_HASH_SIPHASH as the default hash. Fix it and, since we are there, move the check to ext4_hash_info_init. Fixes:985b67cd8639 ("ext4: filesystems without casefold feature cannot be mounted with siphash") Signed-off-by: Gabriel Krisman Bertazi Link: https://patch.msgid.link/87jzg1en6j.fsf_-_@mailhost.krisman.be Signed-off-by: Theodore Ts'o Signed-off-by: Thadeu Lima de Souza Cascardo --- fs/ext4/ext4.h | 1 + fs/ext4/super.c | 28 +++++++++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 579c4ac511ec..27753291fb7e 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2460,6 +2460,7 @@ static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize) #define DX_HASH_HALF_MD4_UNSIGNED 4 #define DX_HASH_TEA_UNSIGNED 5 #define DX_HASH_SIPHASH 6 +#define DX_HASH_LAST DX_HASH_SIPHASH static inline u32 ext4_chksum(struct ext4_sb_info *sbi, u32 crc, const void *address, unsigned int length) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 05665f4a898c..6a2a0af0f676 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -3550,14 +3550,6 @@ int ext4_feature_set_ok(struct super_block *sb, int readonly) } #endif - if (EXT4_SB(sb)->s_es->s_def_hash_version == DX_HASH_SIPHASH && - !ext4_has_feature_casefold(sb)) { - ext4_msg(sb, KERN_ERR, - "Filesystem without casefold feature cannot be " - "mounted with siphash"); - return 0; - } - if (readonly) return 1; @@ -5041,16 +5033,27 @@ static int ext4_load_super(struct super_block *sb, ext4_fsblk_t *lsb, return ret; } -static void ext4_hash_info_init(struct super_block *sb) +static int ext4_hash_info_init(struct super_block *sb) { struct ext4_sb_info *sbi = EXT4_SB(sb); struct ext4_super_block *es = sbi->s_es; unsigned int i; + sbi->s_def_hash_version = es->s_def_hash_version; + + if (sbi->s_def_hash_version > DX_HASH_LAST) { + ext4_msg(sb, KERN_ERR, + "Invalid default hash set in the superblock"); + return -EINVAL; + } else if (sbi->s_def_hash_version == DX_HASH_SIPHASH) { + ext4_msg(sb, KERN_ERR, + "SIPHASH is not a valid default hash value"); + return -EINVAL; + } + for (i = 0; i < 4; i++) sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]); - sbi->s_def_hash_version = es->s_def_hash_version; if (ext4_has_feature_dir_index(sb)) { i = le32_to_cpu(es->s_flags); if (i & EXT2_FLAGS_UNSIGNED_HASH) @@ -5068,6 +5071,7 @@ static void ext4_hash_info_init(struct super_block *sb) #endif } } + return 0; } static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) @@ -5222,7 +5226,9 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) sbi->s_addr_per_block_bits = ilog2(EXT4_ADDR_PER_BLOCK(sb)); sbi->s_desc_per_block_bits = ilog2(EXT4_DESC_PER_BLOCK(sb)); - ext4_hash_info_init(sb); + err = ext4_hash_info_init(sb); + if (err) + goto failed_mount; if (ext4_handle_clustersize(sb)) goto failed_mount; -- 2.47.3