Hello community, here is the log from the commit of package trinity for openSUSE:Factory checked in at 2016-09-16 11:02:48 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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 2016-08-28 12:18:17.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.trinity.new/trinity.changes 2016-09-16 11:03:17.000000000 +0200 @@ -1,0 +2,7 @@ +Thu Sep 15 12:47:10 UTC 2016 - sle...@suse.de + +- Updated to 1.6+git.20160913 + * Removed Provides: 20160315 + * Removed Obsoletes: 20160315 + +------------------------------------------------------------------- Old: ---- trinity-1.6+git.20160826.tar.xz New: ---- trinity-1.6+git.20160913.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ trinity.spec ++++++ --- /var/tmp/diff_new_pack.00PBxC/_old 2016-09-16 11:03:19.000000000 +0200 +++ /var/tmp/diff_new_pack.00PBxC/_new 2016-09-16 11:03:19.000000000 +0200 @@ -16,9 +16,9 @@ # -%define version_unconverted 1.6+git.20160826 +%define version_unconverted 1.6+git.20160913 Name: trinity -Version: 1.6+git.20160826 +Version: 1.6+git.20160913 Release: 0 Summary: A Linux System call fuzz tester License: GPL-2.0 @@ -28,10 +28,6 @@ BuildRequires: gcc BuildRequires: make BuildRequires: xz -# older packages which use old versioning scheme need to be obsoleted, -# this can be removed in the future -Provides: %{name} = 20160315 -Obsoletes: %{name} = 20160315 BuildRoot: %{_tmppath}/%{name}-%{version}-build %if 0%{?suse_version} >= 1320 # needed for btrfs/ioctl.h ++++++ trinity-1.6+git.20160826.tar.xz -> trinity-1.6+git.20160913.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-1.6+git.20160826/include/params.h new/trinity-1.6+git.20160913/include/params.h --- old/trinity-1.6+git.20160826/include/params.h 2016-08-26 22:49:10.000000000 +0200 +++ new/trinity-1.6+git.20160913/include/params.h 2016-09-13 17:18:12.000000000 +0200 @@ -49,6 +49,7 @@ extern unsigned int random_selection_num; extern bool clowntown; +extern bool show_stats; extern unsigned int kernel_taint_mask; extern bool kernel_taint_param_occured; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-1.6+git.20160826/include/stats.h new/trinity-1.6+git.20160913/include/stats.h --- old/trinity-1.6+git.20160826/include/stats.h 2016-08-26 22:49:10.000000000 +0200 +++ new/trinity-1.6+git.20160913/include/stats.h 2016-09-13 17:18:12.000000000 +0200 @@ -10,3 +10,5 @@ /* Counts to tell if we're making progress or not. */ unsigned long previous_op_count; /* combined total of all children */ }; + +void dump_stats(void); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-1.6+git.20160826/include/syscall.h new/trinity-1.6+git.20160913/include/syscall.h --- old/trinity-1.6+git.20160826/include/syscall.h 2016-08-26 22:49:10.000000000 +0200 +++ new/trinity-1.6+git.20160913/include/syscall.h 2016-09-13 17:18:12.000000000 +0200 @@ -70,6 +70,8 @@ .values = vals, \ } +#define NR_ERRNOS 133 // Number in /usr/include/asm-generic/errno.h + struct results { union { // ARG_FD. -1 = Avoid. 0 = untested. 1 = Works. @@ -112,6 +114,9 @@ struct results results5; struct results results6; + unsigned int successes, failures, attempted; + unsigned int errnos[NR_ERRNOS]; + /* FIXME: At some point, if we grow more type specific parts here, * it may be worth union-ising this */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-1.6+git.20160826/include/tables.h new/trinity-1.6+git.20160913/include/tables.h --- old/trinity-1.6+git.20160826/include/tables.h 2016-08-26 22:49:10.000000000 +0200 +++ new/trinity-1.6+git.20160913/include/tables.h 2016-09-13 17:18:12.000000000 +0200 @@ -58,7 +58,6 @@ void sanity_check_tables(void); const char * print_syscall_name(unsigned int callno, bool is32bit); -void enable_random_syscalls(void); void enable_random_syscalls_biarch(void); void enable_random_syscalls_uniarch(void); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-1.6+git.20160826/main.c new/trinity-1.6+git.20160913/main.c --- old/trinity-1.6+git.20160826/main.c 2016-08-26 22:49:10.000000000 +0200 +++ new/trinity-1.6+git.20160913/main.c 2016-09-13 17:18:12.000000000 +0200 @@ -351,7 +351,7 @@ if (trylock(&rec->lock) == FALSE) return TRUE; - if (rec->state <= BEFORE) { + if (rec->state < BEFORE) { unlock(&rec->lock); return TRUE; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-1.6+git.20160826/mm/maps-initial.c new/trinity-1.6+git.20160913/mm/maps-initial.c --- old/trinity-1.6+git.20160826/mm/maps-initial.c 2016-08-26 22:49:10.000000000 +0200 +++ new/trinity-1.6+git.20160913/mm/maps-initial.c 2016-09-13 17:18:12.000000000 +0200 @@ -93,12 +93,14 @@ mapping_sizes[3] = page_size; goto out_free; } - } else { - // Because of increased mem usage, don't do nr_cpus * 4 - max_children /= 4; } } + // Because of increased mem usage, don't do nr_cpus * 4 + printf("Limiting children from %u to %u\n", + max_children, max_children / 4); + max_children /= 4; + out_free: free(buffer); out_close: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-1.6+git.20160826/net/proto-ipv4.c new/trinity-1.6+git.20160913/net/proto-ipv4.c --- old/trinity-1.6+git.20160826/net/proto-ipv4.c 2016-08-26 22:49:10.000000000 +0200 +++ new/trinity-1.6+git.20160913/net/proto-ipv4.c 2016-09-13 17:18:12.000000000 +0200 @@ -56,10 +56,19 @@ { "224.0.0.0", SLASH24 }, /* multi-cast */ { "255.255.255.255", SLASH32 }, }; + const char localhost[] = "127.0.0.1"; - int entry = rnd() % ARRAY_SIZE(addresses); - const char *p = addresses[entry].name; + int entry; + const char *p; + /* 99% of the time, just do localhost. */ + if (!ONE_IN(100)) { + inet_pton(AF_INET, localhost, &v4); + return v4; + } + + entry = rnd() % ARRAY_SIZE(addresses); + p = addresses[entry].name; inet_pton(AF_INET, p, &v4); if (addresses[entry].classmask != SLASH32) @@ -77,11 +86,7 @@ return previous_ip; } - /* 90% of the time, just do localhost. */ - if (!(ONE_IN(10))) - addr = 0x7f000001; - else - addr = new_ipv4_addr(); + addr = new_ipv4_addr(); previous_ip = addr; ip_lifetime = 5; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-1.6+git.20160826/params.c new/trinity-1.6+git.20160913/params.c --- old/trinity-1.6+git.20160826/params.c 2016-08-26 22:49:10.000000000 +0200 +++ new/trinity-1.6+git.20160913/params.c 2016-09-13 17:18:12.000000000 +0200 @@ -45,6 +45,7 @@ unsigned int random_selection_num; bool clowntown = FALSE; +bool show_stats = FALSE; bool user_set_seed = FALSE; @@ -84,6 +85,7 @@ outputerr(" --no_domain,-E: specify network domains to be excluded from testing.\n"); outputerr(" --quiet,-q: less output.\n"); outputerr(" --random,-r#: pick N syscalls at random and just fuzz those\n"); + outputerr(" --stats: show errno distribution per syscall before exiting\n"); outputerr(" --syslog,-S: log important info to syslog. (useful if syslog is remote)\n"); outputerr(" --verbose,-v: increase output verbosity.\n"); outputerr(" --victims,-V: path to victim files.\n"); @@ -119,6 +121,7 @@ { "domain", required_argument, NULL, 'P' }, { "quiet", no_argument, NULL, 'q' }, { "random", required_argument, NULL, 'r' }, + { "stats", no_argument, NULL, 0 }, { "show-unannotated", no_argument, NULL, 0 }, { "syslog", no_argument, NULL, 'S' }, { "verbose", no_argument, NULL, 'v' }, @@ -310,6 +313,9 @@ if (strcmp("show-unannotated", longopts[opt_index].name) == 0) show_unannotated = TRUE; + if (strcmp("stats", longopts[opt_index].name) == 0) + show_stats = TRUE; + break; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-1.6+git.20160826/stats.c new/trinity-1.6+git.20160913/stats.c --- old/trinity-1.6+git.20160826/stats.c 1970-01-01 01:00:00.000000000 +0100 +++ new/trinity-1.6+git.20160913/stats.c 2016-09-13 17:18:12.000000000 +0200 @@ -0,0 +1,46 @@ +#include <errno.h> +#include "log.h" +#include "stats.h" +#include "syscall.h" +#include "tables.h" + +static void dump_entry(const struct syscalltable *table, unsigned int i) +{ + struct syscallentry *entry; + unsigned int j; + + entry = table[i].entry; + if (entry == NULL) + return; + + if (entry->attempted == 0) + return; + + printf("%s: (attempted:%u. success:%u. failures:%u.\n", entry->name, entry->attempted, entry->successes, entry->failures); + + for (j = 0; j < NR_ERRNOS; j++) { + if (entry->errnos[j] != 0) { + printf(" %s: %d\n", strerror(j), entry->errnos[j]); + } + } +} + +void dump_stats(void) +{ + unsigned int i; + + if (biarch == TRUE) { + printf("32bit:\n"); + for_each_32bit_syscall(i) { + dump_entry(syscalls_32bit, i); + } + printf("64bit:\n"); + for_each_64bit_syscall(i) { + dump_entry(syscalls_64bit, i); + } + } else { + for_each_syscall(i) { + dump_entry(syscalls, i); + } + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-1.6+git.20160826/syscall.c new/trinity-1.6+git.20160913/syscall.c --- old/trinity-1.6+git.20160826/syscall.c 2016-08-26 22:49:10.000000000 +0200 +++ new/trinity-1.6+git.20160913/syscall.c 2016-09-13 17:18:12.000000000 +0200 @@ -83,12 +83,14 @@ #define syscall32(a,b,c,d,e,f,g) 0 #endif /* ARCH_IS_BIARCH */ -static void __do_syscall(struct syscallrecord *rec) +static void __do_syscall(struct syscallrecord *rec, enum syscallstate state) { unsigned long ret = 0; errno = 0; + shm->stats.op_count++; + if (dry_run == FALSE) { int nr, call; bool needalarm; @@ -102,6 +104,10 @@ if (needalarm) (void)alarm(1); + lock(&rec->lock); + rec->state = state; + unlock(&rec->lock); + if (rec->do32bit == FALSE) { ret = syscall(call, rec->a1, rec->a2, rec->a3, rec->a4, rec->a5, rec->a6); } else { @@ -111,24 +117,16 @@ (void)alarm(0); } - /* We returned! */ - shm->stats.op_count++; - lock(&rec->lock); rec->errno_post = errno; rec->retval = ret; rec->state = AFTER; unlock(&rec->lock); - - if (IS_ERR(ret)) - shm->stats.failures++; - else - shm->stats.successes++; } /* This is a special case for things like execve, which would replace our * child process with something unknown to us. We use a 'throwaway' process - * to do the execve in, and let it run for a max of a seconds before we kill it + * to do the execve in, and let it run for a max of a second before we kill it */ static void do_extrafork(struct syscallrecord *rec) { @@ -141,11 +139,9 @@ char childname[]="trinity-subchild"; prctl(PR_SET_NAME, (unsigned long) &childname); - rec->state = GOING_AWAY; - __do_syscall(rec); + __do_syscall(rec, GOING_AWAY); /* if this was for eg. an successful execve, we should never get here. * if it failed though... */ - shm->stats.failures++; _exit(EXIT_SUCCESS); } @@ -155,15 +151,18 @@ return; } - /* child */ + /* small pause to let grandchild do some work. */ + if (pid_alive(extrapid) == TRUE) + usleep(100); + while (pid == 0) { int childstatus; pid = waitpid(extrapid, &childstatus, WUNTRACED | WCONTINUED | WNOHANG); if (pid_alive(extrapid) == TRUE) kill(extrapid, SIGKILL); + usleep(1000); } - shm->stats.successes++; } @@ -175,13 +174,11 @@ call = rec->nr; entry = syscalls[call].entry; - rec->state = BEFORE; - if (entry->flags & EXTRA_FORK) do_extrafork(rec); else /* common-case, do the syscall in this child process. */ - __do_syscall(rec); + __do_syscall(rec, BEFORE); } /* @@ -228,14 +225,27 @@ entry = syscalls[call].entry; if (rec->retval == -1UL) { + int err = rec->errno_post; + /* only check syscalls that completed. */ if (rec->state == AFTER) { - if (rec->errno_post == ENOSYS) + if (err == ENOSYS) deactivate_enosys(rec, entry, call); + + entry->failures++; + if (err < NR_ERRNOS) { + entry->errnos[err]++; + } else { + printf("errno out of range: %d:%s\n", err, strerror(err)); + } + shm->stats.failures++; } } else { handle_success(rec); // Believe me folks, you'll never get bored with winning + entry->successes++; + shm->stats.successes++; } + entry->attempted++; generic_post(entry->arg1type, rec->a1); generic_post(entry->arg2type, rec->a2); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-1.6+git.20160826/tables.c new/trinity-1.6+git.20160913/tables.c --- old/trinity-1.6+git.20160826/tables.c 2016-08-26 22:49:10.000000000 +0200 +++ new/trinity-1.6+git.20160913/tables.c 2016-09-13 17:18:12.000000000 +0200 @@ -561,7 +561,7 @@ display_enabled_syscalls_uniarch(); } -void enable_random_syscalls(void) +static void enable_random_syscalls(void) { unsigned int i; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/trinity-1.6+git.20160826/trinity.c new/trinity-1.6+git.20160913/trinity.c --- old/trinity-1.6+git.20160826/trinity.c 2016-08-26 22:49:10.000000000 +0200 +++ new/trinity-1.6+git.20160913/trinity.c 2016-09-13 17:18:12.000000000 +0200 @@ -20,6 +20,7 @@ #include "shm.h" #include "sysv-shm.h" #include "futex.h" +#include "stats.h" #include "tables.h" #include "taint.h" #include "trinity.h" @@ -189,6 +190,8 @@ output(0, "Ran %ld syscalls. Successes: %ld Failures: %ld\n", shm->stats.op_count - 1, shm->stats.successes, shm->stats.failures); + if (show_stats == TRUE) + dump_stats(); shutdown_logging();