Hello community, here is the log from the commit of package trinity for openSUSE:Factory checked in at 2015-09-19 06:55:24 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/trinity (Old) and /work/SRC/openSUSE:Factory/.trinity.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "trinity" Changes: -------- --- /work/SRC/openSUSE:Factory/trinity/trinity.changes 2015-08-21 07:42:02.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.trinity.new/trinity.changes 2015-09-19 06:55:39.000000000 +0200 @@ -1,0 +2,5 @@ +Thu Sep 17 14:22:00 UTC 2015 - mpluskal@suse.com + +- Update to 20150905 + +------------------------------------------------------------------- Old: ---- trinity-20150804.tar.xz New: ---- trinity-20150905.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ trinity.spec ++++++ --- /var/tmp/diff_new_pack.wsz01X/_old 2015-09-19 06:55:40.000000000 +0200 +++ /var/tmp/diff_new_pack.wsz01X/_new 2015-09-19 06:55:40.000000000 +0200 @@ -17,7 +17,7 @@ Name: trinity -Version: 20150804 +Version: 20150905 Release: 0 Summary: A Linux System call fuzz tester License: GPL-2.0 ++++++ trinity-20150804.tar.xz -> trinity-20150905.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/child.c new/trinity-20150905/child.c --- old/trinity-20150804/child.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/child.c 2015-09-17 16:21:20.000000000 +0200 @@ -173,6 +173,9 @@ cpu_set_t set; unsigned int cpudest; + if (no_bind_to_cpu == TRUE) + return; + if (sched_getaffinity(child->pid, sizeof(set), &set) != 0) return; @@ -374,7 +377,6 @@ */ void child_process(void) { - const char *lastop = NULL; int ret; ret = sigsetjmp(ret_jump, 1); @@ -398,6 +400,8 @@ i = rand() % ARRAY_SIZE(child_ops); if (rand() % 100 <= child_ops[i].likelyhood) { + const char *lastop = NULL; + if (lastop != child_ops[i].name) { //output(0, "Chose %s.\n", child_ops[i].name); lastop = child_ops[i].name; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/children/random-syscalls.c new/trinity-20150905/children/random-syscalls.c --- old/trinity-20150804/children/random-syscalls.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/children/random-syscalls.c 2015-09-17 16:21:20.000000000 +0200 @@ -146,6 +146,8 @@ } if (old != 0) { + // FIXME: Should factor in loadavg here, as with enough pids, a child can exceed 60s + // without getting scheduled. if (rec->tv.tv_sec - old > 60) { output(0, "Sanity check failed. Something stomped on rec->tv after syscall:%s(%lx, %lx, %lx) was:%lx now:%lx.\n", print_syscall_name(syscallnr, do32), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/fds/fds.c new/trinity-20150905/fds/fds.c --- old/trinity-20150804/fds/fds.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/fds/fds.c 2015-09-17 16:21:20.000000000 +0200 @@ -68,18 +68,15 @@ list_for_each(node, &fd_providers->list) { struct fd_provider *provider; - int ret; provider = (struct fd_provider *) node; if (provider->enabled == FALSE) continue; - ret = provider->open(); - if (ret == FALSE) - return FALSE; - - num_fd_providers_enabled++; + provider->enabled = provider->open(); + if (provider->enabled == TRUE) + num_fd_providers_enabled++; } output(0, "Enabled %d fd providers.\n", num_fd_providers_enabled); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/fds/files.c new/trinity-20150905/fds/files.c --- old/trinity-20150804/fds/files.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/fds/files.c 2015-09-17 16:21:20.000000000 +0200 @@ -47,7 +47,7 @@ "/proc/sysrq-trigger", "/proc/kmem", "/proc/kcore", /* dangerous/noisy/annoying stuff in /dev */ - "/dev/log", "/dev/mem", "/dev/kmsg", + "/dev/log", "/dev/mem", "/dev/kmsg", "/dev/kmem", NULL }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/fds/sockets.c new/trinity-20150905/fds/sockets.c --- old/trinity-20150804/fds/sockets.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/fds/sockets.c 2015-09-17 16:21:20.000000000 +0200 @@ -68,8 +68,6 @@ output(2, "fd[%i] = domain:%u (%s) type:0x%u protocol:%u %s\n", fd, domain, get_domain_name(domain), type, protocol, accepted ? "[accepted]" : ""); - - nr_sockets++; } static int open_socket(unsigned int domain, unsigned int type, unsigned int protocol) @@ -88,6 +86,11 @@ /* Set some random socket options. */ sso_socket(&shm->sockets[nr_sockets].triplet, &so, fd); + nr_sockets++; + + if (nr_sockets == NR_SOCKET_FDS) + goto skip_bind; + /* Sometimes, listen on created sockets. */ if (RAND_BOOL()) { int ret, one = 1; @@ -104,8 +107,10 @@ (void) listen(fd, RAND_RANGE(1, 128)); // ret = accept4(fd, sa, &salen, SOCK_NONBLOCK); -// if (ret != -1) +// if (ret != -1) { // add_socket(ret, domain, type, protocol, TRUE); +// nr_sockets++; +// } } skip_bind: @@ -220,7 +225,6 @@ { int fd, n, ret = FALSE; int cachefile; - unsigned int nr_to_create = NR_SOCKET_FDS; cachefile = creat(cachefilename, S_IWUSR|S_IRUSR); if (cachefile == -1) @@ -238,55 +242,49 @@ } if (n >= (int)ARRAY_SIZE(no_domains)) - nr_to_create = 0; + goto done; } - while (nr_to_create > 0) { - + while (nr_sockets < NR_SOCKET_FDS) { struct socket_triplet st; - for (st.family = 0; st.family < TRINITY_PF_MAX; st.family++) { + st.family = rand() % TRINITY_PF_MAX; - /* check for ctrl-c again. */ - if (shm->exit_reason != STILL_RUNNING) - goto out_unlock; + /* check for ctrl-c again. */ + if (shm->exit_reason != STILL_RUNNING) + goto out_unlock; + + if (do_specific_domain == TRUE) { + st.family = specific_domain; + //FIXME: If we've passed -P and we're spinning here without making progress + // then we should abort after a few hundred loops. + } - if (do_specific_domain == TRUE) { - st.family = specific_domain; - //FIXME: If we've passed -P and we're spinning here without making progress - // then we should abort after a few hundred loops. - } + if (get_domain_name(st.family) == NULL) + continue; - if (get_domain_name(st.family) == NULL) + if (valid_proto(st.family) == FALSE) { + if (do_specific_domain == TRUE) { + outputerr("Can't do protocol %s\n", get_domain_name(st.family)); + goto out_unlock; + } else { continue; - - if (valid_proto(st.family) == FALSE) { - if (do_specific_domain == TRUE) { - outputerr("Can't do protocol %s\n", get_domain_name(st.family)); - goto out_unlock; - } else { - continue; - } } + } - BUG_ON(st.family >= ARRAY_SIZE(no_domains)); - if (no_domains[st.family]) - continue; - - if (sanitise_socket_triplet(&st) == -1) - rand_proto_type(&st); - - fd = open_socket(st.family, st.type, st.protocol); - if (fd > -1) { - if (write_socket_to_cache(cachefile, &st) == FALSE) - goto out_unlock; - - nr_to_create--; - if (nr_to_create == 0) - goto done; - } else { - //outputerr("Couldn't open family:%d (%s)\n", st.family, get_domain_name(st.family)); - } + BUG_ON(st.family >= ARRAY_SIZE(no_domains)); + if (no_domains[st.family]) + continue; + + if (sanitise_socket_triplet(&st) == -1) + rand_proto_type(&st); + + fd = open_socket(st.family, st.type, st.protocol); + if (fd > -1) { + if (write_socket_to_cache(cachefile, &st) == FALSE) + goto out_unlock; + } else { + //outputerr("Couldn't open family:%d (%s)\n", st.family, get_domain_name(st.family)); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/generate-args.c new/trinity-20150905/generate-args.c --- old/trinity-20150804/generate-args.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/generate-args.c 2015-09-17 16:21:20.000000000 +0200 @@ -418,14 +418,21 @@ lock(&rec->lock); + //TODO: instead of rand64() do a rand arg type entry = syscalls[rec->nr].entry; rec->state = PREP; - rec->a1 = (unsigned long) rand64(); - rec->a2 = (unsigned long) rand64(); - rec->a3 = (unsigned long) rand64(); - rec->a4 = (unsigned long) rand64(); - rec->a5 = (unsigned long) rand64(); - rec->a6 = (unsigned long) rand64(); + if (entry->arg1type == ARG_UNDEFINED) + rec->a1 = (unsigned long) rand64(); + if (entry->arg2type == ARG_UNDEFINED) + rec->a2 = (unsigned long) rand64(); + if (entry->arg3type == ARG_UNDEFINED) + rec->a3 = (unsigned long) rand64(); + if (entry->arg4type == ARG_UNDEFINED) + rec->a4 = (unsigned long) rand64(); + if (entry->arg5type == ARG_UNDEFINED) + rec->a5 = (unsigned long) rand64(); + if (entry->arg6type == ARG_UNDEFINED) + rec->a6 = (unsigned long) rand64(); generic_sanitise(rec); if (entry->sanitise) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/include/compat.h new/trinity-20150905/include/compat.h --- old/trinity-20150804/include/compat.h 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/include/compat.h 2015-09-17 16:21:20.000000000 +0200 @@ -262,6 +262,9 @@ #ifndef NETLINK_LIST_MEMBERSHIPS #define NETLINK_LIST_MEMBERSHIPS 9 #endif +#ifndef NETLINK_CAP_ACK +#define NETLINK_CAP_ACK 10 +#endif /* linux/prctl.h */ #ifndef PR_MCE_KILL_GET @@ -280,6 +283,9 @@ #ifndef PR_SET_NO_NEW_PRIVS #define PR_SET_NO_NEW_PRIVS 38 #define PR_GET_NO_NEW_PRIVS 39 +#endif + +#ifndef PR_GET_TID_ADDRESS #define PR_GET_TID_ADDRESS 40 #endif @@ -300,6 +306,11 @@ #endif #endif +#ifndef PR_CAP_AMBIENT +#define PR_CAP_AMBIENT 47 +#endif + + /* linux/rds.h */ #ifndef RDS_CANCEL_SENT_TO #define RDS_CANCEL_SENT_TO 1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/include/random.h new/trinity-20150905/include/random.h --- old/trinity-20150804/include/random.h 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/include/random.h 2015-09-17 16:21:20.000000000 +0200 @@ -7,7 +7,7 @@ #define ONE_IN(x) ((rand() % x) == 0) // limit of RAND_MAX-1 #if RAND_MAX == 0x7FFFFFFF -#define RAND_32() ((rand() << 1) | (rand() & 1)) +#define RAND_32() rand() #define RAND_64() (((0ULL | rand()) << 33) | ((0ULL | rand()) << 2) | (rand() & 0x3)) #else #error "Unexpected RAND_MAX value. Please add support." @@ -23,6 +23,7 @@ void reseed(void); unsigned int new_seed(void); +bool init_random(void); void generate_rand_bytes(unsigned char *ptr, unsigned int len); unsigned int rand32(void); u64 rand64(void); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/include/syscalls-i386.h new/trinity-20150905/include/syscalls-i386.h --- old/trinity-20150804/include/syscalls-i386.h 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/include/syscalls-i386.h 2015-09-17 16:21:20.000000000 +0200 @@ -366,4 +366,20 @@ { .entry = &syscall_memfd_create }, { .entry = &syscall_bpf }, { .entry = &syscall_execveat }, + { .entry = &syscall_socket }, + { .entry = &syscall_socketpair }, + { .entry = &syscall_bind }, + { .entry = &syscall_connect }, + { .entry = &syscall_listen }, + { .entry = &syscall_accept4 }, + { .entry = &syscall_getsockopt }, + { .entry = &syscall_setsockopt }, + { .entry = &syscall_getsockname }, + { .entry = &syscall_getpeername }, + { .entry = &syscall_sendto }, + { .entry = &syscall_sendmsg }, + { .entry = &syscall_recvfrom }, + { .entry = &syscall_recvmsg }, + { .entry = &syscall_shutdown }, + { .entry = &syscall_userfaultfd }, }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/include/syscalls-s390.h new/trinity-20150905/include/syscalls-s390.h --- old/trinity-20150804/include/syscalls-s390.h 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/include/syscalls-s390.h 2015-09-17 16:21:20.000000000 +0200 @@ -275,9 +275,9 @@ { .entry = &syscall_statfs64 }, { .entry = &syscall_fstatfs64 }, { .entry = &syscall_remap_file_pages }, - { .entry = &syscall_ni_syscall }, - { .entry = &syscall_ni_syscall }, - { .entry = &syscall_ni_syscall }, + { .entry = &syscall_mbind }, + { .entry = &syscall_get_mempolicy }, + { .entry = &syscall_set_mempolicy }, { .entry = &syscall_mq_open }, { .entry = &syscall_mq_unlink }, { .entry = &syscall_mq_timedsend }, @@ -294,7 +294,7 @@ { .entry = &syscall_inotify_init }, { .entry = &syscall_inotify_add_watch }, { .entry = &syscall_inotify_rm_watch }, - { .entry = &syscall_ni_syscall }, + { .entry = &syscall_migrate_pages }, { .entry = &syscall_openat }, { .entry = &syscall_mkdirat }, { .entry = &syscall_mknodat }, @@ -317,7 +317,7 @@ { .entry = &syscall_sync_file_range }, { .entry = &syscall_tee }, { .entry = &syscall_vmsplice }, - { .entry = &syscall_ni_syscall }, + { .entry = &syscall_move_pages }, { .entry = &syscall_getcpu }, { .entry = &syscall_epoll_pwait }, { .entry = &syscall_utimes }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/include/syscalls-s390x.h new/trinity-20150905/include/syscalls-s390x.h --- old/trinity-20150804/include/syscalls-s390x.h 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/include/syscalls-s390x.h 2015-09-17 16:21:20.000000000 +0200 @@ -275,9 +275,9 @@ { .entry = &syscall_statfs64 }, { .entry = &syscall_fstatfs64 }, { .entry = &syscall_remap_file_pages }, - { .entry = &syscall_ni_syscall }, - { .entry = &syscall_ni_syscall }, - { .entry = &syscall_ni_syscall }, + { .entry = &syscall_mbind }, + { .entry = &syscall_get_mempolicy }, + { .entry = &syscall_set_mempolicy }, { .entry = &syscall_mq_open }, { .entry = &syscall_mq_unlink }, { .entry = &syscall_mq_timedsend }, @@ -294,7 +294,7 @@ { .entry = &syscall_inotify_init }, { .entry = &syscall_inotify_add_watch }, { .entry = &syscall_inotify_rm_watch }, - { .entry = &syscall_ni_syscall }, + { .entry = &syscall_migrate_pages }, { .entry = &syscall_openat }, { .entry = &syscall_mkdirat }, { .entry = &syscall_mknodat }, @@ -317,7 +317,7 @@ { .entry = &syscall_sync_file_range }, { .entry = &syscall_tee }, { .entry = &syscall_vmsplice }, - { .entry = &syscall_ni_syscall }, + { .entry = &syscall_move_pages }, { .entry = &syscall_getcpu }, { .entry = &syscall_epoll_pwait }, { .entry = &syscall_utimes }, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/include/syscalls-x86_64.h new/trinity-20150905/include/syscalls-x86_64.h --- old/trinity-20150804/include/syscalls-x86_64.h 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/include/syscalls-x86_64.h 2015-09-17 16:21:20.000000000 +0200 @@ -330,4 +330,5 @@ { .entry = &syscall_kexec_file_load }, { .entry = &syscall_bpf }, { .entry = &syscall_execveat }, + { .entry = &syscall_userfaultfd }, }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/include/trinity.h new/trinity-20150905/include/trinity.h --- old/trinity-20150804/include/trinity.h 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/include/trinity.h 2015-09-17 16:21:20.000000000 +0200 @@ -4,6 +4,7 @@ #include "syscall.h" extern unsigned int num_online_cpus; +extern bool no_bind_to_cpu; extern char *progname; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/mm/fault-write.c new/trinity-20150905/mm/fault-write.c --- old/trinity-20150804/mm/fault-write.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/mm/fault-write.c 2015-09-17 16:21:20.000000000 +0200 @@ -25,16 +25,22 @@ /* 4 byte (32bit) 8 byte (64bit) alignment */ if (i & ~((__WORDSIZE / 8) - 1)) { - unsigned long val; + unsigned long val = 0; i += sizeof(unsigned long); if (i > page_size) return; - if (RAND_BOOL()) - val = rand64(); - else - val = (unsigned long) get_address(); + switch (rand() % 4) { + case 0: val = rand64(); + break; + case 1: val = (unsigned long) get_address(); + break; + case 2: val = (unsigned long) ptr; + break; + case 3: val = get_len(); + break; + } *(unsigned long *)ptr = val; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/net/proto-alg.c new/trinity-20150905/net/proto-alg.c --- old/trinity-20150804/net/proto-alg.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/net/proto-alg.c 2015-09-17 16:21:20.000000000 +0200 @@ -38,6 +38,8 @@ strncpy((char *)alg->salg_name, hashes[i], len); break; case 2: + snprintf((char *)alg->salg_type, 8, "skcipher"); + snprintf((char *)alg->salg_name, 8, "cbc(aes)"); break; case 3: break; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/net/proto-decnet.c new/trinity-20150905/net/proto-decnet.c --- old/trinity-20150804/net/proto-decnet.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/net/proto-decnet.c 2015-09-17 16:21:20.000000000 +0200 @@ -22,7 +22,7 @@ dn->sdn_objnamel = rand() % 16; for (i = 0; i < dn->sdn_objnamel; i++) dn->sdn_objname[i] = rand(); - dn->sdn_add.a_len = rand() % 2; + dn->sdn_add.a_len = RAND_BOOL(); dn->sdn_add.a_addr[0] = rand(); dn->sdn_add.a_addr[1] = rand(); *addr = (struct sockaddr *) dn; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/net/proto-netlink.c new/trinity-20150905/net/proto-netlink.c --- old/trinity-20150804/net/proto-netlink.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/net/proto-netlink.c 2015-09-17 16:21:20.000000000 +0200 @@ -49,7 +49,8 @@ static const unsigned int netlink_opts[] = { NETLINK_ADD_MEMBERSHIP, NETLINK_DROP_MEMBERSHIP, NETLINK_PKTINFO, NETLINK_BROADCAST_ERROR, - NETLINK_NO_ENOBUFS, NETLINK_RX_RING, NETLINK_TX_RING, + NETLINK_NO_ENOBUFS, NETLINK_RX_RING, NETLINK_TX_RING, NETLINK_LISTEN_ALL_NSID, + NETLINK_LIST_MEMBERSHIPS, NETLINK_CAP_ACK, }; void netlink_setsockopt(struct sockopt *so) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/rand/interesting-numbers.c new/trinity-20150905/rand/interesting-numbers.c --- old/trinity-20150804/rand/interesting-numbers.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/rand/interesting-numbers.c 2015-09-17 16:21:20.000000000 +0200 @@ -46,7 +46,7 @@ switch (rand() % 10) { case 0: return 0x80000000 >> (rand() & 0x1f); // 2^n (1 -> 0x10000) case 1: return rand(); // 0 -> RAND_MAX (likely 0x7fffffff) - case 2: return 0xff << (rand() % 25); + case 2: return (unsigned int) 0xff << (4 * (rand() % 7)); case 3: return 0xffff0000; case 4: return 0xffffe000; case 5: return 0xffffff00 | RAND_BYTE(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/rand/random-length.c new/trinity-20150905/rand/random-length.c --- old/trinity-20150804/rand/random-length.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/rand/random-length.c 2015-09-17 16:21:20.000000000 +0200 @@ -9,10 +9,11 @@ int i = 0; if (RAND_BOOL()) { - switch (rand() % 3) { + switch (rand() % 4) { case 0: return sizeof(char); case 1: return sizeof(int); case 2: return sizeof(long); + case 3: return page_size; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/rand/random-pathname.c new/trinity-20150905/rand/random-pathname.c --- old/trinity-20150804/rand/random-pathname.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/rand/random-pathname.c 2015-09-17 16:21:20.000000000 +0200 @@ -1,8 +1,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include "log.h" -#include "maps.h" #include "random.h" #include "sanitise.h" #include "utils.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/rand/random.c new/trinity-20150905/rand/random.c --- old/trinity-20150804/rand/random.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/rand/random.c 2015-09-17 16:21:20.000000000 +0200 @@ -16,12 +16,11 @@ void generate_rand_bytes(unsigned char *ptr, unsigned int len) { unsigned int i; - unsigned char choice = rand() % 3; unsigned int startoffset = 0, remain; - unsigned char separators[3] = { ' ', '-', '\0' }; + unsigned char separators[] = { ':', ',', '.', ' ', '-', '\0', }; unsigned char separator; - switch (choice) { + switch (rand() % 3) { case 0: /* Complete garbage. */ for (i = 0; i < len; i++) @@ -35,7 +34,7 @@ case 2: /* numbers (for now, decimal only) */ - separator = separators[rand() % 3]; + separator = separators[rand() % sizeof(separators)]; remain = len; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/rand/seed.c new/trinity-20150905/rand/seed.c --- old/trinity-20150804/rand/seed.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/rand/seed.c 2015-09-17 16:21:20.000000000 +0200 @@ -23,6 +23,7 @@ #include <unistd.h> #include <stdlib.h> #include <sys/stat.h> +#include <errno.h> #include <fcntl.h> #include <limits.h> #include "shm.h" @@ -30,30 +31,59 @@ #include "pids.h" #include "log.h" #include "random.h" +#include "utils.h" + +static int urandomfd; /* The actual seed lives in the shm. This variable is used * to store what gets passed in from the command line -s argument */ unsigned int seed = 0; -unsigned int new_seed(void) +static int fallbackseed(void) { - int fd; struct timeval t; unsigned int r; - if ((fd = open("/dev/urandom", O_RDONLY)) < 0 || - read(fd, &r, sizeof(r)) != sizeof(r)) { - r = rand(); - if (!(RAND_BOOL())) { - gettimeofday(&t, NULL); - r |= t.tv_usec; - } + //printf("Fell back to gtod seed! errno:%s\n", strerror(errno)); + r = rand(); + if (!(RAND_BOOL())) { + gettimeofday(&t, NULL); + r |= t.tv_usec; } - if (fd >= 0) - close(fd); return r; } +unsigned int new_seed(void) +{ + unsigned int r, bits; + + if (urandomfd == -1) + return fallbackseed(); + + if (read(urandomfd, &r, sizeof(r)) != sizeof(r)) + return fallbackseed(); + + if (read(urandomfd, &bits, sizeof(bits)) != sizeof(bits)) + return fallbackseed(); + + bits %= 31; + bits = max(bits, 8U); + r &= ((1 << bits) -1); + + //printf("new seed:%u\n", r); + return r; +} + +bool init_random(void) +{ + urandomfd = open("/dev/urandom", O_RDONLY); + if (urandomfd == -1) { + printf("urandom: %s\n", strerror(errno)); + return FALSE; + } + return TRUE; +} + /* * If we passed in a seed with -s, use that. Otherwise make one up from time of day. */ @@ -90,6 +120,7 @@ /* if not in child context, we must be main. */ if (child == NULL) { +// printf("Setting shm seed:%u\n", shm->seed); srand(shm->seed); return; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/shm.c new/trinity-20150905/shm.c --- old/trinity-20150804/shm.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/shm.c 2015-09-17 16:21:20.000000000 +0200 @@ -75,6 +75,11 @@ childptrslen &= PAGE_MASK; shm->children = memalign(page_size, childptrslen); + if (shm->children == NULL) { + printf("Failed to allocate child structures.\n"); + exit(EXIT_FAILURE); + } + memset(shm->children, 0, childptrslen); /* We allocate the childdata structs as shared mappings, because diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/signals.c new/trinity-20150905/signals.c --- old/trinity-20150804/signals.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/signals.c 2015-09-17 16:21:20.000000000 +0200 @@ -85,6 +85,8 @@ /* we want default behaviour for child process signals */ (void)signal(SIGFPE, SIG_DFL); (void)signal(SIGCHLD, SIG_DFL); + (void)signal(SIGABRT, SIG_DFL); + (void)signal(SIGSEGV, SIG_DFL); (void)signal(SIGINT, ctrlc_handler); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/syscalls/mmap.c new/trinity-20150905/syscalls/mmap.c --- old/trinity-20150804/syscalls/mmap.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/syscalls/mmap.c 2015-09-17 16:21:20.000000000 +0200 @@ -50,15 +50,11 @@ } while (getline(&buffer, &n, fp) >= 0) { - unsigned int free; + unsigned long long free; - if (sscanf(buffer, "MemFree: %u", &free) == 1) { - unsigned long long freegb; - - freegb = free / 1024; - - if (freegb < GB(8ULL)) { - printf("Free memory: %.2fGB\n", (double) freegb / 1024); + if (sscanf(buffer, "MemFree: %llu", &free) == 1) { + if ((free * 1024) < GB(8ULL)) { + printf("Free memory: %.2fGB\n", (double) free / 1024 / 1024); printf("Low on memory, disabling mmaping of 1GB pages\n"); sizes[5] = page_size; return 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/syscalls/move_pages.c new/trinity-20150905/syscalls/move_pages.c --- old/trinity-20150804/syscalls/move_pages.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/syscalls/move_pages.c 2015-09-17 16:21:20.000000000 +0200 @@ -49,7 +49,7 @@ /* nodes = array of ints specifying desired location for each page */ nodes = calloc(count, sizeof(int)); for (i = 0; i < count; i++) - nodes[i] = (int) rand() % 2; + nodes[i] = (int) RAND_BOOL(); rec->a4 = (unsigned long) nodes; /* status = array of ints returning status of each page.*/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/syscalls/munmap.c new/trinity-20150905/syscalls/munmap.c --- old/trinity-20150804/syscalls/munmap.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/syscalls/munmap.c 2015-09-17 16:21:20.000000000 +0200 @@ -17,41 +17,36 @@ static void sanitise_munmap(struct syscallrecord *rec) { - unsigned long len; - unsigned long nr_pages; - unsigned long offset, offsetpagenr; - map = common_set_mmap_ptr_len(); action = 0; - switch (rand() % 20) { - case 0: + if (ONE_IN(20) == TRUE) { /* delete the whole mapping. */ action = WHOLE; return; + } - case 1 ... 10: + if (RAND_BOOL()) { /* unmap a range of the mapping. */ + unsigned long nr_pages; + unsigned long offset, offsetpagenr; + unsigned long len; + nr_pages = map->size / page_size; - offsetpagenr = (rand() % nr_pages); + offsetpagenr = rand() % nr_pages; offset = offsetpagenr * page_size; rec->a1 = (unsigned long) map->ptr + offset; len = (rand() % (nr_pages - offsetpagenr)) + 1; len *= page_size; rec->a2 = len; - return; - - case 11 ... 19: + } else { /* just unmap 1 page of the mapping. */ + rec->a1 = (unsigned long) map->ptr; rec->a1 += (rand() % map->size) & PAGE_MASK; rec->a2 = page_size; - return; - - default: - break; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/syscalls/open.c new/trinity-20150905/syscalls/open.c --- old/trinity-20150804/syscalls/open.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/syscalls/open.c 2015-09-17 16:21:20.000000000 +0200 @@ -31,11 +31,39 @@ return mask; } +static void sanitise_open(struct syscallrecord *rec) +{ + unsigned long flags; + + flags = get_o_flags(); + + rec->a2 |= flags; + + if (rec->a2 & O_CREAT) + rec->a3 = 0666; + + if (rec->a2 & O_TMPFILE) + rec->a3 = 0666; +} + +static void sanitise_openat(struct syscallrecord *rec) +{ + unsigned long flags; + + flags = get_o_flags(); + + rec->a3 |= flags; + + if (rec->a3 & O_CREAT) + rec->a4 = 0666; + + if (rec->a3 & O_TMPFILE) + rec->a4 = 0666; +} + /* * SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, int, mode) */ -static void sanitise_open(struct syscallrecord *rec); - struct syscallentry syscall_open = { .name = "open", .num_args = 3, @@ -52,20 +80,9 @@ .sanitise = sanitise_open, }; -static void sanitise_open(struct syscallrecord *rec) -{ - unsigned long flags; - - flags = get_o_flags(); - - rec->a2 |= flags; -} - /* * SYSCALL_DEFINE4(openat, int, dfd, const char __user *, filename, int, flags, int, mode) */ -static void sanitise_openat(struct syscallrecord *rec); - struct syscallentry syscall_openat = { .name = "openat", .num_args = 4, @@ -85,15 +102,6 @@ .sanitise = sanitise_openat, }; -static void sanitise_openat(struct syscallrecord *rec) -{ - unsigned long flags; - - flags = get_o_flags(); - - rec->a3 |= flags; -} - /* * SYSCALL_DEFINE3(open_by_handle_at, int, mountdirfd, * struct file_handle __user *, handle, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/syscalls/perf_event_open.c new/trinity-20150905/syscalls/perf_event_open.c --- old/trinity-20150804/syscalls/perf_event_open.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/syscalls/perf_event_open.c 2015-09-17 16:21:20.000000000 +0200 @@ -934,7 +934,7 @@ long long branch_sample = 0; - if (rand() % 2) + if (RAND_BOOL()) return rand64(); if (RAND_BOOL()) @@ -1232,16 +1232,12 @@ /* requires ROOT to select specific CPU if pid==-1 (all processes) */ /* -1 means all CPUs */ - switch(rand() % 2) { - case 0: + if (RAND_BOOL()) { /* Any CPU */ rec->a3 = -1; - break; - case 1: + } else { /* Default to the get_cpu() value */ /* set by ARG_CPU */ - default: - break; } /* group_fd */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/syscalls/prctl.c new/trinity-20150905/syscalls/prctl.c --- old/trinity-20150804/syscalls/prctl.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/syscalls/prctl.c 2015-09-17 16:21:20.000000000 +0200 @@ -36,6 +36,7 @@ #ifdef __mips__ GET_FP_MODE, SET_FP_MODE, #endif + PR_CAP_AMBIENT, }; #define NR_PRCTL_OPTS ARRAY_SIZE(prctl_opts) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/syscalls/select.c new/trinity-20150905/syscalls/select.c --- old/trinity-20150804/syscalls/select.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/syscalls/select.c 2015-09-17 16:21:20.000000000 +0200 @@ -31,9 +31,9 @@ /* set some random fd's. */ for (i = 0; i < rand32() % 10; i++) { - FD_SET(rand32() % 1024, rfds); - FD_SET(rand32() % 1024, wfds); - FD_SET(rand32() % 1024, exfds); + FD_SET(rand32() % (__NFDBITS - 1), rfds); + FD_SET(rand32() % (__NFDBITS - 1), wfds); + FD_SET(rand32() % (__NFDBITS - 1), exfds); } rec->a2 = (unsigned long) rfds; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/syscalls/setsockopt.c new/trinity-20150905/syscalls/setsockopt.c --- old/trinity-20150804/syscalls/setsockopt.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/syscalls/setsockopt.c 2015-09-17 16:21:20.000000000 +0200 @@ -35,39 +35,38 @@ #include "compat.h" struct ip_sso_funcptr { - unsigned int proto; unsigned int sol; void (*func)(struct sockopt *so); }; static const struct ip_sso_funcptr ip_ssoptrs[] = { - { .proto = IPPROTO_IP, .sol = SOL_IP, .func = &ip_setsockopt }, - { .proto = IPPROTO_ICMP, .func = NULL }, - { .proto = IPPROTO_IGMP, .func = NULL }, - { .proto = IPPROTO_IPIP, .func = NULL }, - { .proto = IPPROTO_TCP, .sol = SOL_TCP, .func = &tcp_setsockopt }, - { .proto = IPPROTO_EGP, .func = NULL }, - { .proto = IPPROTO_PUP, .func = NULL }, - { .proto = IPPROTO_UDP, .sol = SOL_UDP, .func = &udp_setsockopt }, - { .proto = IPPROTO_IDP, .func = NULL }, - { .proto = IPPROTO_TP, .func = NULL }, - { .proto = IPPROTO_DCCP, .sol = SOL_DCCP, .func = &dccp_setsockopt }, + [IPPROTO_IP] = { .sol = SOL_IP, .func = &ip_setsockopt }, + [IPPROTO_ICMP] = { .func = NULL }, + [IPPROTO_IGMP] = { .func = NULL }, + [IPPROTO_IPIP] = { .func = NULL }, + [IPPROTO_TCP] = { .sol = SOL_TCP, .func = &tcp_setsockopt }, + [IPPROTO_EGP] = { .func = NULL }, + [IPPROTO_PUP] = { .func = NULL }, + [IPPROTO_UDP] = { .sol = SOL_UDP, .func = &udp_setsockopt }, + [IPPROTO_IDP] = { .func = NULL }, + [IPPROTO_TP] = { .func = NULL }, + [IPPROTO_DCCP] = { .sol = SOL_DCCP, .func = &dccp_setsockopt }, #ifdef USE_IPV6 - { .proto = IPPROTO_IPV6, .sol = SOL_ICMPV6, .func = &icmpv6_setsockopt }, + [IPPROTO_IPV6] = { .sol = SOL_ICMPV6, .func = &icmpv6_setsockopt }, #endif - { .proto = IPPROTO_RSVP, .func = NULL }, - { .proto = IPPROTO_GRE, .func = NULL }, - { .proto = IPPROTO_ESP, .func = NULL }, - { .proto = IPPROTO_AH, .func = NULL }, - { .proto = IPPROTO_MTP, .func = NULL }, - { .proto = IPPROTO_BEETPH, .func = NULL }, - { .proto = IPPROTO_ENCAP, .func = NULL }, - { .proto = IPPROTO_PIM, .func = NULL }, - { .proto = IPPROTO_COMP, .func = NULL }, - { .proto = IPPROTO_SCTP, .sol = SOL_SCTP, .func = &sctp_setsockopt }, - { .proto = IPPROTO_UDPLITE, .sol = SOL_UDPLITE, .func = &udplite_setsockopt }, - { .proto = IPPROTO_RAW, .sol = SOL_RAW, .func = &raw_setsockopt }, - { .proto = IPPROTO_MPLS, .func = NULL }, + [IPPROTO_RSVP] = { .func = NULL }, + [IPPROTO_GRE] = { .func = NULL }, + [IPPROTO_ESP] = { .func = NULL }, + [IPPROTO_AH] = { .func = NULL }, + [IPPROTO_MTP] = { .func = NULL }, + [IPPROTO_BEETPH] = { .func = NULL }, + [IPPROTO_ENCAP] = { .func = NULL }, + [IPPROTO_PIM] = { .func = NULL }, + [IPPROTO_COMP] = { .func = NULL }, + [IPPROTO_SCTP] = { .sol = SOL_SCTP, .func = &sctp_setsockopt }, + [IPPROTO_UDPLITE] = { .sol = SOL_UDPLITE, .func = &udplite_setsockopt }, + [IPPROTO_RAW] = { .sol = SOL_RAW, .func = &raw_setsockopt }, + [IPPROTO_MPLS] = { .func = NULL }, }; struct sso_funcptr { @@ -207,19 +206,15 @@ static void call_inet_sso_ptr(struct sockopt *so, struct socket_triplet *triplet) { - unsigned int i; + int proto = triplet->protocol; - for (i = 0; i < ARRAY_SIZE(ip_ssoptrs); i++) { - if (ip_ssoptrs[i].proto == triplet->protocol) { - if (ip_ssoptrs[i].func != NULL) { - so->level = ip_ssoptrs[i].sol; - ip_ssoptrs[i].func(so); - return; - } else { // unimplemented yet, or no sso for this proto. - do_random_sso(so); - return; - } - } + if (ip_ssoptrs[proto].func != NULL) { + so->level = ip_ssoptrs[proto].sol; + ip_ssoptrs[proto].func(so); + return; + } else { // unimplemented yet, or no sso for this proto. + do_random_sso(so); + return; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/syscalls/socket.c new/trinity-20150905/syscalls/socket.c --- old/trinity-20150804/syscalls/socket.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/syscalls/socket.c 2015-09-17 16:21:20.000000000 +0200 @@ -19,56 +19,56 @@ #include "compat.h" struct socket_ptr { - unsigned int family; void (*func)(struct socket_triplet *st); }; + static const struct socket_ptr socketptrs[] = { - { .family = AF_UNIX, .func = &unix_rand_socket }, - { .family = AF_INET, .func = &inet_rand_socket }, - { .family = AF_AX25, .func = &ax25_rand_socket }, - { .family = AF_IPX, .func = &ipx_rand_socket }, + [AF_UNIX] = { .func = &unix_rand_socket }, + [AF_INET] = { .func = &inet_rand_socket }, + [AF_AX25] = { .func = &ax25_rand_socket }, + [AF_IPX] = { .func = &ipx_rand_socket }, #ifdef USE_APPLETALK - { .family = AF_APPLETALK, .func = &atalk_rand_socket }, + [AF_APPLETALK] = { .func = &atalk_rand_socket }, #endif -//TODO { .family = AF_NETROM, .func = &netrom_rand_socket }, -//TODO { .family = AF_BRIDGE, .func = &bridge_rand_socket }, -//TODO { .family = AF_ATMPVC, .func = &atmpvc_rand_socket }, - { .family = AF_X25, .func = &x25_rand_socket }, + [AF_NETROM] = { .func = NULL }, + [AF_BRIDGE] = { .func = NULL }, + [AF_ATMPVC] = { .func = NULL }, + [AF_X25] = { .func = &x25_rand_socket }, #ifdef USE_IPV6 - { .family = AF_INET6, .func = &inet6_rand_socket }, + [AF_INET6] = { .func = &inet6_rand_socket }, #endif -//TODO { .family = AF_ROSE, .func = &rose_rand_socket }, - { .family = AF_DECnet, .func = &decnet_rand_socket }, -//TODO { .family = AF_NETBEUI, .func = &netbeui_rand_socket }, -//TODO { .family = AF_SECURITY, .func = &security_rand_socket }, -//TODO { .family = AF_KEY, .func = &key_rand_socket }, - { .family = AF_NETLINK, .func = &netlink_rand_socket }, - { .family = AF_PACKET, .func = &packet_rand_socket }, -//TODO { .family = AF_ASH, .func = &ash_rand_socket }, -//DEAD { .family = AF_ECONET, .func = &econet_rand_socket }, -//TODO { .family = AF_ATMSVC, .func = &atmsvc_rand_socket }, - { .family = AF_RDS, .func = &rds_rand_socket }, -//TODO { .family = AF_SNA, .func = &sna_rand_socket }, - { .family = AF_IRDA, .func = &irda_rand_socket }, -//TODO { .family = AF_PPPOX, .func = &pppox_rand_socket }, -//TODO { .family = AF_WANPIPE, .func = &wanpipe_rand_socket }, - { .family = AF_LLC, .func = &llc_rand_socket }, -//TODO { .family = AF_IB, .func = &ib_rand_socket }, -//TODO { .family = AF_MPLS, .func = &mpls_rand_socket }, - { .family = AF_CAN, .func = &can_rand_socket }, - { .family = AF_TIPC, .func = &tipc_rand_socket }, -//TODO { .family = AF_BLUETOOTH, .func = &bluetooth_rand_socket }, -//TODO { .family = AF_IUCV, .func = &iucv_rand_socket }, -//TODO { .family = AF_RXRPC, .func = &rxrpc_rand_socket }, -//TODO { .family = AF_ISDN, .func = &isdn_rand_socket }, -//TODO { .family = AF_PHONET, .func = &phonet_rand_socket }, -//TODO { .family = AF_IEEE802154, .func = &ieee802154_rand_socket }, + [AF_ROSE] = { .func = NULL }, + [AF_DECnet] = { .func = &decnet_rand_socket }, + [AF_NETBEUI] = { .func = NULL }, + [AF_SECURITY] = { .func = NULL }, + [AF_KEY] = { .func = NULL }, + [AF_NETLINK] = { .func = &netlink_rand_socket }, + [AF_PACKET] = { .func = &packet_rand_socket }, + [AF_ASH] = { .func = NULL }, + [AF_ECONET] = { .func = NULL }, // DEAD + [AF_ATMSVC] = { .func = NULL }, + [AF_RDS] = { .func = &rds_rand_socket }, + [AF_SNA] = { .func = NULL }, + [AF_IRDA] = { .func = &irda_rand_socket }, + [AF_PPPOX] = { .func = NULL }, + [AF_WANPIPE] = { .func = NULL }, + [AF_LLC] = { .func = &llc_rand_socket }, + [AF_IB] = { .func = NULL }, + [AF_MPLS] = { .func = NULL }, + [AF_CAN] = { .func = &can_rand_socket }, + [AF_TIPC] = { .func = &tipc_rand_socket }, + [AF_BLUETOOTH] = { .func = NULL }, + [AF_IUCV] = { .func = NULL }, + [AF_RXRPC] = { .func = NULL }, + [AF_ISDN] = { .func = NULL }, + [AF_PHONET] = { .func = NULL }, + [AF_IEEE802154] = { .func = NULL }, #ifdef USE_CAIF - { .family = AF_CAIF, .func = &caif_rand_socket }, + [AF_CAIF] = { .func = &caif_rand_socket }, #endif -//TODO { .family = AF_ALG, .func = &alg_rand_socket }, - { .family = AF_NFC, .func = &nfc_rand_socket }, -//TODO { .family = AF_VSOCK, .func = &vsock_rand_socket }, + [AF_ALG] = { .func = NULL }, + [AF_NFC] = { .func = &nfc_rand_socket }, + [AF_VSOCK] = { .func = NULL }, }; void rand_proto_type(struct socket_triplet *st) @@ -106,11 +106,12 @@ int sanitise_socket_triplet(struct socket_triplet *st) { unsigned int i; - for (i = 0; i < ARRAY_SIZE(socketptrs); i++) { - if (socketptrs[i].family == st->family) { - socketptrs[i].func(st); - return 0; - } + + i = st->family; + + if (socketptrs[i].func != NULL) { + socketptrs[i].func(st); + return 0; } /* Couldn't find func, fall back to random. */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/syscalls/syscalls.h new/trinity-20150905/syscalls/syscalls.h --- old/trinity-20150804/syscalls/syscalls.h 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/syscalls/syscalls.h 2015-09-17 16:21:20.000000000 +0200 @@ -376,5 +376,6 @@ extern struct syscallentry syscall_kexec_file_load; extern struct syscallentry syscall_bpf; extern struct syscallentry syscall_execveat; +extern struct syscallentry syscall_userfaultfd; unsigned int random_fcntl_setfl_flags(void); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/syscalls/userfaultfd.c new/trinity-20150905/syscalls/userfaultfd.c --- old/trinity-20150804/syscalls/userfaultfd.c 1970-01-01 01:00:00.000000000 +0100 +++ new/trinity-20150905/syscalls/userfaultfd.c 2015-09-17 16:21:20.000000000 +0200 @@ -0,0 +1,19 @@ +/* + * SYSCALL_DEFINE1(userfaultfd, int, flags) + */ + +#include <fcntl.h> +#include "sanitise.h" + +struct syscallentry syscall_userfaultfd = { + .name = "userfaultfd", + .num_args = 1, + .arg1name = "flags", + .arg1type = ARG_LIST, + .arg1list = { + .num = 2, + .values = { O_CLOEXEC, O_NONBLOCK, }, + }, + .flags = NEED_ALARM, + .rettype = RET_FD, +}; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/trinity.c new/trinity-20150905/trinity.c --- old/trinity-20150804/trinity.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/trinity.c 2015-09-17 16:21:20.000000000 +0200 @@ -28,6 +28,7 @@ unsigned int page_size; unsigned int num_online_cpus; +bool no_bind_to_cpu; unsigned int max_children; /* @@ -106,6 +107,9 @@ num_online_cpus = sysconf(_SC_NPROCESSORS_ONLN); max_children = num_online_cpus; /* possibly overridden in params. */ + if (init_random() == FALSE) + exit(EXIT_FAILURE); + set_seed(0); select_syscall_tables(); @@ -175,6 +179,8 @@ setup_main_signals(); + no_bind_to_cpu = RAND_BOOL(); + output(0, "Main thread is alive.\n"); prctl(PR_SET_NAME, (unsigned long) &taskname); set_seed(0); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-20150804/watchdog.c new/trinity-20150905/watchdog.c --- old/trinity-20150804/watchdog.c 2015-08-19 16:40:29.000000000 +0200 +++ new/trinity-20150905/watchdog.c 2015-09-17 16:21:20.000000000 +0200 @@ -378,6 +378,11 @@ while (shm->ready == FALSE) { unsigned int counter = 0; + if (shm->mainpid != 0) { + if (check_main_alive() == FALSE) + return; + } + while (shm->mainpid == 0) { if (check_main_alive() == FALSE) @@ -391,7 +396,7 @@ if (shm->exit_reason != STILL_RUNNING) return; - usleep(1); + sleep(1); } }
participants (1)
-
root@hilbert.suse.de