eternaltyro / cryptsetup

Since Google code is shuttering...
http://code.google.com/p/cryptsetup
GNU General Public License v2.0
0 stars 0 forks source link

the bug of using veritysetup on arm board #191

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Download veritysetup tools and dependent libraries from openmamba
2.Let these compile into the file system
3.Transplant drive from kernel 3.4 to kernel3.0
4.Start development board

5.dd if=romfs.img of=/dev/block/mtdblock12 bs1 count=12582912
  the "romfs.img" is a romfs system, it has two files which are block1(all is 0) and block2(all is 0)

6.veritysetup --data-blocks 4096 --hash-offset=16777216 format 
/dev/block/mtdblock12 /dev/block/mtdblock12
UUID:                   a7da42fc-cb44-486f-a16a-a07d44de1402
Hash type:              1
Data blocks:            4096
Data block size:        4096
Hash block size:        4096
Hash algorithm:         sha256
Salt:             
410acaf6666fadf98e0e23e933763954dc739f1288916dc7886e718af720062c
Root hash:              
bba6ef77e38190bdb3cf26f74e9ada2ea36d3946bf6688683aafea4f807c3357

7.veritysetup --data-blocks 4096 --hash-offset=16777216 create mtd12 
/dev/block/mtdblock12 /dev/block/mtdblock12 
bba6ef77e38190bdb3cf26f74e9ada2ea36d3946bf6688683aafea4f807c3357

8.busybox mount /dev/mapper/mtd12 tmp

9.using command "ls"
root@android:/data/tmp # ls
attempt to access beyond end of device
dm-0: rw=0, want=40968, limit=32768
attempt to access beyond end of device
dm-0: rw=0, want=40968, limit=32768
block2

10.hexdump -C block2 | more
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00140000  00 00 00 02 00 00 00 00  00 50 00 00 32 12 90 9b  |.........P..2...|
00140010  62 6c 6f 63 6b 31 00 00  00 00 00 00 00 00 00 00  |block1..........|
00140020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
002bff80  76 65 72 69 74 79 00 00  01 00 00 00 01 00 00 00  |verity..........|
002bff90  bf fd 71 92 c9 d3 4d f0  8c 89 ff a0 4a 59 6c 03  |..q...M.....JYl.|
002bffa0  73 68 61 32 35 36 00 00  00 00 00 00 00 00 00 00  |sha256..........|
002bffb0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
002bffc0  00 10 00 00 00 10 00 00  00 0b 00 00 00 00 00 00  |................|
002bffd0  20 00 00 00 00 00 00 00  cb 2b 08 35 3d d2 b8 45  | ........+.5=..E|
002bffe0  94 83 e5 17 70 98 7a ba  a8 e6 e1 2a b0 bb d2 f7  |....p.z....*....|
002bfff0  dc 0f 50 43 b1 eb ec e8  00 00 00 00 00 00 00 00  |..PC............|
002c0000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
002c0380  8f 0e 96 41 3f 4f f7 b6  3b b6 a7 45 56 eb 7f 83  |...A?O..;..EV...|
002c0390  2f 6e aa f4 5c 03 55 2b  a2 84 71 91 d3 5a 7f b3  |/n..\.U+..q..Z..|
002c03a0  ff 6e 08 49 20 82 03 06  2c 63 02 74 aa db 35 72  |.n.I ...,c.t..5r|
002c03b0  c8 ad 46 6a d9 52 5c ba  bb c5 bc 50 ba a8 27 1b  |..Fj.R\....P..'.|
002c03c0  ff 6e 08 49 20 82 03 06  2c 63 02 74 aa db 35 72  |.n.I ...,c.t..5r|
002c03d0  c8 ad 46 6a d9 52 5c ba  bb c5 bc 50 ba a8 27 1b  |..Fj.R\....P..'.|
002c03e0  ff 6e 08 49 20 82 03 06  2c 63 02 74 aa db 35 72  |.n.I ...,c.t..5r|

What is the expected output? What do you see instead?
expected output:
root@android:/data/tmp # ls
block1
block2
root@android:/data/tmp # hexdump -C block1
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0500000
root@android:/data/tmp # hexdump -C block2
0000000 0000 0000 0000 0000 0000 0000 0000 0000
*
0500000

instead:
root@android:/data/tmp # ls
attempt to access beyond end of device
dm-0: rw=0, want=40968, limit=32768
attempt to access beyond end of device
dm-0: rw=0, want=40968, limit=32768
block2

root@android:/data/tmp # hexdump -C block2 | more
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00140000  00 00 00 02 00 00 00 00  00 50 00 00 32 12 90 9b  |.........P..2...|
00140010  62 6c 6f 63 6b 31 00 00  00 00 00 00 00 00 00 00  |block1..........|
00140020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
002bff80  76 65 72 69 74 79 00 00  01 00 00 00 01 00 00 00  |verity..........|
002bff90  bf fd 71 92 c9 d3 4d f0  8c 89 ff a0 4a 59 6c 03  |..q...M.....JYl.|
002bffa0  73 68 61 32 35 36 00 00  00 00 00 00 00 00 00 00  |sha256..........|
002bffb0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
002bffc0  00 10 00 00 00 10 00 00  00 0b 00 00 00 00 00 00  |................|
002bffd0  20 00 00 00 00 00 00 00  cb 2b 08 35 3d d2 b8 45  | ........+.5=..E|
002bffe0  94 83 e5 17 70 98 7a ba  a8 e6 e1 2a b0 bb d2 f7  |....p.z....*....|
002bfff0  dc 0f 50 43 b1 eb ec e8  00 00 00 00 00 00 00 00  |..PC............|
002c0000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
002c0380  8f 0e 96 41 3f 4f f7 b6  3b b6 a7 45 56 eb 7f 83  |...A?O..;..EV...|
002c0390  2f 6e aa f4 5c 03 55 2b  a2 84 71 91 d3 5a 7f b3  |/n..\.U+..q..Z..|
002c03a0  ff 6e 08 49 20 82 03 06  2c 63 02 74 aa db 35 72  |.n.I ...,c.t..5r|
002c03b0  c8 ad 46 6a d9 52 5c ba  bb c5 bc 50 ba a8 27 1b  |..Fj.R\....P..'.|
002c03c0  ff 6e 08 49 20 82 03 06  2c 63 02 74 aa db 35 72  |.n.I ...,c.t..5r|
002c03d0  c8 ad 46 6a d9 52 5c ba  bb c5 bc 50 ba a8 27 1b  |..Fj.R\....P..'.|
002c03e0  ff 6e 08 49 20 82 03 06  2c 63 02 74 aa db 35 72  |.n.I ...,c.t..5r|
What version of the product are you using? On what operating system?
1.6.2 android(kernel3.0)

