[U-Boot] [PATCH 2/3] test/fs: Check ext4 behaviour if dirent is first entry in directory block

Stephen Warren swarren at wwwdotorg.org
Mon Sep 12 20:39:35 CEST 2016


On 09/11/2016 02:46 PM, Stefan Brüns wrote:
> This is a regression test for a crash happening if the first dirent
> in the block matches. Code tried to access a predecessor entry which
> does not exist.
> The crash happened for any block, but "." is always the first entry in
> the first directory block and thus easy to check for.

> diff --git a/test/fs/fs-test.sh b/test/fs/fs-test.sh

> +# Next test case checks writing a file whose dirent
> +# is the first in the block, which is always true for "."
> +# The write should fail, but the lookup should work
> +# Test Case 12 - Check directory traversal
> +${PREFIX}${WRITE} host${SUFFIX} $addr ${FPATH}. 0x10

Doesn't that attempt to write a file named ".", which would end up 
over-writing the directory content? Unless I'm misunderstanding, that 
doesn't seem like a good idea.

Also, ${FPATH} might be "", "/", "something", or "something/". Appending 
"." to some of those won't work the same way as some others.

> @@ -471,6 +477,11 @@ function check_results() {

> +	# Check lookup of 'dot' directory
> +	grep -A5 "Test Case 12 " "$1" | \
> +		egrep -q 'Unable to write file'
> +	pass_fail "TC12: 1MB write to . - write denied"

Oh, I see; this expects the write to be denied since the destination is 
a directory. Perhaps that's OK. I'd rather see a read attempt though, to 
guarantee that even if the access does end up being allowed, the FS 
isn't trashed for any future tests that may be added afterwards.


More information about the U-Boot mailing list