-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read error due to assumed corrupt block with all-zero nonce #532
Comments
Running
|
Hi, nice analysis so far! But i think you have to adjust the offset in the encrypted file due to overhead (https://github.com/rfjakob/gocryptfs/blob/master/Documentation/file-format.md) Alternatively, can you run gocryptfs-xray on the encrypted file? |
and |
Ok, can you
to see how much data is zeroed out? My guess is that it is more than the nonce. But in any case, the data in this block is gone. |
PS: You could also try to decrypt the file using https://github.com/slackner/gocryptfs-inspect would be interesting to see what it thinks about block 2328. |
=> From 0x92a312 to 0x92afff it's only zeros. Running
so the zeros are starting with 0x92a312 |
and then |
Using
gives also the input/output error as I guess it's reading the full block to be able to modify the one byte. So running instead
the result from
Reading that just written byte again with |
This
worked because you seeked to |
OK, I tried again:
Reading it back And
So it seems that the copy operation fixed the IV. This leads to the questions:
That only a hand full of files are affected and that those files were only added lately (I don't know whether a good file was in between though) was checked by creating a |
First non-zero byte is at offset 9613312 bytes = 4096 * 2347. I think your NAS lost one 4096-byte block starting from 4096 * 2346 = 9609216 to 4096 * 2347 = 9613312 However, we should see two corrupt gocryptfs blocks in this case, as one zeroed-out 4096-byte NAS block will most likely touch two 4128-byte gocryptfs blocks. We are still missing something here. I suggest taking a big file (1GB from urandom? But NOT all-zero!), copying it many times unencrypted to the NAS, drop caches [1] and then checking the md5sum of all files. Then try again via gocryptfs? [1]: |
I've now created a random filled 1 GB and a 10 GB file locally.
So today everything is working as expected. This is sad as it makes this issue sporadic. :( Deleting all the additional files I've copied the last few days for testing and trying again: still no problem But, interesting observation: the inode numbers seem to not get reused. The latest copies have created inodes 71334 and 71336. But I'd have expected to be just above 71020 or so again as I didn't fill that vault anymore after I discovered the problems (+ the test copies, of course) All copying and deleting are done in the terminal, so I'm sure that no desktop environment trash can or similar is interfering with these tests |
Now I retried again. Copying the 1 GB random file to 20 separate files in the encrypted vault worked fine. Then 10x a 10 GB random file also worked. Copying then exactly the same three files to the same path of the NAS mount ( Then copying the affected file again in the vault in the same path but with a different name shows that the second copy is also corrupt. The position is different though:
|
As I still have the problem I wonder what to do to get it solved. Something that I have discovered is that
with some times Also I do wonder whether this issue might be related to #483 ? |
Also one more discovery: when I use |
Hmm, rsync and cp probably use different block sizes. By the way, what's the NAS model and do you know what Samba version it runs? Also, can you show what mount options were negotiated for the mount (from mount output) |
The NAS is a Synology DS920+. Samba on the NAS is version 4.4.16 Mounting is happening via Since a few months I'm using only |
Same issue without gocryptfs involved on Synology DS218 ? |
Interesting. restic sees a similar problem on cifs: restic/restic#2659 (comment) :
|
I've got a rather big gocryptfs mount (a bit over 8 TB data). Reading a few lately added files (each with a few GB each) I get
Eingabe-/Ausgabefehler
(input/output error) when accessing a little part (I guess: exactly one block) inside them.Running
gocryptfs -fsck /mnt/vault_cipherdir
I get this output (names shortend, numbers original):Things I already did:
hexdump -n 512 -s 0 foo/bar2/def
looks good (as expected)hexdump -n 512 -s $((1024*4*2328)) foo/bar2/def
looks bad and gives theEingabe-/Ausgabefehler
(as expected). In/var/log/syslog
it creates two entriesgocryptfs[6457]: doRead 71017: corrupt block #2328: all-zero nonce
hexdump -n 512 -s 0 /mnt/vault_cipherdir/<EncryptedPathToSameFile>
looks good (as expected)hexdump -n 512 -s $((1024*4*2328)) /mnt/vault_cipherdir/<EncryptedPathToSameFile>
also looks good (as hoped for as it shows that the underlying system is working correctly) and prints a bunch of "random" bytesfoo/bar2/def
) again. No error messages.md5sum foo/bar2/def2
) I get anEingabe-/Ausgabefehler
for this file as well (/var/log/syslog
says this time twice:gocryptfs[6457]: doRead 71074: corrupt block #88480: all-zero nonce
)What I think is curious: all the inums are just above 71000. Coincidence?
Is this information enough for you to fix the issue - or do you need more information from me?
gocryptfs --version
givesgocryptfs 1.7.1; go-fuse 0.0~git20190214.58dcd77; 2019-12-26 go1.13.5 linux/amd64
The text was updated successfully, but these errors were encountered: