Skip to contentSkip to conversation

tests/sctp: allow both ENOSPC and EINPROGRESS for CIPSO tag space errors

PATCH In review Paul Moore 2 participants 3 messages Aug 9, 2022 – Aug 23, 2022 SELinux security module

lore
Share & tools
lore

Paul Moore

author maintainer
#0 lore raw

PATCH 1/1 tests/sctp: allow both ENOSPC and EINPROGRESS for CIPSO tag space errors

If the NetLabel subsystem in the kernel is configured to apply CIPSO packet labels directly to the packets instead of the sockets, the kernel will return EINPROGRESS on a failed connect(2) instead of ENOSPC. This is due to differences in how the CIPSO labels are applied to network traffic in the two cases and how the error conditions are able to be propagated back to userspace.

This patch allows both error codes to the relevant SCTP test cases.

---
 tests/sctp/test |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tests/sctp/test +3 -3
index 69dcbef..5626ab8 100755
@@ -508,7 +508,7 @@ $pid = server_start( "-t test_sctp_server_t -l s0:c20.c300",
 # TAG 1 allows categories 0 to 239 to be sent
 $result = system
 "runcon -t test_sctp_client_t -l s0:c20.c300 -- $basedir/sctp_client $v seq 127.0.0.1 1035 2>&1";
-ok( $result >> 8 eq 7 );
+ok( ( $result >> 8 eq 7 ) || ( $result >> 8 eq 6 ) );
 
 if ($test_clpeeloff) {
 
@@ -675,7 +675,7 @@ $pid = server_start( "-t test_sctp_server_t -l s0:c20.c335",
 # TAG 2 allows a maximum of 15 categories in exchange
 $result = system
 "runcon -t test_sctp_client_t -l s0:c200.c216 -- $basedir/sctp_client $v seq 127.0.0.1 1035 2>&1";
-ok( $result >> 8 eq 7 );
+ok( ( $result >> 8 eq 7 ) || ( $result >> 8 eq 6 ) );
 
 if ($test_clpeeloff) {
 
@@ -842,7 +842,7 @@ $pid = server_start( "-t test_sctp_server_t -l s0:c20.c50",
 # TAG 2 allows a maximum of 7 ranges in exchange
 $result = system
 "runcon -t test_sctp_client_t -l s0:c20,c22,c24,c30.c33,c38,c42.c45,c48,c50 -- $basedir/sctp_client $v seq 127.0.0.1 1035 2>&1";
-ok( $result >> 8 eq 7 );
+ok( ( $result >> 8 eq 7 ) || ( $result >> 8 eq 6 ) );
 
 if ($test_clpeeloff) {
 
#1 lore raw
Quoted 37 lines · Paul Moore

If the NetLabel subsystem in the kernel is configured to apply CIPSO packet labels directly to the packets instead of the sockets, the kernel will return EINPROGRESS on a failed connect(2) instead of ENOSPC. This is due to differences in how the CIPSO labels are applied to network traffic in the two cases and how the error conditions are able to be propagated back to userspace.

This patch allows both error codes to the relevant SCTP test cases.

---
 tests/sctp/test |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tests/sctp/test +2 -2
index 69dcbef..5626ab8 100755
@@ -508,7 +508,7 @@ $pid = server_start( "-t test_sctp_server_t -l s0:c20.c300",
 # TAG 1 allows categories 0 to 239 to be sent
 $result = system
 "runcon -t test_sctp_client_t -l s0:c20.c300 -- $basedir/sctp_client $v seq 127.0.0.1 1035 2>&1";
-ok( $result >> 8 eq 7 );
+ok( ( $result >> 8 eq 7 ) || ( $result >> 8 eq 6 ) );
 
 if ($test_clpeeloff) {
 
@@ -675,7 +675,7 @@ $pid = server_start( "-t test_sctp_server_t -l s0:c20.c335",
 # TAG 2 allows a maximum of 15 categories in exchange
 $result = system
 "runcon -t test_sctp_client_t -l s0:c200.c216 -- $basedir/sctp_client $v seq 127.0.0.1 1035 2>&1";
-ok( $result >> 8 eq 7 );
+ok( ( $result >> 8 eq 7 ) || ( $result >> 8 eq 6 ) );
 
 if ($test_clpeeloff) {
 

tests/sctp/test $pid = server_start( "-t test_sctp_server_t -l s0:c20.c50", · line 847

Quoted 7 lines
tests/sctp/test +1 -1
@@ -842,7 +842,7 @@ $pid = server_start( "-t test_sctp_server_t -l s0:c20.c50",
 # TAG 2 allows a maximum of 7 ranges in exchange
 $result = system
 "runcon -t test_sctp_client_t -l s0:c20,c22,c24,c30.c33,c38,c42.c45,c48,c50 -- $basedir/sctp_client $v seq 127.0.0.1 1035 2>&1";
-ok( $result >> 8 eq 7 );
+ok( ( $result >> 8 eq 7 ) || ( $result >> 8 eq 6 ) );
 
 if ($test_clpeeloff) {

This patch makes sense regardless of the pending kernel fixes, so I applied it now:
https://github.com/SELinuxProject/selinux-testsuite/commit/c04b5bb4bdcf894a6de6afa0e7e24911dee8dcbf

Thanks!

Signature · 3 lines
Ondrej Mosnacek
Senior Software Engineer, Linux Security - SELinux kernel
Red Hat, Inc.
author maintainer
#2 lore raw
Quoted 15 lines · Ondrej Mosnacek
Quoted 13 lines · Paul Moore

If the NetLabel subsystem in the kernel is configured to apply CIPSO packet labels directly to the packets instead of the sockets, the kernel will return EINPROGRESS on a failed connect(2) instead of ENOSPC. This is due to differences in how the CIPSO labels are applied to network traffic in the two cases and how the error conditions are able to be propagated back to userspace.

This patch allows both error codes to the relevant SCTP test cases.

---
 tests/sctp/test |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

...

Quoted 3 lines

This patch makes sense regardless of the pending kernel fixes, so I applied it now:
https://github.com/SELinuxProject/selinux-testsuite/commit/c04b5bb4bdcf894a6de6afa0e7e24911dee8dcbf

Agreed, thanks Ondrej.

Signature · 1 line
paul-moore.com