Skip to contentSkip to conversation

ext4: Fix checking of entry validity

PATCH Applied Jan Kara 3 participants 8 messages Jul 31, 2020 – Aug 26, 2020

Subsystems (2)
lore
Share & tools
lore

Jan Kara

author reviewer
#0 lore raw

PATCH 1/1 ext4: Fix checking of entry validity

ext4_search_dir() and ext4_generic_delete_entry() can be called both for standard director blocks and for inline directories stored inside inode or inline xattr space. For the second case we didn't call ext4_check_dir_entry() with proper constraints that could result in accepting corrupted directory entry as well as false positive filesystem errors like:

EXT4-fs error (device dm-0): ext4_search_dir:1395: inode #28320400:
block 113246792: comm dockerd: bad entry in directory: directory entry too close to block end - offset=0, inode=28320403, rec_len=32, name_len=8, size=4096

Fix the arguments passed to ext4_check_dir_entry().

Fixes 109ba779d6cc ("ext4: check for directory entries too close to block end")
---
 fs/ext4/namei.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/ext4/namei.c +3 -3
index 56738b538ddf..98b91f2314eb 100644
@@ -1396,8 +1396,8 @@ int ext4_search_dir(struct buffer_head *bh, char *search_buf, int buf_size,
 		    ext4_match(dir, fname, de)) {
 			/* found a match - just to be sure, do
 			 * a full check */
-			if (ext4_check_dir_entry(dir, NULL, de, bh, bh->b_data,
-						 bh->b_size, offset))
+			if (ext4_check_dir_entry(dir, NULL, de, bh, search_buf,
+						 buf_size, offset))
 				return -1;
 			*res_dir = de;
 			return 1;
@@ -2472,7 +2472,7 @@ int ext4_generic_delete_entry(handle_t *handle,
 	de = (struct ext4_dir_entry_2 *)entry_buf;
 	while (i < buf_size - csum_size) {
 		if (ext4_check_dir_entry(dir, NULL, de, bh,
-					 bh->b_data, bh->b_size, i))
+					 entry_buf, buf_size, i))
 			return -EFSCORRUPTED;
 		if (de == de_del)  {
 			if (pde)
Signature · 1 line
2.16.4
maintainer
#1 lore raw

Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 109ba779d6cc ("ext4: check for directory entries too close to block end").

The bot has tested the following trees: v5.7.11, v5.4.54, v4.19.135, v4.14.190, v4.9.231, v4.4.231.

v5.7.11: Build OK!
v5.4.54: Build OK!
v4.19.135: Build OK!
v4.14.190: Build OK!
v4.9.231: Failed to apply! Possible dependencies:
364443cbcfe7 ("ext4: convert DAX reads to iomap infrastructure") 39bc88e5e38e ("arm64: Disable TTBR0_EL1 during normal kernel execution") 7046ae35329f ("ext4: Add iomap support for inline data")
7c0f6ba682b9 ("Replace <asm/uaccess.h> with <linux/uaccess.h> globally") 9cf09d68b89a ("arm64: xen: Enable user access before a privcmd hvc call") b886ee3e778e ("ext4: Support case-insensitive file name lookups") bd38967d406f ("arm64: Factor out PAN enabling/disabling into separate uaccess_* macros") ee73f9a52a34 ("ext4: convert to new i_version API")
eeca7ea1baa9 ("ext4: use current_time() for inode timestamps")

v4.4.231: Failed to apply! Possible dependencies:
12735f881952 ("ext4: pre-zero allocated blocks for DAX IO") 2dcba4781fa3 ("ext4: get rid of EXT4_GET_BLOCKS_NO_LOCK flag") 364443cbcfe7 ("ext4: convert DAX reads to iomap infrastructure") 7046ae35329f ("ext4: Add iomap support for inline data") 705965bd6dfa ("ext4: rename and split get blocks functions") b886ee3e778e ("ext4: Support case-insensitive file name lookups") ba5843f51d46 ("ext4: use pre-zeroed blocks for DAX page faults") c86d8db33a92 ("ext4: implement allocation of pre-zeroed blocks") ee73f9a52a34 ("ext4: convert to new i_version API")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
maintainer
#2 lore raw
In reply to Jan Kara

Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 109ba779d6cc ("ext4: check for directory entries too close to block end").

The bot has tested the following trees: v5.7.11, v5.4.54, v4.19.135, v4.14.190, v4.9.231, v4.4.231.

v5.7.11: Build OK!
v5.4.54: Build OK!
v4.19.135: Build OK!
v4.14.190: Build OK!
v4.9.231: Failed to apply! Possible dependencies:
364443cbcfe7 ("ext4: convert DAX reads to iomap infrastructure") 39bc88e5e38e ("arm64: Disable TTBR0_EL1 during normal kernel execution") 7046ae35329f ("ext4: Add iomap support for inline data")
7c0f6ba682b9 ("Replace <asm/uaccess.h> with <linux/uaccess.h> globally") 9cf09d68b89a ("arm64: xen: Enable user access before a privcmd hvc call") b886ee3e778e ("ext4: Support case-insensitive file name lookups") bd38967d406f ("arm64: Factor out PAN enabling/disabling into separate uaccess_* macros") ee73f9a52a34 ("ext4: convert to new i_version API")
eeca7ea1baa9 ("ext4: use current_time() for inode timestamps")

v4.4.231: Failed to apply! Possible dependencies:
12735f881952 ("ext4: pre-zero allocated blocks for DAX IO") 2dcba4781fa3 ("ext4: get rid of EXT4_GET_BLOCKS_NO_LOCK flag") 364443cbcfe7 ("ext4: convert DAX reads to iomap infrastructure") 7046ae35329f ("ext4: Add iomap support for inline data") 705965bd6dfa ("ext4: rename and split get blocks functions") b886ee3e778e ("ext4: Support case-insensitive file name lookups") ba5843f51d46 ("ext4: use pre-zeroed blocks for DAX page faults") c86d8db33a92 ("ext4: implement allocation of pre-zeroed blocks") ee73f9a52a34 ("ext4: convert to new i_version API")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
maintainer Applied
#3 lore raw
In reply to Jan Kara

Thanks, applied, although I changed the commit summary to be:

ext4: fix checking of directory entry validity for inline directories

- Ted

Quoted 20 lines · Jan Kara

ext4_search_dir() and ext4_generic_delete_entry() can be called both for standard director blocks and for inline directories stored inside inode or inline xattr space. For the second case we didn't call ext4_check_dir_entry() with proper constraints that could result in accepting corrupted directory entry as well as false positive filesystem errors like:

EXT4-fs error (device dm-0): ext4_search_dir:1395: inode #28320400:
block 113246792: comm dockerd: bad entry in directory: directory entry too close to block end - offset=0, inode=28320403, rec_len=32, name_len=8, size=4096

Fix the arguments passed to ext4_check_dir_entry().

Fixes 109ba779d6cc ("ext4: check for directory entries too close to block end")
---
 fs/ext4/namei.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
maintainer
#4 lore raw
In reply to Jan Kara

Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 109ba779d6cc ("ext4: check for directory entries too close to block end").

The bot has tested the following trees: v5.8, v5.7.13, v5.4.56, v4.19.137, v4.14.192, v4.9.232, v4.4.232.

v5.8: Build OK!
v5.7.13: Build OK!
v5.4.56: Build OK!
v4.19.137: Build OK!
v4.14.192: Build OK!
v4.9.232: Failed to apply! Possible dependencies:
364443cbcfe7 ("ext4: convert DAX reads to iomap infrastructure") 39bc88e5e38e ("arm64: Disable TTBR0_EL1 during normal kernel execution") 7046ae35329f ("ext4: Add iomap support for inline data")
7c0f6ba682b9 ("Replace <asm/uaccess.h> with <linux/uaccess.h> globally") 9cf09d68b89a ("arm64: xen: Enable user access before a privcmd hvc call") b886ee3e778e ("ext4: Support case-insensitive file name lookups") bd38967d406f ("arm64: Factor out PAN enabling/disabling into separate uaccess_* macros") ee73f9a52a34 ("ext4: convert to new i_version API")
eeca7ea1baa9 ("ext4: use current_time() for inode timestamps")

v4.4.232: Failed to apply! Possible dependencies:
12735f881952 ("ext4: pre-zero allocated blocks for DAX IO") 2dcba4781fa3 ("ext4: get rid of EXT4_GET_BLOCKS_NO_LOCK flag") 364443cbcfe7 ("ext4: convert DAX reads to iomap infrastructure") 7046ae35329f ("ext4: Add iomap support for inline data") 705965bd6dfa ("ext4: rename and split get blocks functions") b886ee3e778e ("ext4: Support case-insensitive file name lookups") ba5843f51d46 ("ext4: use pre-zeroed blocks for DAX page faults") c86d8db33a92 ("ext4: implement allocation of pre-zeroed blocks") ee73f9a52a34 ("ext4: convert to new i_version API")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
maintainer
#5 lore raw
In reply to Jan Kara

Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 109ba779d6cc ("ext4: check for directory entries too close to block end").

The bot has tested the following trees: v5.8, v5.7.14, v5.4.57, v4.19.138, v4.14.193, v4.9.232, v4.4.232.

v5.8: Build OK!
v5.7.14: Build OK!
v5.4.57: Build OK!
v4.19.138: Build OK!
v4.14.193: Build OK!
v4.9.232: Failed to apply! Possible dependencies:
364443cbcfe7 ("ext4: convert DAX reads to iomap infrastructure") 39bc88e5e38e ("arm64: Disable TTBR0_EL1 during normal kernel execution") 7046ae35329f ("ext4: Add iomap support for inline data")
7c0f6ba682b9 ("Replace <asm/uaccess.h> with <linux/uaccess.h> globally") 9cf09d68b89a ("arm64: xen: Enable user access before a privcmd hvc call") b886ee3e778e ("ext4: Support case-insensitive file name lookups") bd38967d406f ("arm64: Factor out PAN enabling/disabling into separate uaccess_* macros") ee73f9a52a34 ("ext4: convert to new i_version API")
eeca7ea1baa9 ("ext4: use current_time() for inode timestamps")

v4.4.232: Failed to apply! Possible dependencies:
12735f881952 ("ext4: pre-zero allocated blocks for DAX IO") 2dcba4781fa3 ("ext4: get rid of EXT4_GET_BLOCKS_NO_LOCK flag") 364443cbcfe7 ("ext4: convert DAX reads to iomap infrastructure") 7046ae35329f ("ext4: Add iomap support for inline data") 705965bd6dfa ("ext4: rename and split get blocks functions") b886ee3e778e ("ext4: Support case-insensitive file name lookups") ba5843f51d46 ("ext4: use pre-zeroed blocks for DAX page faults") c86d8db33a92 ("ext4: implement allocation of pre-zeroed blocks") ee73f9a52a34 ("ext4: convert to new i_version API")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
maintainer
#6 lore raw
In reply to Jan Kara

Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 109ba779d6cc ("ext4: check for directory entries too close to block end").

The bot has tested the following trees: v5.8.1, v5.7.15, v5.4.58, v4.19.139, v4.14.193, v4.9.232, v4.4.232.

v5.8.1: Build OK!
v5.7.15: Build OK!
v5.4.58: Build OK!
v4.19.139: Build OK!
v4.14.193: Build failed! Errors:

v4.9.232: Failed to apply! Possible dependencies:
364443cbcfe7 ("ext4: convert DAX reads to iomap infrastructure") 39bc88e5e38e ("arm64: Disable TTBR0_EL1 during normal kernel execution") 7046ae35329f ("ext4: Add iomap support for inline data")
7c0f6ba682b9 ("Replace <asm/uaccess.h> with <linux/uaccess.h> globally") 9cf09d68b89a ("arm64: xen: Enable user access before a privcmd hvc call") b886ee3e778e ("ext4: Support case-insensitive file name lookups") bd38967d406f ("arm64: Factor out PAN enabling/disabling into separate uaccess_* macros") ee73f9a52a34 ("ext4: convert to new i_version API")
eeca7ea1baa9 ("ext4: use current_time() for inode timestamps")

v4.4.232: Failed to apply! Possible dependencies:
12735f881952 ("ext4: pre-zero allocated blocks for DAX IO") 2dcba4781fa3 ("ext4: get rid of EXT4_GET_BLOCKS_NO_LOCK flag") 364443cbcfe7 ("ext4: convert DAX reads to iomap infrastructure") 7046ae35329f ("ext4: Add iomap support for inline data") 705965bd6dfa ("ext4: rename and split get blocks functions") b886ee3e778e ("ext4: Support case-insensitive file name lookups") ba5843f51d46 ("ext4: use pre-zeroed blocks for DAX page faults") c86d8db33a92 ("ext4: implement allocation of pre-zeroed blocks") ee73f9a52a34 ("ext4: convert to new i_version API")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha
maintainer
#7 lore raw
In reply to Jan Kara

Hi

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag
fixing commit: 109ba779d6cc ("ext4: check for directory entries too close to block end").

The bot has tested the following trees: v5.8.2, v5.7.16, v5.4.59, v4.19.140, v4.14.193, v4.9.232, v4.4.232.

v5.8.2: Build OK!
v5.7.16: Build OK!
v5.4.59: Build OK!
v4.19.140: Build OK!
v4.14.193: Build OK!
v4.9.232: Failed to apply! Possible dependencies:
364443cbcfe7 ("ext4: convert DAX reads to iomap infrastructure") 39bc88e5e38e ("arm64: Disable TTBR0_EL1 during normal kernel execution") 7046ae35329f ("ext4: Add iomap support for inline data")
7c0f6ba682b9 ("Replace <asm/uaccess.h> with <linux/uaccess.h> globally") 9cf09d68b89a ("arm64: xen: Enable user access before a privcmd hvc call") b886ee3e778e ("ext4: Support case-insensitive file name lookups") bd38967d406f ("arm64: Factor out PAN enabling/disabling into separate uaccess_* macros") ee73f9a52a34 ("ext4: convert to new i_version API")
eeca7ea1baa9 ("ext4: use current_time() for inode timestamps")

v4.4.232: Failed to apply! Possible dependencies:
12735f881952 ("ext4: pre-zero allocated blocks for DAX IO") 2dcba4781fa3 ("ext4: get rid of EXT4_GET_BLOCKS_NO_LOCK flag") 364443cbcfe7 ("ext4: convert DAX reads to iomap infrastructure") 7046ae35329f ("ext4: Add iomap support for inline data") 705965bd6dfa ("ext4: rename and split get blocks functions") b886ee3e778e ("ext4: Support case-insensitive file name lookups") ba5843f51d46 ("ext4: use pre-zeroed blocks for DAX page faults") c86d8db33a92 ("ext4: implement allocation of pre-zeroed blocks") ee73f9a52a34 ("ext4: convert to new i_version API")

NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

Signature · 2 lines
Thanks
Sasha