From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from air.basealt.ru (air.basealt.ru [193.43.8.18]) (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 B021B198E6D for ; Mon, 18 Nov 2024 10:21:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.43.8.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731925262; cv=none; b=CML67kcGl8RkXIkunpYvUSGm2Nes/9ytaQo4jbEVuoemDzGhPfze7CG6Z1HUZctJap1WJ4YC67YHRysoAy76yiB5C2+cDikpcl+E0iS0ZJfcFxpoSfwtkMybuvajhGp2IXtA45tMD1rTvksh9kCg0MkwVqbqqzEN1faSAnY1lQ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731925262; c=relaxed/simple; bh=VCkHQ6f3mAlnMdGatpZKxHHJ1BEwhcceEaOXrVaUX3c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GXLz4aUaTVr2hRuWfdeD7bhhFtT6t02ROfzqoJCcgHi7Fl5+w8lcQSPCdGNRaMmC8BUVg8fnkf4b5+oEVlCC78dY5ZNUhkBHsY1lHKA2jVUnDAQ/Q/OQ3VfuGNo3jWR36/uUqL5zPq2Xqn+QE7RuBfyL3TGvoFD7YzSnqrfJVYk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=altlinux.org; spf=pass smtp.mailfrom=altlinux.org; arc=none smtp.client-ip=193.43.8.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=altlinux.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=altlinux.org Received: from altlinux.malta.altlinux.ru (obninsk.basealt.ru [217.15.195.17]) by air.basealt.ru (Postfix) with ESMTPSA id C2D9923392; Mon, 18 Nov 2024 13:20:58 +0300 (MSK) From: Vasiliy Kovalev To: Greg Kroah-Hartman , Sasha Levin , stable@vger.kernel.org Cc: lvc-project@linuxtesting.org, dutyrok@altlinux.org, gerben@altlinux.org, kovalev@altlinux.org Subject: [PATCH 3/3] ext4: fix error message when rejecting the default hash Date: Mon, 18 Nov 2024 13:20:50 +0300 Message-Id: <20241118102050.16077-4-kovalev@altlinux.org> X-Mailer: git-send-email 2.33.8 In-Reply-To: <20241118102050.16077-1-kovalev@altlinux.org> References: <20241118102050.16077-1-kovalev@altlinux.org> 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 [ Upstream commit a2187431c395cdfbf144e3536f25468c64fc7cfa ] 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: Vasiliy Kovalev --- 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 72abb8d6caf75..d5706aedf4fef 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2449,6 +2449,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 68070b1859803..3e4b9bf101454 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -3559,14 +3559,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; @@ -5050,16 +5042,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) @@ -5077,6 +5080,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) @@ -5234,7 +5238,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.33.8 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 D3807148857 for ; Tue, 19 Nov 2024 04:36:37 +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=1731990998; cv=none; b=RoJAGLeE7JMguh/FVcRbT/HbiSfs8QUMjiW+lI0nVKI5alwIihDiTxHAidGhIC3N4uiHlXh++y0o8bowZQjqtLRjfVrVpo0MQJYe4iM9jBkFrsTui0j6PLDasd/VBaLsr8YVk3+rm8tNasZTOWa3zJ9SbD2fqorvDjURWPkc7A4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731990998; c=relaxed/simple; bh=cBVsmzaYdqsz6YjkJvT0uCPW8tIDW8zcI1RD+93B63E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VhdGio5U2EeeBgVnb+Zv5mUgK17spgOaYnXtV72cTFZQziwwl9YJr327LuvwhYu1wHb4RHa/ws102QU+1etyKw+A4wR7Kkv7hQ2unVdFA49SA2SLh1pkFCV36M1EceS0ZtBd70Ly65+j2oczExBDCK5K3yJwttrzQVzdut8CnV4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ogEV82fe; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ogEV82fe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B403C4CED1; Tue, 19 Nov 2024 04:36:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1731990997; bh=cBVsmzaYdqsz6YjkJvT0uCPW8tIDW8zcI1RD+93B63E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ogEV82fe0OvS/pS9BB2bI+TIEJNMkLyfRCt+AqqGWGtehxLLwlquWDi9dW45YFmat BihVfVumHADr/Oo1d7qG3NaBbFIpxcqQt+SDtSX2tLlVQ4dkb+Gy1bUkXJ3358ak21 o/2gm5GO7SeKAE1RCviv69MB57tsZ6iEQdZbwUzgMEQh3M5y5bNpcVSbN8HsH2lPwt JODLyCKmcVHuDhXG8VDE8NDBVTbMA3l201nK85CeHL36/QFYLfAIBiLCKw4dE+7UBD OSv0pe4fvFpKDIoWnnYXj/HvG4jRypZCjMVHa1vguqhN0cb76AiA+4Ahgjvx+7GCPe UpHKwf0iXhUFw== From: Sasha Levin To: stable@vger.kernel.org Cc: Vasiliy Kovalev , Sasha Levin Subject: Re: [PATCH 3/3] ext4: fix error message when rejecting the default hash Date: Mon, 18 Nov 2024 23:36:35 -0500 Message-ID: <20241118102050.16077-4-kovalev@altlinux.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241118102050.16077-4-kovalev@altlinux.org> References: Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID: <20241119043635.g8uMBK5UglL8AI2bA8e9dlnTS8yntkUP1syTTSIvgjQ@z> [ Sasha's backport helper bot ] Hi, The upstream commit SHA1 provided is correct: a2187431c395cdfbf144e3536f25468c64fc7cfa WARNING: Author mismatch between patch and upstream commit: Backport author: Vasiliy Kovalev Commit author: Gabriel Krisman Bertazi Commit in newer trees: |-----------------|----------------------------------------------| | 6.11.y | Present (different SHA1: b5778b2b428a) | |-----------------|----------------------------------------------| Note: The patch differs from the upstream commit: --- --- - 2024-11-18 22:36:26.886622930 -0500 +++ /tmp/tmp.pApf2ytKkR 2024-11-18 22:36:26.882290161 -0500 @@ -1,3 +1,5 @@ +[ Upstream commit a2187431c395cdfbf144e3536f25468c64fc7cfa ] + 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 @@ -11,16 +13,17 @@ 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: Vasiliy Kovalev --- fs/ext4/ext4.h | 1 + - fs/ext4/super.c | 27 +++++++++++++++++---------- - 2 files changed, 18 insertions(+), 10 deletions(-) + 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 481ece3660eb7..7ac668d4ce83c 100644 +index 72abb8d6caf75..d5706aedf4fef 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h -@@ -2462,6 +2462,7 @@ static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize) +@@ -2449,6 +2449,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 @@ -29,13 +32,13 @@ 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 58423e6bf3d07..adc5046fe9dd5 100644 +index 68070b1859803..3e4b9bf101454 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c -@@ -3583,13 +3583,6 @@ int ext4_feature_set_ok(struct super_block *sb, int readonly) - "mounted without CONFIG_UNICODE"); - return 0; +@@ -3559,14 +3559,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, @@ -43,10 +46,11 @@ - "mounted with siphash"); - return 0; - } - +- if (readonly) return 1; -@@ -5095,16 +5088,27 @@ static int ext4_load_super(struct super_block *sb, ext4_fsblk_t *lsb, + +@@ -5050,16 +5042,27 @@ static int ext4_load_super(struct super_block *sb, ext4_fsblk_t *lsb, return ret; } @@ -76,22 +80,25 @@ if (ext4_has_feature_dir_index(sb)) { i = le32_to_cpu(es->s_flags); if (i & EXT2_FLAGS_UNSIGNED_HASH) -@@ -5122,6 +5126,7 @@ static void ext4_hash_info_init(struct super_block *sb) +@@ -5077,6 +5080,7 @@ static void ext4_hash_info_init(struct super_block *sb) #endif } } + return 0; } - static int ext4_block_group_meta_init(struct super_block *sb, int silent) -@@ -5257,7 +5262,9 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) - if (err) - goto failed_mount; + static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb) +@@ -5234,7 +5238,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; - err = ext4_handle_clustersize(sb); - if (err) + if (ext4_handle_clustersize(sb)) + goto failed_mount; +-- +2.33.8 + --- Results of testing on various branches: | Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-6.11.y | Failed (branch not found) | N/A | | stable/linux-6.6.y | Failed (branch not found) | N/A | | stable/linux-6.1.y | Failed (branch not found) | N/A | | stable/linux-5.15.y | Failed (branch not found) | N/A | | stable/linux-5.10.y | Failed (branch not found) | N/A | | stable/linux-5.4.y | Failed (branch not found) | N/A | | stable/linux-4.19.y | Failed (branch not found) | N/A |