Please provide any additional information below.

Original issue reported on code.google.com by askxia...@gmail.com on 18 Dec 2013 at 2:41

GoogleCodeExporter commented 9 years ago
Please provide any additional information below.
root@android:/data # hexdump -C /dev/block/mtdblock12 | more                   
00000000  2d 72 6f 6d 31 66 73 2d  00 a0 00 a0 c7 82 ed 0e  |-rom1fs-........|
00000010  72 6f 6d 20 35 32 61 66  31 62 61 32 00 00 00 00  |rom 52af1ba2....|
00000020  00 00 00 49 00 00 00 20  00 00 00 00 d1 ff ff 97  |...I... ........|
00000030  2e 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000040  00 00 00 60 00 00 00 20  00 00 00 00 d1 d1 ff 80  |...`... ........|
00000050  2e 2e 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000060  00 50 00 82 00 00 00 00  00 50 00 00 31 c1 90 1b  |.P.......P..1...|
00000070  62 6c 6f 63 6b 32 00 00  00 00 00 00 00 00 00 00  |block2..........|
00000080  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00500080  00 00 00 02 00 00 00 00  00 50 00 00 32 12 90 9b  |.........P..2...|
00500090  62 6c 6f 63 6b 31 00 00  00 00 00 00 00 00 00 00  |block1..........|
005000a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00b00000  76 65 72 69 74 79 00 00  01 00 00 00 01 00 00 00  |verity..........|
00b00010  2f a8 e0 2c 8a b6 4b b8  a4 15 79 e9 34 70 01 83  |/..,..K...y.4p..|
00b00020  73 68 61 32 35 36 00 00  00 00 00 00 00 00 00 00  |sha256..........|
00b00030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00b00040  00 10 00 00 00 10 00 00  00 0b 00 00 00 00 00 00  |................|
00b00050  20 00 00 00 00 00 00 00  05 68 9d b3 10 51 d9 3a  | ........h...Q.:|
00b00060  85 ed a5 eb d5 27 90 4b  ac d7 de cb 8f f6 5f 34  |.....'.K......_4|
00b00070  5d ff 05 ad b2 cd 39 c2  00 00 00 00 00 00 00 00  |].....9.........|
00b00080  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
--More-- 

Try to Match --data-blocks=2816 --hash-offset=00b00000 to use veritysetup, the 
result:
root@android:/data/tmp # ls
attempt to access beyond end of device
dm-0: rw=0, want=40968, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=40968, limit=22528
block2
root@android:/data/tmp # hexdump -C block2 | more                              
attempt to access beyond end of device
dm-0: rw=0, want=22536, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=22536, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=22568, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=22600, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=22632, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=22664, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=22696, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=22728, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=22760, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=22792, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=22824, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=22856, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=22888, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=22920, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=22952, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=22984, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23016, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23048, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23080, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23112, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23144, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23176, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23208, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23240, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23272, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23304, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23336, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23368, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23400, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23432, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23464, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23496, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23528, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23560, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23592, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23624, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23656, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23688, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23720, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23752, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23784, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23816, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23848, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23880, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23912, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23944, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=23976, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=24008, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=24040, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=24072, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=24104, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=24136, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=24168, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=24200, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=24232, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=24264, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=24296, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=24328, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=24360, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=24392, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=24424, limit=22528
attempt to access beyond end of device
dm-0: rw=0, want=22536, limit=22528
00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00140000  00 00 00 02 00 00 00 00  00 50 00 00 32 12 90 9b  |.........P..2...|
00140010  62 6c 6f 63 6b 31 00 00  00 00 00 00 00 00 00 00  |block1..........|
00140020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
hexdump: block2: Input/output error
002bf000

Original comment by askxia...@gmail.com on 18 Dec 2013 at 2:57

GoogleCodeExporter commented 9 years ago
> 5.dd if=romfs.img of=/dev/block/mtdblock12 bs1 count=12582912

syntax error. bs=1 ?

What has this bug common with veritysetup? It is miscalculation of underlying 
bock device size.

>attempt to access beyond end of device
>dm-0: rw=0, want=23336, limit=22528

Please check your block device size.... best with blockdev --getsize64 
</dev/...> and compare it with  expected size. I think you are just simply 
using too small mtd device here.

Original comment by gmazyl...@gmail.com on 18 Dec 2013 at 5:52

GoogleCodeExporter commented 9 years ago
Please check your block device size.... best with blockdev --getsize64 
</dev/...> and compare it with  expected size. I think you are just simply 
using too small mtd device here.

Reply:
The flash is larger than 80M, in addition, I use U-disk(512M) to experiment 
and the result is the same as before,but it is succeed on X86.
Where the problem may be?

Original comment by askxia...@gmail.com on 24 Dec 2013 at 5:59