USB data eater

08.01.2011 14:23

I found a curious feature the other day while copying some (rather important) data from an 512 MB USB flash drive. The contents of the files differed each time I copied them. Some further testing turned out that there's a part of the drive's address space that is unreliable and will return single-byte errors when read back.

For instance, here's a list of bytes that differed between two consecutive sequential reads:

0x0078071b: d5 != 4e, 11010101 ^ 01001110 = 10011011
0x007807c0: fc != fe, 11111100 ^ 11111110 = 00000010
0x007836d6: 46 != 56, 01000110 ^ 01010110 = 00010000
0x00785267: 65 != e5, 01100101 ^ 11100101 = 10000000
0x007852c7: 11 != 51, 00010001 ^ 01010001 = 01000000
0x00785344: 65 != 39, 01100101 ^ 00111001 = 01011100
0x0078720b: 00 != 40, 00000000 ^ 01000000 = 01000000
0x00787250: 86 != a6, 10000110 ^ 10100110 = 00100000
0x00787274: 51 != d1, 01010001 ^ 11010001 = 10000000
0x0078732f: 6a != 38, 01101010 ^ 00111000 = 01010010
0x00787336: 75 != f5, 01110101 ^ 11110101 = 10000000
0x00787389: 53 != 73, 01010011 ^ 01110011 = 00100000
0x007890f2: 01 != 52, 00000001 ^ 01010010 = 01010011
0x0078919c: b7 != 37, 10110111 ^ 00110111 = 10000000
0x0078933d: c2 != e2, 11000010 ^ 11100010 = 00100000
0x00789676: 5c != 7c, 01011100 ^ 01111100 = 00100000
0x0078b478: de != fe, 11011110 ^ 11111110 = 00100000
0x0078b4ad: bf != ff, 10111111 ^ 11111111 = 01000000
0x0078b512: ae != be, 10101110 ^ 10111110 = 00010000
0x0078b54c: 0d != 4d, 00001101 ^ 01001101 = 01000000
0x0078b5d3: 75 != f5, 01110101 ^ 11110101 = 10000000
0x0078d70c: 02 != 12, 00000010 ^ 00010010 = 00010000
0x0078d799: 01 != 3c, 00000001 ^ 00111100 = 00111101
0x0078f69e: e4 != 9c, 11100100 ^ 10011100 = 01111000
0x0078f79f: b3 != 93, 10110011 ^ 10010011 = 00100000
0x00793653: 5d != 1d, 01011101 ^ 00011101 = 01000000
0x0079367a: 39 != 19, 00111001 ^ 00011001 = 00100000
0x007936de: c5 != 67, 11000101 ^ 01100111 = 10100010
0x007936f6: 3a != 2a, 00111010 ^ 00101010 = 00010000
0x00793738: 49 != 09, 01001001 ^ 00001001 = 01000000
0x007937a9: 36 != 16, 00110110 ^ 00010110 = 00100000
0x007990fe: c7 != 57, 11000111 ^ 01010111 = 10010000
0x007991c8: 0d != 1d, 00001101 ^ 00011101 = 00010000
0x007b5024: 38 != 81, 00111000 ^ 10000001 = 10111001
0x007b504b: 91 != 7b, 10010001 ^ 01111011 = 11101010
0x007b50ce: 86 != 06, 10000110 ^ 00000110 = 10000000
0x007bf094: 80 != c0, 10000000 ^ 11000000 = 01000000
0x007bf0e9: 48 != 9c, 01001000 ^ 10011100 = 11010100
0x007bf0f3: c3 != d3, 11000011 ^ 11010011 = 00010000
0x007bf10c: 69 != e9, 01101001 ^ 11101001 = 10000000
0x007bf17c: 1c != 5c, 00011100 ^ 01011100 = 01000000
0x007bf1d0: e2 != f2, 11100010 ^ 11110010 = 00010000
Address range scanned 0x00000000 .. 0x1e800000, 42 bytes differ

The errors seem to be limited to addresses between 0x00780000 and 0x007bffff, a 256 kB block, but the list of error addresses differs after each read. Bits will switch both from 0 to 1 and 1 to 0, as evident from the dump above, which seems to suggest this isn't due to faulty or stuck bits in the flash ROM.

For the record, the drive presents itself as:

usb 1-6.3: New USB device found, idVendor=0204, idProduct=6025
usb 1-6.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-6.3: Product: USB Flash Drive
usb 1-6.3: Manufacturer: PIXIKA

Just to be sure, I've tried reading this key on two different computers and both gave the same result (i.e. bytes from the address range above were always corrupted).

So, what is to be learned from this? Bad flash drives can silently corrupt your data (making my previous assumption about block level CRC invalid) - there is no evidence in kernel logs that the software was aware of corruption. I guess a fancy filesystem would protect you, but who uses that on USB drives?

Also of note is that badblocks(8) will not detect this by default (as it seems to depend on the kernel throwing an IO error). Only when run in read-write mode (-n flag, probably also -w) will it report problems with the drive.

This makes it the second case of silent data corruption in the last 3 months. Seriously, sometimes I feel like a magnet for broken technology.

Posted by Tomaž | Categories: Digital

Comments

Sometimes? :)

Posted by Kristjan Lapuh (via Facebook)

Add a new comment


(No HTML tags allowed. Separate paragraphs with a blank line.)