SELinuxProject / selinux-testsuite

This is the upstream SELinux testsuite which is designed as a basic set of regression tests for the SELinux kernel functionality.
GNU General Public License v2.0
54 stars 43 forks source link

BUG: fix SCTP test race conditions #49

Closed WOnder93 closed 5 years ago

WOnder93 commented 5 years ago

There is a race condition in the SCTP tests that causes failures when the SCTP server program takes too long to get past the listen() call. In such case the client attempts to connect to the port when noone is listening yet, leading to a test failure.

This situation can be easily reproduced by adding sleep(1) before the listen() call in tests/sctp/sctp_server.c.

Fix this by having the sctp_server, sctp_peeloff_server, and sctp_asconf_params_server programs write something to a file after successfully calling listen() to inform the test script that it can run the client.

Another possible race condition is due to the 'kill TERM, ...' calls, which may not terminate the server quickly enough, leading to the new server failing to bind to the port (which is still being used by the old server). Fix this by sending the KILL signal rather than TERM (there is really no point in being graceful here).

Signed-off-by: Ondrej Mosnacek omosnace@redhat.com

stephensmalley commented 5 years ago

I guess my only question is why is this showing up as an issue for SCTP now when it has never been reported to be a problem for the inet_socket tests, which use the same pattern. I do note that the wait time was reduced in 9d7d40ab1e04a6e679023a48ee2765fc3f8ca1ca, so I suppose that made it more likely. unix_socket tests also have similar pattern although those still use the longer wait times.

WOnder93 commented 5 years ago

Hm, not sure why it didn't appear there, possibly the pre-listen steps are just slightly slower in the SCTP programs... I will convert the other cases tomorrow, I didn't realize that the same pattern is used elsewhere.

WOnder93 commented 5 years ago

Closing in favor of #50.