Fredrik Fornwall
6 years ago
6 changed files with 73 additions and 91 deletions
@ -1,75 +0,0 @@ |
|||
From 3b78843ee18a3099196a61c7d07c0e2d24d1fe84 Mon Sep 17 00:00:00 2001 |
|||
From: vishalbiswas <vshlbiswas@ymail.com> |
|||
Date: Tue, 17 Jan 2017 10:10:23 +0530 |
|||
Subject: [PATCH] syscall: Add clone |
|||
|
|||
Signed-off-by: vishalbiswas <vshlbiswas@ymail.com> |
|||
---
|
|||
src/common/compat.h | 4 ++++ |
|||
src/lib/syscall.c | 21 +++++++++++++++++++++ |
|||
2 files changed, 25 insertions(+) |
|||
|
|||
diff --git a/src/common/compat.h b/src/common/compat.h
|
|||
index f490113..bf42f07 100644
|
|||
--- a/src/common/compat.h
|
|||
+++ b/src/common/compat.h
|
|||
@@ -126,6 +126,9 @@ void tsocks_once(tsocks_once_t *o, void (*init_routine)(void));
|
|||
#ifndef __NR_fork |
|||
#define __NR_fork -18 |
|||
#endif |
|||
+#ifndef __NR_clone
|
|||
+#define __NR_clone -19
|
|||
+#endif
|
|||
|
|||
#define TSOCKS_NR_SOCKET __NR_socket |
|||
#define TSOCKS_NR_CONNECT __NR_connect |
|||
@@ -145,6 +148,7 @@ void tsocks_once(tsocks_once_t *o, void (*init_routine)(void));
|
|||
#define TSOCKS_NR_GETTIMEOFDAY __NR_gettimeofday |
|||
#define TSOCKS_NR_CLOCK_GETTIME __NR_clock_gettime |
|||
#define TSOCKS_NR_FORK __NR_fork |
|||
+#define TSOCKS_NR_CLONE __NR_clone
|
|||
|
|||
/* |
|||
* Despite glibc providing wrappers for these calls for a long time |
|||
diff --git a/src/lib/syscall.c b/src/lib/syscall.c
|
|||
index d0fdaaa..c8a9b46 100644
|
|||
--- a/src/lib/syscall.c
|
|||
+++ b/src/lib/syscall.c
|
|||
@@ -423,6 +423,24 @@ static LIBC_SYSCALL_RET_TYPE handle_fork(void)
|
|||
{ |
|||
return tsocks_libc_syscall(TSOCKS_NR_FORK); |
|||
} |
|||
+
|
|||
+/*
|
|||
+ * * Handle clone(2) syscall.
|
|||
+ * */
|
|||
+static LIBC_SYSCALL_RET_TYPE handle_clone(va_list args)
|
|||
+{
|
|||
+ int (*fn)(void*);
|
|||
+ void* child_stack;
|
|||
+ int flags;
|
|||
+ void* arg;
|
|||
+
|
|||
+ fn = va_arg(args, __typeof__(fn));
|
|||
+ child_stack = va_arg(args, __typeof__(child_stack));
|
|||
+ flags = va_arg(args, __typeof__(flags));
|
|||
+ arg = va_arg(args, __typeof__(arg));
|
|||
+
|
|||
+ return tsocks_libc_syscall(TSOCKS_NR_CLONE, fn, child_stack, flags, arg);
|
|||
+}
|
|||
#endif /* __linux__ */ |
|||
|
|||
/* |
|||
@@ -541,6 +559,9 @@ LIBC_SYSCALL_RET_TYPE tsocks_syscall(long int number, va_list args)
|
|||
case TSOCKS_NR_FORK: |
|||
ret = handle_fork(); |
|||
break; |
|||
+ case TSOCKS_NR_CLONE:
|
|||
+ ret = handle_clone(args);
|
|||
+ break;
|
|||
#endif /* __linux__ */ |
|||
default: |
|||
/* |
|||
--
|
|||
2.11.0 |
|||
|
@ -0,0 +1,11 @@ |
|||
diff -u -r ../torsocks-2.3.0/Makefile.am ./Makefile.am
|
|||
--- ../torsocks-2.3.0/Makefile.am 2018-11-19 15:42:40.000000000 +0000
|
|||
+++ ./Makefile.am 2018-11-21 22:42:40.280616653 +0000
|
|||
@@ -1,6 +1,6 @@
|
|||
ACLOCAL_AMFLAGS = -I config |
|||
|
|||
-SUBDIRS = src doc tests extras
|
|||
+SUBDIRS = src doc extras
|
|||
|
|||
dist_doc_DATA = ChangeLog |
|||
|
@ -0,0 +1,21 @@ |
|||
diff -u -r ../torsocks-2.3.0/src/common/compat.h ./src/common/compat.h
|
|||
--- ../torsocks-2.3.0/src/common/compat.h 2018-11-19 15:42:40.000000000 +0000
|
|||
+++ ./src/common/compat.h 2018-11-21 22:39:33.390432043 +0000
|
|||
@@ -129,6 +129,9 @@
|
|||
#ifndef __NR_memfd_create |
|||
#define __NR_memfd_create -19 |
|||
#endif |
|||
+#ifndef __NR_clone
|
|||
+#define __NR_clone -19
|
|||
+#endif
|
|||
|
|||
#define TSOCKS_NR_SOCKET __NR_socket |
|||
#define TSOCKS_NR_CONNECT __NR_connect |
|||
@@ -149,6 +152,7 @@
|
|||
#define TSOCKS_NR_CLOCK_GETTIME __NR_clock_gettime |
|||
#define TSOCKS_NR_FORK __NR_fork |
|||
#define TSOCKS_NR_MEMFD_CREATE __NR_memfd_create |
|||
+#define TSOCKS_NR_CLONE __NR_clone
|
|||
|
|||
/* |
|||
* Despite glibc providing wrappers for these calls for a long time |
@ -0,0 +1,38 @@ |
|||
diff -u -r ../torsocks-2.3.0/src/lib/syscall.c ./src/lib/syscall.c
|
|||
--- ../torsocks-2.3.0/src/lib/syscall.c 2018-11-19 15:42:40.000000000 +0000
|
|||
+++ ./src/lib/syscall.c 2018-11-21 22:37:53.867404833 +0000
|
|||
@@ -437,6 +437,24 @@
|
|||
|
|||
return tsocks_libc_syscall(TSOCKS_NR_MEMFD_CREATE, name, flags); |
|||
} |
|||
+
|
|||
+/*
|
|||
+ * * Handle clone(2) syscall.
|
|||
+ * */
|
|||
+static LIBC_SYSCALL_RET_TYPE handle_clone(va_list args)
|
|||
+{
|
|||
+ int (*fn)(void*);
|
|||
+ void* child_stack;
|
|||
+ int flags;
|
|||
+ void* arg;
|
|||
+
|
|||
+ fn = va_arg(args, __typeof__(fn));
|
|||
+ child_stack = va_arg(args, __typeof__(child_stack));
|
|||
+ flags = va_arg(args, __typeof__(flags));
|
|||
+ arg = va_arg(args, __typeof__(arg));
|
|||
+
|
|||
+ return tsocks_libc_syscall(TSOCKS_NR_CLONE, fn, child_stack, flags, arg);
|
|||
+}
|
|||
#endif /* __linux__ */ |
|||
|
|||
/* |
|||
@@ -558,6 +576,9 @@
|
|||
case TSOCKS_NR_MEMFD_CREATE: |
|||
ret = handle_memfd_create(args); |
|||
break; |
|||
+ case TSOCKS_NR_CLONE:
|
|||
+ ret = handle_clone(args);
|
|||
+ break;
|
|||
#endif /* __linux__ */ |
|||
default: |
|||
/* |
@ -1,12 +0,0 @@ |
|||
diff -u -r ../torsocks-2.2.0/tests/Makefile.am ./tests/Makefile.am
|
|||
--- ../torsocks-2.2.0/tests/Makefile.am 2016-10-18 12:44:01.000000000 -0400
|
|||
+++ ./tests/Makefile.am 2016-12-20 21:23:41.960184652 -0500
|
|||
@@ -29,7 +29,7 @@
|
|||
test_connect_LDADD = $(LIBTAP) $(LIBTORSOCKS) |
|||
|
|||
test_fd_passing_SOURCES = test_fd_passing.c |
|||
-test_fd_passing_LDADD = $(LIBTAP) $(LIBTORSOCKS) -lpthread
|
|||
+test_fd_passing_LDADD = $(LIBTAP) $(LIBTORSOCKS)
|
|||
|
|||
test_getpeername_SOURCES = test_getpeername.c |
|||
test_getpeername_LDADD = $(LIBTAP) $(LIBTORSOCKS) |
Loading…
Reference in new issue