classification
Title: test_sha256 from test_socket fails on ppc64le arch
Type: Stage:
Components: Tests Versions: Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, cstratak, haypo, rdecker
Priority: normal Keywords:

Created on 2017-10-05 19:58 by cstratak, last changed 2017-10-13 19:58 by rdecker.

Files
File name Uploaded Description Edit
trace cstratak, 2017-10-09 18:11
trace2 cstratak, 2017-10-10 15:08
trace_x86_64 rdecker, 2017-10-13 19:58
Messages (9)
msg303783 - (view) Author: Charalampos Stratakis (cstratak) * Date: 2017-10-05 19:58
The issue is reproducible on a CentOS 7.4 on ppc64le architecture. It passes successfully on other arch's (however the other power pc arch's might also be affected).

How to reproduce:

Compile python 3.6 from source.

Run ./python3 -m test --verbose test_socket

And it fails with:

ERROR: test_sha256 (test.test_socket.LinuxKernelCryptoAPI)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/test/cpython/Lib/test/test_socket.py", line 5424, in test_sha256
    op.sendall(b"abc")
OSError: [Errno 126] Required key not available
msg303974 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2017-10-09 15:23
> The issue is reproducible on a CentOS 7.4 on ppc64le architecture.

What is the kernel version?

It would be nice to have the strace output. Example:

strace -o trace ./python -m test -v test_socket -m test_sha256
# then get the trace file

I'm surprised because it seems like ENOKEY (error 126) can only be get on accept(), not on send():
http://elixir.free-electrons.com/linux/latest/source/crypto/af_alg.c#L295
msg303975 - (view) Author: Charalampos Stratakis (cstratak) * Date: 2017-10-09 15:25
Forgot the mention the kernel version which is 3.10.0-693.2.1.el7.ppc64le
msg303989 - (view) Author: Charalampos Stratakis (cstratak) * Date: 2017-10-09 18:11
Attaching the strace output.
msg304036 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2017-10-10 13:12
Charalampos Stratakis: "Attaching the strace output."

Oh thanks! I guess tha the interesting syscalls are:

socket(AF_ALG, SOCK_SEQPACKET|SOCK_CLOEXEC, 0) = 3
bind(3, {sa_family=AF_ALG, sa_data="hash\0\0\0\0\0\0\0\0\0\0"}, 88) = 0
accept4(3, NULL, NULL, SOCK_CLOEXEC)    = 4
send(4, "abc", 3, 0)                    = -1 ENOKEY (Required key not available)
close(4)                                = 0

test_socket calls bind() with typ='hash', name='sha256', but in the strace, I only see 'hash'.

strace is maybe outdated and fails to display the full bind() address, or Python doesn't serialize correctly the address.

--

On my Fedora 26, I see sha256 in the bind call:

socket(AF_ALG, SOCK_SEQPACKET|SOCK_CLOEXEC, 0) = 3
bind(3, {sa_family=AF_ALG, sa_data="hash\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0sha256\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"}, 88) = 0
accept4(3, NULL, NULL, SOCK_CLOEXEC)    = 4
sendto(4, "abc", 3, 0, NULL, 0)         = 3
recvfrom(4, "\272x\26\277\217\1\317\352AA@\336]\256\"#\260\3a\243\226\27z\234\264\20\377a\362\0\25\255", 512, 0, NULL, NULL) = 32
close(4)                                = 0
accept4(3, NULL, NULL, SOCK_CLOEXEC)    = 4
sendto(4, "a", 1, MSG_MORE, NULL, 0)    = 1
sendto(4, "b", 1, MSG_MORE, NULL, 0)    = 1
sendto(4, "c", 1, MSG_MORE, NULL, 0)    = 1
sendto(4, "", 0, 0, NULL, 0)            = 0
recvfrom(4, "\272x\26\277\217\1\317\352AA@\336]\256\"#\260\3a\243\226\27z\234\264\20\377a\362\0\25\255", 512, 0, NULL, NULL) = 32
close(4)                                = 0
close(3)                                = 0
msg304037 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2017-10-10 13:13
> strace is maybe outdated and fails to display the full bind() address,

I vote for this option since I see addrlen=88 in both examples.
msg304044 - (view) Author: Charalampos Stratakis (cstratak) * Date: 2017-10-10 13:45
Indeed the version of strace is 'strace-4.12-4.el7'.

I will try to provide output from the latest one.
msg304051 - (view) Author: Charalampos Stratakis (cstratak) * Date: 2017-10-10 15:08
Attaching the output of:

strace -s 128 -e trace=%network -o trace ./python3 -m test -v test_socket -m test_sha256

using the latest version of strace (4.19).
msg304353 - (view) Author: Ryan Decker (rdecker) Date: 2017-10-13 19:58
I seem to be having this issue on CentOS 7.4 but running on x86_64 instead of ppc64le. I have attached an strace using version 4.17 (the lastest version from scl) created as follows:

strace -s 128 -e trace=%network -o trace ./python -m test -v test_socket -m test_sha256


== CPython 3.6.3 (default, Oct 13 2017, 11:16:36) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
== Linux-3.10.0-693.2.2.el7.x86_64-x86_64-with-centos-7.4.1708-Core little-endian
== cwd: /home/ryan/Downloads/Python-3.6.3/build/test_python_4140
== CPU count: 8
== encodings: locale=UTF-8, FS=utf-8
Run tests sequentially
0:00:00 load avg: 0.13 [1/1] test_socket
test_sha256 (test.test_socket.LinuxKernelCryptoAPI) ... ERROR

======================================================================
ERROR: test_sha256 (test.test_socket.LinuxKernelCryptoAPI)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ryan/Downloads/Python-3.6.3/Lib/test/test_socket.py", line 5424, in test_sha256
    op.sendall(b"abc")
OSError: [Errno 126] Required key not available

----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (errors=1)
test test_socket failed
test_socket failed

1 test failed:
    test_socket

Total duration: 39 ms
Tests result: FAILURE
History
Date User Action Args
2017-10-13 19:58:38rdeckersetfiles: + trace_x86_64
nosy: + rdecker
messages: + msg304353

2017-10-10 15:08:41cstrataksetfiles: + trace2

messages: + msg304051
2017-10-10 13:45:40cstrataksetmessages: + msg304044
2017-10-10 13:13:34hayposetmessages: + msg304037
2017-10-10 13:12:05hayposetmessages: + msg304036
2017-10-09 18:11:25cstrataksetfiles: + trace

messages: + msg303989
2017-10-09 15:25:14cstrataksetmessages: + msg303975
2017-10-09 15:23:28hayposetnosy: + haypo
messages: + msg303974
2017-10-05 19:58:44cstrataksetnosy: + christian.heimes
2017-10-05 19:58:24cstratakcreate