All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/connect01: bypass bionic connect() implementation
@ 2018-03-03  0:09 Greg Hackmann
  2018-03-05 21:47 ` Petr Vorel
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Hackmann @ 2018-03-03  0:09 UTC (permalink / raw)
  To: ltp

The connect01 test segfaults on Android when it gets to the second
testcase.  bionic's connect() implementation hooks into the netd client
library, which in turn expects addr to be a valid pointer.

Work around this by directly calling the kernel connect syscall.

Signed-off-by: Greg Hackmann <ghackmann@google.com>
---
 testcases/kernel/syscalls/connect/connect01.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/testcases/kernel/syscalls/connect/connect01.c b/testcases/kernel/syscalls/connect/connect01.c
index 2be83cfbb..e9b9c7945 100644
--- a/testcases/kernel/syscalls/connect/connect01.c
+++ b/testcases/kernel/syscalls/connect/connect01.c
@@ -116,6 +116,23 @@ int TST_TOTAL = sizeof(tdat) / sizeof(tdat[0]);
 static char *argv0;
 #endif
 
+#ifdef __BIONIC__
+/**
+ * bionic's connect() implementation calls netdClientInitConnect() before
+ * sending the request to the kernel.  We need to bypass this, or the test will
+ * segfault during the addr = (struct sockaddr *)-1 testcase.
+ */
+#include "lapi/syscalls.h"
+
+static int sys_connect(int sockfd, const struct sockaddr *addr,
+		socklen_t addrlen)
+{
+	return ltp_syscall(__NR_connect, sockfd, addr, addrlen);
+}
+
+#define connect(sockfd, addr, addrlen) sys_connect(sockfd, addr, addrlen)
+#endif
+
 int main(int argc, char *argv[])
 {
 	int lc;
-- 
2.16.2.395.g2e18187dfd-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [LTP] [PATCH] syscalls/connect01: bypass bionic connect() implementation
  2018-03-03  0:09 [LTP] [PATCH] syscalls/connect01: bypass bionic connect() implementation Greg Hackmann
@ 2018-03-05 21:47 ` Petr Vorel
  2018-03-06 10:11   ` Cyril Hrubis
  0 siblings, 1 reply; 4+ messages in thread
From: Petr Vorel @ 2018-03-05 21:47 UTC (permalink / raw)
  To: ltp

Hi Greg,

> The connect01 test segfaults on Android when it gets to the second
> testcase.  bionic's connect() implementation hooks into the netd client
> library, which in turn expects addr to be a valid pointer.

> Work around this by directly calling the kernel connect syscall.

> Signed-off-by: Greg Hackmann <ghackmann@google.com>
> ---
>  testcases/kernel/syscalls/connect/connect01.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)

> diff --git a/testcases/kernel/syscalls/connect/connect01.c b/testcases/kernel/syscalls/connect/connect01.c
> index 2be83cfbb..e9b9c7945 100644
> --- a/testcases/kernel/syscalls/connect/connect01.c
> +++ b/testcases/kernel/syscalls/connect/connect01.c
> @@ -116,6 +116,23 @@ int TST_TOTAL = sizeof(tdat) / sizeof(tdat[0]);
>  static char *argv0;
>  #endif

> +#ifdef __BIONIC__
> +/**
> + * bionic's connect() implementation calls netdClientInitConnect() before
> + * sending the request to the kernel.  We need to bypass this, or the test will
> + * segfault during the addr = (struct sockaddr *)-1 testcase.
> + */
> +#include "lapi/syscalls.h"
> +
> +static int sys_connect(int sockfd, const struct sockaddr *addr,
> +		socklen_t addrlen)
> +{
> +	return ltp_syscall(__NR_connect, sockfd, addr, addrlen);
> +}
> +
> +#define connect(sockfd, addr, addrlen) sys_connect(sockfd, addr, addrlen)
> +#endif
> +
>  int main(int argc, char *argv[])
>  {
>  	int lc;

Pushed, thanks!


Kind regards,
Petr

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [LTP] [PATCH] syscalls/connect01: bypass bionic connect() implementation
  2018-03-05 21:47 ` Petr Vorel
@ 2018-03-06 10:11   ` Cyril Hrubis
  2018-03-06 10:41     ` Petr Vorel
  0 siblings, 1 reply; 4+ messages in thread
From: Cyril Hrubis @ 2018-03-06 10:11 UTC (permalink / raw)
  To: ltp

Hi!
Maybe it's a good idea to call the raw syscall regardless of the libc
implementation since we had cases where tests started to segfault on
glibc upgrade or in special conditions where libc had to convert
structure layouts between 32bit/64bit userspace/kernel.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [LTP] [PATCH] syscalls/connect01: bypass bionic connect() implementation
  2018-03-06 10:11   ` Cyril Hrubis
@ 2018-03-06 10:41     ` Petr Vorel
  0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2018-03-06 10:41 UTC (permalink / raw)
  To: ltp

Hi,

> Maybe it's a good idea to call the raw syscall regardless of the libc
> implementation since we had cases where tests started to segfault on
> glibc upgrade or in special conditions where libc had to convert
> structure layouts between 32bit/64bit userspace/kernel.
Pushed change where the raw syscall is called regardless of the libc implementation.


Kind regards,
Petr

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-06 10:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-03  0:09 [LTP] [PATCH] syscalls/connect01: bypass bionic connect() implementation Greg Hackmann
2018-03-05 21:47 ` Petr Vorel
2018-03-06 10:11   ` Cyril Hrubis
2018-03-06 10:41     ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.