syscalls/connect02: Handle IPV6_ADDRFORM removal and listen() EINVAL
PATCH 1/1 syscalls/connect02: Handle IPV6_ADDRFORM removal and listen() EINVAL
Upstream kernel commit 31c5ea8a3296 ("ipv6: Remove IPV6_ADDRFORM.") completely removed IPV6_ADDRFORM socket option support from the Linux kernel, causing setsockopt(SOL_IPV6, IPV6_ADDRFORM, ...) to return -ENOPROTOOPT.
In addition, commit 8cc3aef0cb19 ("tcp: Do not allow buggy transitions between ehash and lhash2.") intentionally disallows converting an unhashed established socket into a listening socket by returning -EINVAL from listen().
Update connect02 to:
1. Skip the test with TCONF when IPV6_ADDRFORM returns ENOPROTOOPT or EOPNOTSUPP.
2. Accept EINVAL from listen() on kernels with the TCP transition restriction.
--- testcases/kernel/syscalls/connect/connect02.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/connect/connect02.c +17 -1
@@ -91,6 +91,14 @@ static void run(void) sizeof(optval)));if (TST_RET ==-1 ) { +SAFE_CLOSE (confd1); +SAFE_CLOSE (fd); + +if (TST_ERR ==ENOPROTOOPT ||TST_ERR ==EOPNOTSUPP ) { +tst_brk (TCONF |TTERRNO , +"IPV6_ADDRFORM is removed/unsupported by this kernel" ); + } +tst_res (TFAIL |TTERRNO ,"setsockopt(IPV6_ADDRFORM) failed" );return ;
@@ -104,7 +112,15 @@ static void run(void) sizeof(reset_addr));SAFE_BIND (fd, (struct sockaddr *)&bind_addr4,sizeof (bind_addr4)); -SAFE_LISTEN (fd,5 ); +TEST (listen (fd,5 )); +if (TST_RET ==-1 ) { +if (TST_ERR ==EINVAL ) { +SAFE_CLOSE (fd); +SAFE_CLOSE (confd1); +continue ; + } +tst_brk (TBROK |TTERRNO ,"listen(fd,5) failed unexpectedly" ); + } addrlen =tst_get_connect_address (fd, &client_addr2); confd2 =SAFE_SOCKET (AF_INET ,SOCK_STREAM ,IPPROTO_TCP );
Signature · 5 lines
2.55.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Ramesh,
testcases/kernel/syscalls/connect/connect02.c static void run(void) · line 93
Quoted 6 lines · Ramesh Chhetri
syscalls/connect02: Handle
IPV6_ADDRFORMremoval andlisten()EINVALtestcases/kernel/syscalls/connect/connect02.c +3
-0@@ -91,6 +91,14 @@ static void run(void) +if (TST_ERR ==ENOPROTOOPT ||TST_ERR ==EOPNOTSUPP ) { +tst_brk (TCONF |TTERRNO , +"IPV6_ADDRFORM is removed/unsupported by this kernel" );
High: A kernel containing b6f6118901d1 without 82c9ae440857 returns ENOPROTOOPT here because its TCP branch leaves retv at -ENOPROTOOPT. This turns the existing regression check's TFAIL into TCONF. Distinguish removal, for example with getsockopt(IPV6_ADDRFORM) on fd before closing it, and retain TFAIL when the option still exists.
testcases/kernel/syscalls/connect/connect02.c static void run(void) · line 116
Quoted 6 lines
testcases/kernel/syscalls/connect/connect02.c +5
-0@@ -104,7 +112,15 @@ static void run(void) +if (TST_ERR ==EINVAL ) { +SAFE_CLOSE (fd); +SAFE_CLOSE (confd1); +continue ; + }
Medium: When 8cc3aef0cb19 rejects this transition, all 1000 iterations take this branch and the function reports TPASS without reaching the second connect()/accept() that exercises CVE-2018-9568.
Report TCONF when the transition is unavailable instead of silently continuing to a pass.
Verdict - Needs revision
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp