commit e389c99937a35815e2752952634cc80c3aaf1d4e Author: David Goulet dgoulet@ev0ke.net Date: Thu Jun 23 09:51:27 2016 -0400
syscall: Whitelist sched_getaffinity(2)
ffmepg needed this syscall else it would end up in an infinite loop.
Reported in Debian: https://bugs.debian.org/805741
Signed-off-by: David Goulet dgoulet@ev0ke.net --- src/common/compat.h | 5 +++++ src/lib/syscall.c | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+)
diff --git a/src/common/compat.h b/src/common/compat.h index 38bf191..b14df7f 100644 --- a/src/common/compat.h +++ b/src/common/compat.h @@ -109,6 +109,9 @@ void tsocks_once(tsocks_once_t *o, void (*init_routine)(void)); #ifndef __NR_accept4 #define __NR_accept4 -13 #endif +#ifndef __NR_sched_getaffinity +#define __NR_sched_getaffinity -14 +#endif
#define TSOCKS_NR_SOCKET __NR_socket #define TSOCKS_NR_CONNECT __NR_connect @@ -123,6 +126,7 @@ void tsocks_once(tsocks_once_t *o, void (*init_routine)(void)); #define TSOCKS_NR_GETRANDOM __NR_getrandom #define TSOCKS_NR_FUTEX __NR_futex #define TSOCKS_NR_ACCEPT4 __NR_accept4 +#define TSOCKS_NR_SCHED_GETAFFINITY __NR_sched_getaffinity
/* * Despite glibc providing wrappers for these calls for a long time @@ -188,6 +192,7 @@ void tsocks_once(tsocks_once_t *o, void (*init_routine)(void)); #define TSOCKS_NR_GETPEERNAME SYS_getpeername #define TSOCKS_NR_LISTEN SYS_listen #define TSOCKS_NR_RECVMSG SYS_recvmsg +#define TSOCKS_NR_SCHED_GETAFFINITY SYS_sched_getaffinity
#endif /* __FreeBSD__, __FreeBSD_kernel__, __darwin__, __NetBSD__ */
diff --git a/src/lib/syscall.c b/src/lib/syscall.c index 8b24f4c..9495a64 100644 --- a/src/lib/syscall.c +++ b/src/lib/syscall.c @@ -164,6 +164,25 @@ static LIBC_RECVMSG_RET_TYPE handle_recvmsg(va_list args) return tsocks_recvmsg(sockfd, msg, flags); }
+/* + * Handle sched_getaffinity(2) syscall. + * NOTE: ffmpeg is one of the application that needs this one on the + * whitelist. + */ +static LIBC_SYSCALL_RET_TYPE handle_sched_getaffinity(va_list args) +{ + pid_t pid; + size_t cpusetsize; + cpu_set_t *mask; + + pid = va_arg(args, __typeof__(pid)); + cpusetsize = va_arg(args, __typeof__(cpusetsize)); + mask = va_arg(args, __typeof__(mask)); + + return tsocks_libc_syscall(TSOCKS_NR_SCHED_GETAFFINITY, pid, cpusetsize, + mask); +} + #if defined(__linux__) /* * Handle gettid(2) syscall. @@ -455,6 +474,9 @@ LIBC_SYSCALL_RET_TYPE tsocks_syscall(long int number, va_list args) case TSOCKS_NR_INOTIFY_RM_WATCH: ret = handle_inotify_rm_watch(args); break; + case TSOCKS_NR_SCHED_GETAFFINITY: + ret = handle_sched_getaffinity(args); + break; #endif /* __linux__ */ default: /*
tor-commits@lists.torproject.org