therealromster / cryptsetup

Automatically exported from code.google.com/p/cryptsetup
GNU General Public License v2.0
0 stars 0 forks source link

veritysetup bug that depends on the size of the image #239

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

SIZE=$(( (671800*4096) ))
dd if=/dev/zero of=test bs=1 seek="$SIZE" count=1
veritysetup format test vert | tee ./stdo
HASH="`cat ./stdo | egrep '^Root hash:' | egrep -o '[0-9a-f]{64}'`"
veritysetup verify test vert "$HASH"

What is the expected output? What do you see instead?

It is expected that veritysetup silently exits with a success status. Instead, 
it complains that verification failed at position 0.

What version of the product are you using? On what operating system?

1.6.1 on ubuntu

Please provide any additional information below.

Surprisingly, it seems to fail for quite a number of SIZE values around the one 
given above. I also ran a randomized test script for smaller values of SIZE in 
a loop and things were OK, so the cryptsetup installation on my system is not 
totally broken or anything.

Mounting the device did not work either, so the bug is not limited to the 
user-mode verification. Either it is in the format step, or the bug exists both 
in veritysetup verify and in the kernel implementation.

Original issue reported on code.google.com by zerosu...@gmail.com on 22 Dec 2014 at 1:23

GoogleCodeExporter commented 9 years ago
Hm, there are some restrictions but it should follow kernel component.

If you have randomized testing script, could you provide it as well?

Original comment by gmazyl...@gmail.com on 22 Dec 2014 at 1:37

GoogleCodeExporter commented 9 years ago
sorry, I just noticed a slight problem in the test code above, it should be 
count=0 otherwise the file size will not be a multiple of 4K as intended. it 
doesn't work either way, though. here is the randomized test script. this one 
does not fail whether count=0 or count=1. so the problem only manifests for 
large file sizes.

while [ 1 ]
do
  SIZE=$(( (RANDOM*4096) ))
  rm -f ./test ./vert
  dd if=/dev/zero of=test bs=1 seek="$SIZE" count=0
  veritysetup format test vert | tee ./stdo
  HASH="cat ./stdo | egrep '^Root hash:' | egrep -o '[0-9a-f]{64}'`"
  veritysetup verify test vert "$HASH"
done

Original comment by zerosu...@gmail.com on 22 Dec 2014 at 9:14