-
Notifications
You must be signed in to change notification settings - Fork 73
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
Strange test failures #92
Comments
I am unable to reproduce the issue with the current code. Note, I have removed the sleep(1) that you rightfully pointed out. Could you test it again on your system whether you see that bug? Thanks. |
Strange, I can't reproduce it either now, even when I revert to 2da4a5a and remove the sleep. I upgraded to kernel 5.6.8 in the meantime, so let me try again with the 5.5 kernel... |
Yes, it does reproduce on 5.5.10, so it must have been fixed by a kernel change somewhere between 5.5 and 5.6. I'll try to bisect it. |
OK, never mind, it turns out I just didn't wait long enough... Now I'm getting the bug also on BTW, you reverted the sleep removal, but the commit lacks any explanation... |
Am Mittwoch, 6. Mai 2020, 17:15:35 CEST schrieb Ondrej Mosnáček:
Hi Ondrej,
OK, never mind, it turns out I just didn't wait long enough... Now I'm
getting the bug also on `5.6.8-200.fc31.x86_64` and
`5.7.0-0.rc4.1.fc33.x86_64` kernels (with current master and removed
sleep). It usually takes a couple hundred to thousand invocations to
trigger.
BTW, you reverted the sleep removal, but the commit lacks any explanation...
Hm, yes. It was midnight and I just wanted to get the testing to pass again.
Leaving a broken archive is not good.
Then I overlooked the description part...
Ciao
Stephan
|
Wait... isn't the problem that we are testing the stream mode with |
Am Mittwoch, 6. Mai 2020, 18:58:52 CEST schrieb Ondrej Mosnáček:
Hi Ondrej,
Wait... isn't the problem that we are testing the stream mode with
`xts(aes)`, which is not a stream cipher? I mean "stream" in the sense that
it updates the IV so that the encryption can continue with in a seprate
operation with the returned IV. IIUC, in stream mode the socket input can
be internally split into parts, which are processed in separate skcipher
operations, which would produce a different output for XTS, since it would
process each part with the same IV... Am I right?
A stream operation is intended to follow an init/update/final approach where
the update can be performed multiple times. Think of it as the traditional
crypto libs:
cipher_handle = alloc_init_cipher(key, IV);
encrypt(cipher_handle, somedata);
destroy(cipher_handle);
The stream API just implements that concept.
The key/IV is set with the init part. Thus, the multiple updates operate on
the existing cipher handle whose IV is internally updated as defined by the
chaining mode.
So, the stream API is unrealated to a stream cipher, it is just a reference
that you can stream data into the open cipher handle. Thus, it works with any
type of symmetric cipher.
I think the issue is some form of race because I see the issue regularly when
I run the kernel within a QEMU environment.
If I would recollect why I added the sleep(1) to the test code... I usually
comment my code heavily to just avoid such head-scratch...
Ciao
Stephan
|
Right, I probably mixed up the terminology, but my point was that Looking again at how XTS is defined, it seems one could implement transparent chaining by simply decrypting the final tweak using the tweak key and return it as the output IV... but I believe this has never been mandated nor implemented in the Crypto API (likely because of the overhead of the final tweak decryption, which would be pointless if you're not going to use the output IV - and there is currently no way to signal to the driver that you are going to need it). I could remember this wrong, so you should probably double-check with Herbert, but AFAIK this is how it is (and always has been). |
There is a race condition when these are run with the long XTS test vectors, so skip them for now. See: smuellerDD/libkcapi#92 Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
There is a race condition when these are run with the long XTS test vectors, so skip them for now. See: smuellerDD/libkcapi#92 Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
(Note : removing this causes issue : smuellerDD/issues/92) Revert commit d542b05 Signed-off-by: Sahana Prasad <sahana@redhat.com>
…a race condition when run with long XTS test vectors. For more information, see: smuellerDD#92 Signed-off-by: Sahana Prasad <sahana@redhat.com>
test/kcapi-main.c: Removes unneeded sleep. Reverts commit d542b05 test/test.sh: Temporarily disables the multithreaded tests that cause a race condition when run with long XTS test vectors. For more information, see: smuellerDD#92 Signed-off-by: Sahana Prasad <sahana@redhat.com>
test/kcapi-main.c: Removes unneeded sleep. Reverts commit d542b05 test/test.sh: Temporarily disables the multithreaded tests that cause a race condition when run with long XTS test vectors. For more information, see: smuellerDD#92 Signed-off-by: Sahana Prasad <sahana@redhat.com>
You are quite right. I slightly reformatted the patches. Thanks for your help. |
The full discussion is provided with #92. Reported-by: Ondrej Mosnáček Signed-off-by: Sahana Prasad <sahana@redhat.com> Signed-off-by: Stephan Mueller <smueller@chronox.de>
https://build.opensuse.org/request/show/831601 by user msmeissn + dimstar_suse - update to 1.2.0: * enhancement: kcapi-hasher: add madvise and 64 bit support by Brandur Simonsen * fix: fix clang warnding in KDF implementation by Khem Raj * fix: fix inverted logic in kcapi-main test logic reported by Ondrej Mosnáček * fix: return error when iteration count is zero for PBKDF as reported by Guido Vranken * enhancement: add function kcapi_cipher_stream_update_last to indicate the last block of a symmetric cipher stream operation * disable XTS multithreaded tests as it triggers a race discussed in smuellerDD/libkcapi#92. The conclusion is the following: xts(aes) doesn't support chaining requests like for other ciphers such as CBC (at least as implemented in the kernel Crypto API). That can be seen in `crypto/testmgr.h` - th
When running the libkcapi testsuite, I sometimes (very rarely) notice failures in the "Symmetric synchronous multithreaded non-aligned test" instances with long (8k) messages. I discovered that this becomes much more often if I replace the
sleep(1);
intests/kcapi-main.c
with a shorter delay (say,usleep(100);
).To be honest, I don't see any logical reason for the sleep to be there. It seems it is only swiping a real bug under the carpet...
Here is an excerpt from strace over one such failed run:
Command:
Output:
For some reason, the recvmsg() call is cut off early and returns only 3344 bytes (I believe it is always this number). The second recvmsg() then returns the remaining 4848 bytes, however the resulting message doesn't match the expected output. Any idea what's going on? This looks like a bug somewhere in the AF_ALG interface.
Kernel version: 5.5.15-200.fc31.x86_64
The text was updated successfully, but these errors were encountered: