Skip to content
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

accept vs accept4 syscalls on 32 bit x86 #260

Closed
rpurdie opened this issue Jun 22, 2023 · 2 comments
Closed

accept vs accept4 syscalls on 32 bit x86 #260

rpurdie opened this issue Jun 22, 2023 · 2 comments
Labels
Milestone

Comments

@rpurdie
Copy link

rpurdie commented Jun 22, 2023

Within Yocto Project we recently set 5.15 as our minimum kernel version. This changes the way glibc is built such that the accept() call changes to use the accept4 syscall behind the scenes. This causes various test failures in accept, net-yy-inet6, net-yy-inet and
net-y-unix. I'm not sure how this should be handled in strace?

As an example:

cat net-yy-inet6.gen.log
--- exp
+++ out
@@ -5,7 +5,7 @@
getsockopt(3TCPv6:[[::1]:46887], SOL_TCP, TCP_MAXSEG, [536], [4]) = 0
socket(AF_INET6, SOCK_STREAM, IPPROTO_IP) = 4TCPv6:[17255]
connect(4TCPv6:[17255], {sa_family=AF_INET6, sin6_port=htons(46887), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_scope_id=0}, 28) = 0
-accept(3TCPv6:[[::1]:46887], {sa_family=AF_INET6, sin6_port=htons(60152), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_scope_id=0}, [28]) = 5TCPv6:[[::1]:46887-[::1]:60152]>
+accept4(3TCPv6:[[::1]:46887], {sa_family=AF_INET6, sin6_port=htons(60152), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_scope_id=0}, [28], 0) = 5TCPv6:[[::1]:46887-[::1]:60152]>
getpeername(5TCPv6:[[::1]:46887-[::1]:60152]>, {sa_family=AF_INET6, sin6_port=htons(60152), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_scope_id=0}, [28]) = 0
getpeername(4TCPv6:[[::1]:60152-[::1]:46887]>, {sa_family=AF_INET6, sin6_port=htons(46887), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_scope_id=0}, [28]) = 0
setsockopt(4TCPv6:[[::1]:60152-[::1]:46887]>, SOL_TCP, TCP_MAXSEG, [536], 4) = 0
net-yy-inet6.gen.test: failed test: ../../src/strace -a22 -yy -eclose,network ../net-yy-inet6 output mismatch
FAIL net-yy-inet6.gen.test (exit status: 1)

@ldv-alt
Copy link
Member

ldv-alt commented Jun 22, 2023 via email

@ldv-alt ldv-alt added the tests label Jun 26, 2023
@ldv-alt ldv-alt added this to the v6.4 milestone Jun 26, 2023
ldv-alt added a commit that referenced this issue Jun 26, 2023
The libc function is allowed to implement accept() using accept4()
syscall, so migrate to accept4() those tests that trace accept() syscall
but do not test accept() specifically, and change the test of accept()
syscall to invoke either __NR_accept or __NR_socketcall(SYS_ACCEPT)
directly.

* tests/accept_compat.h: Remove.
* tests/Makefile.am (EXTRA_DIST): Remove accept_compat.h.
* tests/accept.c [TEST_SYSCALL_NAME]: Do not invoke accept(),
call __NR_accept or __NR_socketcall if available, or skip the test.
* tests/net-y-unix.c: Do not include "accept_compat.h".
(main): Invoke accept4() instead of accept().
* tests/net-yy-inet.c: Likewise.
* tests/net-yy-unix.c: Likewise.

Resolves: #260
@rpurdie
Copy link
Author

rpurdie commented Jun 27, 2023

Thanks!

turistu pushed a commit to turistu/strace that referenced this issue Jul 6, 2023
The libc function is allowed to implement accept() using accept4()
syscall, so migrate to accept4() those tests that trace accept() syscall
but do not test accept() specifically, and change the test of accept()
syscall to invoke either __NR_accept or __NR_socketcall(SYS_ACCEPT)
directly.

* tests/accept_compat.h: Remove.
* tests/Makefile.am (EXTRA_DIST): Remove accept_compat.h.
* tests/accept.c [TEST_SYSCALL_NAME]: Do not invoke accept(),
call __NR_accept or __NR_socketcall if available, or skip the test.
* tests/net-y-unix.c: Do not include "accept_compat.h".
(main): Invoke accept4() instead of accept().
* tests/net-yy-inet.c: Likewise.
* tests/net-yy-unix.c: Likewise.

Resolves: strace#260
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants