Skip to contentSkip to conversation

ext4: Fix incorrect offset

PATCH Applied Wang Jianjian 3 participants 3 messages Aug 24, 2023 – Oct 6, 2023 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: Fix incorrect offset

The last argumen of ext4_check_dir_entry is dentry offset int the file.

---
 fs/ext4/namei.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ext4/namei.c +1 -2
index 94608b7df7e8..33ebd35025bf 100644
@@ -2261,8 +2261,7 @@ static int make_indexed_dir(handle_t *handle, struct ext4_filename *fname,
 	top = data2 + len;
 	while ((char *)(de2 = ext4_next_entry(de, blocksize)) < top) {
 		if (ext4_check_dir_entry(dir, NULL, de, bh2, data2, len,
-					 (data2 + (blocksize - csum_size) -
-					  (char *) de))) {
+					(char *)de - data2)) {
 			brelse(bh2);
 			brelse(bh);
 			return -EFSCORRUPTED;
Signature · 1 line
2.34.3
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 1 line · Wang Jianjian

The last argumen of ext4_check_dir_entry is dentry offset

^^^ argument

Quoted 1 line

int the file.

^^ in the directory

Maybe you could also add to the changelog: Luckily this error only results in the wrong offset being printed in the eventual error message.

Quoted 1 line

Otherwise the fix looks good. Feel free to add:

Honza

Quoted 21 lines
---
 fs/ext4/namei.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/ext4/namei.c +1 -2
index 94608b7df7e8..33ebd35025bf 100644
@@ -2261,8 +2261,7 @@ static int make_indexed_dir(handle_t *handle, struct ext4_filename *fname,
 	top = data2 + len;
 	while ((char *)(de2 = ext4_next_entry(de, blocksize)) < top) {
 		if (ext4_check_dir_entry(dir, NULL, de, bh2, data2, len,
-					 (data2 + (blocksize - csum_size) -
-					  (char *) de))) {
+					(char *)de - data2)) {
 			brelse(bh2);
 			brelse(bh);
 			return -EFSCORRUPTED;
Signature · 1 line
2.34.3
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
maintainer Applied
#2 lore raw
In reply to Wang Jianjian
Quoted 4 lines · Wang Jianjian

The last argumen of ext4_check_dir_entry is dentry offset int the file.

Applied, thanks!

[1/1] ext4: Fix incorrect offset

      commit: 8fedebb5ea183994aca39af3f80623f5db42fff7

Best regards,

Signature · 1 line
Theodore Ts'o <[email protected]>