From 012152f3d1f111541f2fbb4c1e65c91243cd6bde Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Fri, 28 Oct 2016 20:05:57 +0200 Subject: [PATCH] fusefrontend: I/O error instead of panic on all-zero nonce Running xfstests generic/075 on tmpfs often triggered a panic for what seems to be a tmpfs bug. Quoting from the email to lkml, http://www.spinics.net/lists/kernel/msg2370127.html : tmpfs seems to be incorrectly returning 0-bytes when reading from a file that is concurrently being truncated. --- internal/contentenc/content.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/contentenc/content.go b/internal/contentenc/content.go index dd3b77a..c42a844 100644 --- a/internal/contentenc/content.go +++ b/internal/contentenc/content.go @@ -113,7 +113,10 @@ func (be *ContentEnc) DecryptBlock(ciphertext []byte, blockNo uint64, fileID []b // Extract nonce nonce := ciphertext[:be.cryptoCore.IVLen] if bytes.Equal(nonce, be.allZeroNonce) { - panic("Hit an all-zero nonce. This MUST NOT happen!") + // Bug in tmpfs? + // https://github.com/rfjakob/gocryptfs/issues/56 + // http://www.spinics.net/lists/kernel/msg2370127.html + return nil, errors.New("all-zero nonce") } ciphertextOrig := ciphertext ciphertext = ciphertext[be.cryptoCore.IVLen:]