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
csiphash alignment issue on non x86-64 platforms #2483
Comments
Comment from firstyear (@Firstyear) at 2017-10-25 02:12:16 Metadata Update from @Firstyear:
|
Comment from firstyear (@Firstyear) at 2017-10-25 02:12:41 Metadata Update from @Firstyear:
|
Comment from firstyear (@Firstyear) at 2017-10-30 03:03:52 @lslebodn @vashirov Would really appreciate you both looking at this - to check my solution matches expectation and also that it works on ppc64 which had the issue, Thanks! |
Comment from lslebodn at 2017-10-30 14:10:52
IMHO you can always add I think there still can be a problem with following code:
I am not sure whether ((intptr_t)m % sizeof(uint32_t) == 0) |
Comment from vashirov (@vashirov) at 2017-10-30 14:12:38 Test no longer crashes, but still fails:
|
Comment from lslebodn at 2017-10-30 14:25:22 BTW if you would like to get rid of dynamic allocation you can try following change. I didn't test taht
|
Comment from lslebodn at 2017-10-30 14:28:25 @vashirov We might get better error reporting with different cmocka assertions:
|
Comment from vashirov (@vashirov) at 2017-10-30 14:39:16
|
Comment from firstyear (@Firstyear) at 2017-10-31 02:28:32 Perhaps this is an endianness issues with the memcpy? |
Comment from firstyear (@Firstyear) at 2017-10-31 02:33:18
But we don't know how large the input is, so I think this may have a memcpy issues if in is not large enough (stack over-read). |
Comment from firstyear (@Firstyear) at 2017-10-31 02:33:30
Done, added to the patch :) |
Comment from firstyear (@Firstyear) at 2017-10-31 02:53:45
Done, it's simple :)
I think at this point it shouldn't matter, because it's just doing 32bit reads of the values, and pt is from &t which is a uint64_t, so that will be valid, and &m is from *in, which we just fixed to be aligned. So in both, this should be okay now. |
Comment from firstyear (@Firstyear) at 2017-10-31 02:59:15
Actually, I think the issue is here. We correctly copy in everything with le64toh for mi in uint64_t groups, but when we have a src without an input of size 8, we will hit uint8_t *m = (uint8_t *)in; which does not do the same le64toh. So this could be the issue. |
Comment from firstyear (@Firstyear) at 2017-10-31 03:01:26
^^-- Yep, that's the failure. On an aligned source we pass, but line 44 is an input of 24 bytes, so we'll skip that loop and go to the uint8_t *m = (uint8_t *)in; line, which is not correctly using endianness controls. As a result we get the failure. The first test will be src_sz = 8, and the second is src_sz = 3, so that's why this happens. I'm still not sure of the fix though .... |
Comment from firstyear (@Firstyear) at 2017-10-31 04:06:35 This is what I have now, but it's still not solving the issues from the line 44 test. |
Comment from firstyear (@Firstyear) at 2017-10-31 06:36:27 So a build/cmocka test on copr with ppc64le works, so this is definitely an endianness issue with non-multiple of 8 sized input data. |
Comment from lslebodn at 2017-10-31 10:24:38
That's possible :-) BTW it might be good idea to extend test suite and test string with length from 8 till 16. Unit tests are fast and it will cover all cases with endian issues. |
Comment from firstyear (@Firstyear) at 2017-11-01 01:43:56 Yes, this is a good idea. But you are also still assuming that I know how to solve this issue in a meaningful way :) I'll update the test cases for a start, |
Comment from firstyear (@Firstyear) at 2017-11-01 05:52:06 Okay, @vashirov here is a new patch which uses a different strategy to do the memcpy for excess bytes. I'll stay online for your morning to work through it with you. Thanks to @lslebodn for his advice, I added extra tests too and they all pass on LE x86_64 |
Comment from cgrzemba at 2017-11-01 10:07:15 seems to work on Solaris11.3 Sparc:
|
Comment from firstyear (@Firstyear) at 2017-11-01 10:21:03 Great! @cgrzemba thanks for testing! @vashirov is about to check this on a bigendian system to be sure the fix is correct. Thanks for your patience with this, |
Comment from vashirov (@vashirov) at 2017-11-01 10:30:56
All tests pass on ppc64 :) |
Comment from mreynolds (@mreynolds389) at 2017-11-02 03:25:30 LGTM, ack |
Comment from mreynolds (@mreynolds389) at 2017-11-02 03:25:31 Metadata Update from @mreynolds389:
|
Comment from firstyear (@Firstyear) at 2017-11-02 03:38:08 commit 7514464 commit 92c56e9 |
Comment from firstyear (@Firstyear) at 2017-11-02 03:38:08 Metadata Update from @Firstyear:
|
Cloned from Pagure issue: https://pagure.io/389-ds-base/issue/49424
Issue Description
On ppc64 and sparc64 csiphash relies on an alignment that is not correct. This can cause a crash condition to occur,
We should correct this issue asap
CC: @cgrzemba @lslebodn @vashirov
The text was updated successfully, but these errors were encountered: