Ticket #21022: add_seccomp_syscall.patch

File add_seccomp_syscall.patch, 1.7 KB (added by cypherpunks, 4 years ago)
  • src/common/compat.h

    diff --git a/src/common/compat.h b/src/common/compat.h
    index aa1da28..2fdd5c2 100644
    a b void tsocks_once(tsocks_once_t *o, void (*init_routine)(void)); 
    114114#ifndef __NR_sched_getaffinity
    115115#define __NR_sched_getaffinity -14
    116116#endif
     117#ifndef __NR_seccomp
     118#define __NR_seccomp -15
     119#endif
    117120
    118121#define TSOCKS_NR_SOCKET    __NR_socket
    119122#define TSOCKS_NR_CONNECT   __NR_connect
    void tsocks_once(tsocks_once_t *o, void (*init_routine)(void)); 
    129132#define TSOCKS_NR_FUTEX     __NR_futex
    130133#define TSOCKS_NR_ACCEPT4   __NR_accept4
    131134#define TSOCKS_NR_SCHED_GETAFFINITY __NR_sched_getaffinity
     135#define TSOCKS_NR_SECCOMP   __NR_seccomp
    132136
    133137/*
    134138 * Despite glibc providing wrappers for these calls for a long time
  • src/lib/syscall.c

    diff --git a/src/lib/syscall.c b/src/lib/syscall.c
    index 789c380..10552bb 100644
    a b static LIBC_SYSCALL_RET_TYPE handle_inotify_rm_watch(va_list args) 
    372372
    373373        return inotify_rm_watch(fd, wd);
    374374}
     375
     376/*
     377 * Handle seccomp(2) syscall.
     378 */
     379static LIBC_SYSCALL_RET_TYPE handle_seccomp(va_list args)
     380{
     381        unsigned int operation, flags;
     382        void *sargs;
     383
     384        operation = va_arg(args, __typeof__(operation));
     385        flags = va_arg(args, __typeof__(flags));
     386        sargs = va_arg(args, __typeof__(sargs));
     387
     388        return tsocks_libc_syscall(TSOCKS_NR_SECCOMP, operation, flags, sargs);
     389}
    375390#endif /* __linux__ */
    376391
    377392/*
    LIBC_SYSCALL_RET_TYPE tsocks_syscall(long int number, va_list args) 
    478493        case TSOCKS_NR_SCHED_GETAFFINITY:
    479494                ret = handle_sched_getaffinity(args);
    480495                break;
     496        case TSOCKS_NR_SECCOMP:
     497                ret = handle_seccomp(args);
     498                break;
    481499#endif /* __linux__ */
    482500        default:
    483501                /*