From 1f6cb79459e181448d6e4e37381b57325b6d0fdb Mon Sep 17 00:00:00 2001 From: David Smith Date: Mon, 8 Feb 2010 15:59:29 -0600 Subject: Fixed BZ559643 by doing 'spawn;expect;wait' instead of 'spawn;wait;expect'. * testsuite/systemtap.base/labels.exp: Corrected order of 'spawn;expect;wait' calls. Added 'wait' calls when needed. Also, doesn't run the "labels exe .label" test if uprobes isn't supported. --- testsuite/systemtap.base/labels.exp | 43 ++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/testsuite/systemtap.base/labels.exp b/testsuite/systemtap.base/labels.exp index f759beef..01c3afbd 100644 --- a/testsuite/systemtap.base/labels.exp +++ b/testsuite/systemtap.base/labels.exp @@ -60,13 +60,13 @@ if { $res != "" } { set ok 0 spawn stap -l "process(\"$label_exepath\").function(\"foo@${label_srcpath}:10\").label(\"*\")" -wait expect { -timeout 180 -re {no match while resolving probe point} { incr ok; exp_continue } timeout { fail "$test (timeout)" } eof { } } +wait if {$ok == 1} { pass "$test :N .label" } { fail "$test :N .label $ok" } @@ -75,13 +75,13 @@ if {$ok == 1} { pass "$test :N .label" } { fail "$test :N .label $ok" } set ok 0 spawn stap -l "process(\"$label_exepath\").function(\"foo@${label_srcpath}:4\").label(\"*\")" -wait expect { -timeout 180 -re {process.*function.*labels.c:5...label..init_an_int} { incr ok; exp_continue } timeout { fail "$test (timeout)" } eof { } } +wait if {$ok == 1} { pass "$test :N .label" } { fail "$test :N .label $ok" } @@ -89,7 +89,6 @@ if {$ok == 1} { pass "$test :N .label" } { fail "$test :N .label $ok" } spawn stap -l "process(\"$label_exepath\").function(\"*\").label(\"*\")" -wait set ok 0 expect { -timeout 180 @@ -104,25 +103,28 @@ expect { timeout { fail "$test (timeout)" } eof { } } +wait if {$ok == 4} { pass "$test -l .label" } { fail "$test -l .label $ok" } -# label in an executable - -set ok 0 -verbose -log "spawn stap -c $label_exepath $label_stppath" -spawn stap -c $label_exepath $label_stppath - -wait -expect { - -timeout 180 - -re {VARS a=0x0 b=0x0.*init_an_int.*VARS a=0x2 b=0x0.*VARS a=0x2 b=0x3 c=0x[a-f01-9]} { incr ok; exp_continue } - timeout { fail "$test (timeout)" } - eof { } +# label in an executable (only if we have uprobes) +if {[uprobes_p]} { + set ok 0 + verbose -log "spawn stap -c $label_exepath $label_stppath" + spawn stap -c $label_exepath $label_stppath + + expect { + -timeout 180 + -re {VARS a=0x0 b=0x0.*init_an_int.*VARS a=0x2 b=0x0.*VARS a=0x2 b=0x3 c=0x[a-f01-9]} { incr ok; exp_continue } + timeout { fail "$test (timeout)" } + eof { } + } + wait + if {$ok == 1} { pass "$test exe .label" } { fail "$test exe .label $ok" } +} else { + untested "$test exe .label" } -if {$ok == 1} { pass "$test exe .label" } { fail "$test exe .label $ok" } - # address of label in an executable set label_shpath "[pwd]/label.sh" @@ -138,6 +140,8 @@ spawn sh $label_shpath expect { -re {0x[0-9a-f]*} } +wait + set nomatch 0 spawn stap -p2 -l "process\(\"$label_exepath\"\).statement($expect_out(0,string))" expect { @@ -146,6 +150,7 @@ expect { timeout { fail "$test (timeout)" } eof { } } +wait if {$nomatch == 0} { pass "$test exe .statement" } { fail "$test exe .statement" } @@ -171,6 +176,7 @@ expect { timeout { fail "$test (timeout)" } eof { } } +wait if {$ok == 1} { pass "$test so .label" } { fail "$test so .label $ok" } @@ -189,6 +195,8 @@ spawn sh $label_shpath expect { -re {0x[0-9a-f]*} } +wait + set nomatch 0 spawn stap -p2 -l "process\(\"$label_sopath\"\).statement($expect_out(0,string))" expect { @@ -197,6 +205,7 @@ expect { timeout { fail "$test (timeout)" } eof { } } +wait if {$nomatch == 0} { pass "$test so .statement" } { fail "$test so .statement" } -- cgit From 82d819db2debd4831a11139fe81781f2c4566ef8 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 9 Feb 2010 12:22:37 +0100 Subject: rhbz#563114 Make syscall.pipe sys32_pipe probe alias optional on x86_64. Some distributions might have backported the pipe fd leak patch and removed the sys32_pipe kernel function even before 2.6.32. So make the probe alias optional instead of relying on a version check. * tapset/x86_64/syscalls.stp (syscall.pipe): Make alias optional. (syscall.pipe.return): Likewise. --- tapset/x86_64/syscalls.stp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tapset/x86_64/syscalls.stp b/tapset/x86_64/syscalls.stp index 79a5181e..5ad064a2 100644 --- a/tapset/x86_64/syscalls.stp +++ b/tapset/x86_64/syscalls.stp @@ -145,16 +145,14 @@ probe syscall.vm86_warning.return = kernel.function("sys32_vm86_warning").return # pipe _______________________________________________________ # # long sys32_pipe(int __user *fd) -# -%(kernel_v < "2.6.32" %? -probe syscall.pipe32 = kernel.function("sys32_pipe") +# Not available in newer kernels. +probe syscall.pipe32 = kernel.function("sys32_pipe")? { name = "pipe" argstr = sprintf("%p", $fd) } -probe syscall.pipe32.return = kernel.function("sys32_pipe").return +probe syscall.pipe32.return = kernel.function("sys32_pipe").return? { name = "pipe" retstr = returnstr(1) } -%) -- cgit From 685814768d61e47d491a81271f04de8b421acc4d Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Tue, 9 Feb 2010 16:23:18 -0500 Subject: Fix tcl.exp initialization bug tcl.exp: Initialize xok --- testsuite/systemtap.apps/tcl.exp | 1 + 1 file changed, 1 insertion(+) diff --git a/testsuite/systemtap.apps/tcl.exp b/testsuite/systemtap.apps/tcl.exp index 4c4a4342..07409ccd 100644 --- a/testsuite/systemtap.apps/tcl.exp +++ b/testsuite/systemtap.apps/tcl.exp @@ -47,6 +47,7 @@ if {![installtest_p]} { set ok 0 set ko 0 +set xok 0 set lines 0 verbose -log "spawn stap -DMAXSKIPPED=8024 -t -c \"tcl/install/bin/tclsh${tclreleasemajor} tcl/src/tests/all.tcl > tcl-test.out\" $srcdir/$subdir/stap-tcl.stp tcl/install/bin/tclsh${tclreleasemajor} tcl/install/lib/libtcl${tclreleasemajor}.so" spawn stap -DMAXSKIPPED=8024 -t -c "tcl/install/bin/tclsh${tclreleasemajor} tcl/src/tests/all.tcl > tcl-test.out" $srcdir/$subdir/stap-tcl.stp tcl/install/bin/tclsh${tclreleasemajor} tcl/install/lib/libtcl${tclreleasemajor}.so -- cgit From 42048078ab7712361ce54fa9face358f75e1d699 Mon Sep 17 00:00:00 2001 From: David Smith Date: Wed, 10 Feb 2010 16:35:46 -0600 Subject: Fixed PR 11270 by adding nd_syscall testcase. * testsuite/systemtap.syscall/test.tcl: Now uses global variable 'test_script' to find test script to run. * testsuite/systemtap.syscall/syscall.exp: Sets test_script. * testsuite/systemtap.syscall/nd_sys.stp: New test script. Copy of sys.stp, but uses nd_syscall probes. * testsuite/systemtap.syscall/nd_syscall.exp: New testcase. Copy of syscall.exp, but uses nd_sys.stp test script. --- testsuite/systemtap.syscall/nd_sys.stp | 37 +++++++++++++++++++ testsuite/systemtap.syscall/nd_syscall.exp | 59 ++++++++++++++++++++++++++++++ testsuite/systemtap.syscall/syscall.exp | 1 + testsuite/systemtap.syscall/test.tcl | 4 +- 4 files changed, 99 insertions(+), 2 deletions(-) create mode 100755 testsuite/systemtap.syscall/nd_sys.stp create mode 100644 testsuite/systemtap.syscall/nd_syscall.exp diff --git a/testsuite/systemtap.syscall/nd_sys.stp b/testsuite/systemtap.syscall/nd_sys.stp new file mode 100755 index 00000000..5936cb77 --- /dev/null +++ b/testsuite/systemtap.syscall/nd_sys.stp @@ -0,0 +1,37 @@ +global indent, indent_str, entry_p + +probe begin { + indent = 0 + for (i=0; i<20; i++) { + if (i == 0) + indent_str[0] = "" + else + indent_str[i] = indent_str[i-1] . " " + } +} + + +probe nd_syscall.* ? { + if (pid() == target()) { + if (entry_p) printf("\n") + printf("%s%s: %s (%s) = ", indent_str[indent], execname(), name, argstr) +# printf("%s%s: %s (%s) = ", indent_str[indent], execname(), probefunc(), argstr) + indent++ + entry_p = 1 + } +} + +probe nd_syscall.*.return ? { + if (pid() == target()) { + if (indent) indent-- + if (entry_p) + printf("%s\n", retstr) + else + printf("%s%s\n", indent_str[indent],retstr) + entry_p = 0 + } +} + +probe end { + printf("\n") +} diff --git a/testsuite/systemtap.syscall/nd_syscall.exp b/testsuite/systemtap.syscall/nd_syscall.exp new file mode 100644 index 00000000..4aefcf4b --- /dev/null +++ b/testsuite/systemtap.syscall/nd_syscall.exp @@ -0,0 +1,59 @@ +set test_script "nd_sys.stp" +source $srcdir/$subdir/test.tcl + +proc test_procedure {} { + global srcdir subdir + set wd [pwd] + set flags "" + if {$srcdir == ""} { + set pattern "*.c" + } else { + set pattern "$srcdir/$subdir/*.c" + } + + # for first pass, force 64-bit compilation for 64-bit systems + # Add any other 64-bit arcvhitecture you want tested below. + # To find tcl's platform name for your machine, run the following: + # echo "puts $::tcl_platform(machine)" | tclsh + + switch -regexp $::tcl_platform(machine) { + ^ia64$ { + set do_64_bit_pass 1 + set flags "" + } + ^(x86_64|ppc64|s390x)$ { + set do_64_bit_pass 1 + set flags "additional_flags=-m64" + } + default { + set do_64_bit_pass 0 + } + } + + if {$do_64_bit_pass} { + foreach filename [lsort [glob $pattern]] { + set testname [file tail [string range $filename 0 end-2]] + if {![installtest_p]} { untested "64-bit $testname"; continue } + send_log "Testing 64-bit ${testname}\n" + run_one_test $filename $flags 64 + } + } + + set do_32_bit_pass 1 + switch -regexp $::tcl_platform(machine) { + {^(x86_64|ppc64)$} { set flags "additional_flags=-m32" } + {^s390x$} { set flags "additional_flags=-m31" } + {^ia64$} { set do_32_bit_pass 0 } + } + + if {$do_32_bit_pass} { + foreach filename [lsort [glob $pattern]] { + set testname [file tail [string range $filename 0 end-2]] + if {![installtest_p]} { untested "32-bit $testname"; continue } + send_log "Testing 32-bit ${testname}\n" + run_one_test $filename $flags 32 + } + } +} + +test_procedure diff --git a/testsuite/systemtap.syscall/syscall.exp b/testsuite/systemtap.syscall/syscall.exp index a4978997..3316c4a5 100644 --- a/testsuite/systemtap.syscall/syscall.exp +++ b/testsuite/systemtap.syscall/syscall.exp @@ -1,3 +1,4 @@ +set test_script "sys.stp" source $srcdir/$subdir/test.tcl proc test_procedure {} { diff --git a/testsuite/systemtap.syscall/test.tcl b/testsuite/systemtap.syscall/test.tcl index 9d620d74..477fae70 100755 --- a/testsuite/systemtap.syscall/test.tcl +++ b/testsuite/systemtap.syscall/test.tcl @@ -27,7 +27,7 @@ proc bgerror {error} { trap {cleanup_and_exit} SIGINT proc run_one_test {filename flags bits} { - global dir current_dir + global dir current_dir test_script set testname [file tail [string range $filename 0 end-2]] @@ -43,7 +43,7 @@ proc run_one_test {filename flags bits} { return } - set sys_prog "[file dirname [file normalize $filename]]/sys.stp" + set sys_prog "[file dirname [file normalize $filename]]/${test_script}" set cmd "stap --skip-badvars -c $dir/${testname} ${sys_prog}" # Extract additional C flags needed to compile -- cgit From 84b49730802c1cc625b85a2bfd473f6839d4e99c Mon Sep 17 00:00:00 2001 From: Przemysław Pawełczyk Date: Thu, 11 Feb 2010 15:10:39 -0500 Subject: Add simple test for PR10257 (sprint(@hist_linear)). Test is simple, because print and sprint uses the same code for handling @hist_* and it is not intended for playing with MAXSTRINGLEN, which is required anyway for bigger histograms (the one generated here consists of only 127 characters). When PR10690 (need way to produce bigger procfs output) will be fixed, then we should add another test for both PRs with normal histogram. --- testsuite/systemtap.maps/hist_in_string.exp | 8 ++++++++ testsuite/systemtap.maps/hist_in_string.stp | 10 ++++++++++ 2 files changed, 18 insertions(+) create mode 100644 testsuite/systemtap.maps/hist_in_string.exp create mode 100644 testsuite/systemtap.maps/hist_in_string.stp diff --git a/testsuite/systemtap.maps/hist_in_string.exp b/testsuite/systemtap.maps/hist_in_string.exp new file mode 100644 index 00000000..02f201af --- /dev/null +++ b/testsuite/systemtap.maps/hist_in_string.exp @@ -0,0 +1,8 @@ +# test histogram printed to string + +set test "hist_in_string" +set ::result_string {value |-------------------------------------------------- count + 0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 128 +} + +stap_run2 $srcdir/$subdir/$test.stp diff --git a/testsuite/systemtap.maps/hist_in_string.stp b/testsuite/systemtap.maps/hist_in_string.stp new file mode 100644 index 00000000..f9d0e81a --- /dev/null +++ b/testsuite/systemtap.maps/hist_in_string.stp @@ -0,0 +1,10 @@ +global l + +probe begin +{ + for (i = 0; i < 128; i++) + l <<< 0 + + print(sprint(@hist_linear(l, 0, 0, 1))) + exit() +} -- cgit From c0d1b5a004b9949bb455b7dbe17b335b7cab9ead Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 12 Feb 2010 10:25:43 -0500 Subject: PR11105 part 2: tighten constraints on stap-server parameters passed to make * util.h, util.cxx (assert_match_regexp): New function. * main.cxx (main): Constrain -R, -r, -a, -D, -S, -q, -B flags. * stap-serverd (listen): Harden stap-server-connect with ulimit/loop. * testsuite/systemtap.server/{client,server}_args.exp: Revised. --- main.cxx | 24 ++++++++-------- stap-serverd | 22 ++++++++++----- testsuite/systemtap.server/client_args.exp | 28 +++++++++---------- testsuite/systemtap.server/server_args.exp | 45 ++++++++++++++++-------------- util.cxx | 36 +++++++++++++++++++++++- util.h | 2 +- 6 files changed, 101 insertions(+), 56 deletions(-) diff --git a/main.cxx b/main.cxx index 8f5ee72e..2dba179f 100644 --- a/main.cxx +++ b/main.cxx @@ -57,7 +57,7 @@ version () << "SystemTap translator/driver " << "(version " << VERSION << "/" << dwfl_version (NULL) << " " << GIT_MESSAGE << ")" << endl - << "Copyright (C) 2005-2009 Red Hat, Inc. and others" << endl + << "Copyright (C) 2005-2010 Red Hat, Inc. and others" << endl << "This is free software; see the source for copying conditions." << endl; } @@ -708,12 +708,12 @@ main (int argc, char * const argv []) break; case 'o': + // NB: client_options not a problem, since pass 1-4 does not use output_file. s.output_file = string (optarg); break; case 'R': - if (client_options) - client_options_disallowed += client_options_disallowed.empty () ? "-R" : ", -R"; + if (client_options) { cerr << "ERROR: -R invalid with --client-options" << endl; usage(s,1); } s.runtime_path = string (optarg); break; @@ -722,6 +722,7 @@ main (int argc, char * const argv []) client_options_disallowed += client_options_disallowed.empty () ? "-m" : ", -m"; s.module_name = string (optarg); save_module = true; + // XXX: convert to assert_regexp_match() { string::size_type len = s.module_name.length(); @@ -766,15 +767,14 @@ main (int argc, char * const argv []) break; case 'r': - if (client_options) - client_options_disallowed += client_options_disallowed.empty () ? "-r" : ", -r"; + if (client_options) // NB: no paths! + assert_regexp_match("-r parameter from client", optarg, "^[a-z0-9_\\.-]+$"); setup_kernel_release(s, optarg); break; case 'a': - if (client_options) - client_options_disallowed += client_options_disallowed.empty () ? "-a" : ", -a"; - s.architecture = string(optarg); + assert_regexp_match("-a parameter", optarg, "^[a-z0-9_-]+$"); + s.architecture = string(optarg); break; case 'k': @@ -821,16 +821,19 @@ main (int argc, char * const argv []) break; case 'D': + assert_regexp_match ("-D parameter", optarg, "^[a-z_][a-z_0-9]*(=[a-z_0-9]+)?$"); if (client_options) client_options_disallowed += client_options_disallowed.empty () ? "-D" : ", -D"; s.macros.push_back (string (optarg)); break; case 'S': + assert_regexp_match ("-S parameter", optarg, "^[0-9]+(,[0-9]+)?$"); s.size_option = string (optarg); break; case 'q': + if (client_options) { cerr << "ERROR: -q invalid with --client-options" << endl; usage(s,1); } s.tapset_compile_coverage = true; break; @@ -861,9 +864,8 @@ main (int argc, char * const argv []) break; case 'B': - if (client_options) - client_options_disallowed += client_options_disallowed.empty () ? "-B" : ", -B"; - s.kbuildflags.push_back (string (optarg)); + if (client_options) { cerr << "ERROR: -B invalid with --client-options" << endl; usage(s,1); } + s.kbuildflags.push_back (string (optarg)); break; case 0: diff --git a/stap-serverd b/stap-serverd index eda9711e..5820286f 100755 --- a/stap-serverd +++ b/stap-serverd @@ -360,11 +360,19 @@ function advertise_presence { function listen { # The stap-server-connect program will listen forever # accepting requests. - ${stap_pkglibexecdir}stap-server-connect \ - -p $port -n $nss_cert -d $ssl_db -w $nss_pw \ - -s "$stap_options" \ - >> $logfile 2>&1 & - wait '%${stap_pkglibexecdir}stap-server-connect' >> $logfile 2>&1 + # CVE-2009-4273 ... or at least, until resource limits fire + while true; do # NB: loop to avoid DoS by deliberate rlimit-induced halt + # NB: impose resource limits in case of mischevious data inducing + # too much / long computation + (ulimit -f 50000 -s 1000 -t 60 -u 20 -v 500000; + exec ${stap_pkglibexecdir}stap-server-connect \ + -p $port -n $nss_cert -d $ssl_db -w $nss_pw \ + -s "$stap_options") & + stap_server_connect_pid=$! + wait + # NB: avoid superfast spinning in case of a ulimit or other failure + sleep 1 + done >> $logfile 2>&1 } # function: warning [ MESSAGE ] @@ -396,8 +404,8 @@ function terminate { wait '%avahi-publish-service' >> $logfile 2>&1 # Kill any running 'stap-server-connect' job. - kill -s SIGTERM '%${stap_pkglibexecdir}stap-server-connect' >> $logfile 2>&1 - wait '%${stap_pkglibexecdir}stap-server-connect' >> $logfile 2>&1 + kill -s SIGTERM $stap_server_connect_pid >> $logfile 2>&1 + wait $stap_server_connect_pid >> $logfile 2>&1 exit } diff --git a/testsuite/systemtap.server/client_args.exp b/testsuite/systemtap.server/client_args.exp index f41b91cb..694d546d 100644 --- a/testsuite/systemtap.server/client_args.exp +++ b/testsuite/systemtap.server/client_args.exp @@ -5,33 +5,34 @@ set test "Invalid Server Client Arguments" set test_file $srcdir/systemtap.server/test.stp # Test invalid combinations. -set error_regexp ".*You can't specify .* when --unprivileged is specified.*" +set error_regexp ".*(ERROR)|(You can't specify .* when --unprivileged is specified).*" set invalid_options [list \ - "--unprivileged --client-options -a i386" \ "--unprivileged --client-options -B X=Y" \ "--unprivileged --client-options -D X=Y" \ "--unprivileged --client-options -I /tmp" \ "--unprivileged --client-options -m test" \ "--unprivileged --client-options -R /tmp" \ - "--unprivileged --client-options -r [exec uname -r]" \ - "--unprivileged --client-options -a i386 -B X=Y -D X=Y -I /tmp -m test -R /tmp -r [exec uname -r]" \ - "--client-options --unprivileged -a i386" \ + "--unprivileged --client-options -B X=Y -D X=Y -I /tmp -m test -R /tmp -r [exec uname -r]" \ "--client-options --unprivileged -B X=Y" \ "--client-options --unprivileged -D X=Y" \ "--client-options --unprivileged -I /tmp" \ "--client-options --unprivileged -m test" \ "--client-options --unprivileged -R /tmp" \ - "--client-options --unprivileged -r [exec uname -r]" \ - "--client-options --unprivileged -a i386 -B X=Y -D X=Y -I /tmp -m test -R /tmp -r [exec uname -r]" \ - "--client-options -a i386 --unprivileged" \ + "--client-options --unprivileged -B X=Y -D X=Y -I /tmp -m test -R /tmp -r [exec uname -r]" \ "--client-options -B X=Y --unprivileged" \ "--client-options -D X=Y --unprivileged" \ "--client-options -I /tmp --unprivileged" \ "--client-options -m test --unprivileged" \ "--client-options -R /tmp --unprivileged" \ - "--client-options -r [exec uname -r] --unprivileged" \ - "--client-options -a i386 -B X=Y -D X=Y -I /tmp -m test -R /tmp -r [exec uname -r] --unprivileged" \ + "--client-options -B X=Y -D X=Y -I /tmp -m test -R /tmp -r [exec uname -r] --unprivileged" \ + "--client-options -R /path" \ + "-D \"foo;bar\"" \ + "-D 2=4" \ + "-D \"foo;bar\"" \ + "--client-options -r /path" \ + "-S /path" \ + "--client-options -q" \ ] foreach options $invalid_options { @@ -66,9 +67,8 @@ set valid_options [list \ "-D X=Y" \ "-I /tmp" \ "-m test" \ - "-R /tmp" \ "-r [exec uname -r]" \ - "-a i386 -B X=Y -D X=Y -I /tmp -m test -R /tmp -r [exec uname -r]" \ + "-a i386 -B X=Y -D X=Y -I /tmp -m test -r [exec uname -r]" \ "--unprivileged" \ "--unprivileged -a i386" \ "--unprivileged -B X=Y" \ @@ -80,13 +80,11 @@ set valid_options [list \ "--unprivileged -a i386 -B X=Y -D X=Y -I /tmp -m test -R /tmp -r [exec uname -r]" \ "--client-options" \ "--client-options -a i386" \ - "--client-options -B X=Y" \ "--client-options -D X=Y" \ "--client-options -I /tmp" \ "--client-options -m test" \ - "--client-options -R /tmp" \ "--client-options -r [exec uname -r]" \ - "--client-options -a i386 -B X=Y -D X=Y -I /tmp -m test -R /tmp -r [exec uname -r]" \ + "--client-options -a i386 -D X=Y -I /tmp -m test -r [exec uname -r]" \ "--unprivileged --client-options" \ "--client-options --unprivileged" \ "--unprivileged -a i386 --client-options" \ diff --git a/testsuite/systemtap.server/server_args.exp b/testsuite/systemtap.server/server_args.exp index eac9074c..81a2c37b 100644 --- a/testsuite/systemtap.server/server_args.exp +++ b/testsuite/systemtap.server/server_args.exp @@ -114,27 +114,27 @@ if {[installtest_p]} then { # for debugging a currently failing case and helps to ensure that previously # fixed cases do not regress. set previously_fixed [list \ - "-p1 -I=\\w94\nbh -R'-1vo*w- -e -B9 -Dhfuo0iu7 -c" \ - "-p1 -I8o\\2ie -Rtu\\\n -e'1\\ -B*3x8k\; -D\n\" -c" \ - "-p1 -Ira\\3;c g -Rlr\"6/3ho -e0fle'qq -B -Dr/316k\\o8 -cjyoc\n3" \ - "-p1 -I6p3 -Rk3g-t\n89 -elc -Bd -Dqgsgv' -c" \ - "-p1 -I\"vyv;z -Rzvchje2\\ -ej\"/3 -Be -D/ 01qck\n -c3u55zut" \ - "-p1 -I1 -R\n -eo9e\nx047q -B\"*dd;tn\\ -D9xyefk0a -cvl98/x1'i" \ + "-p1 -I=\\w94\nbh -e -Dhfuo0iu7 -c" \ + "-p1 -I8o\\2ie -e'1\\ -D\n\" -c" \ + "-p1 -Ira\\3;c g -e0fle'qq -Dr/316k\\o8 -cjyoc\n3" \ + "-p1 -I6p3 -elc -Dqgsgv' -c" \ + "-p1 -I\"vyv;z -ej\"/3 -D/ 01qck\n -c3u55zut" \ + "-p1 -I1 -eo9e\nx047q -D9xyefk0a -cvl98/x1'i" \ "-p1 -c; test.stp" \ - "-p1 -I4hgy96 -R -e5oo39p -Bile\\vp -Ddx8v -c4;" \ - "-p1 -I -Repwd9 -esq3wors -Btmk;\\t -Dz -c*eibz8h2e" \ - "-p1 -I -Ry a -em339db5 -B;ae41428d -Du2;c0ps -ch9o\\" \ - "-p1 -Ipfjps4 -Rx479 -ebug4dc -Bih;fe2 -Du8vd fvkl -c" \ - "-p1 -I0\"nspzjyf -R -e5r3up8h -Bgqnyjq6w -Dmi;ojp9m -cx;a2fat" \ - "-p1 -Iu -R9 -ek7;r -Big -Dcu\"; -c\"hc" \ - "-p1 -Icd4fidq -Rkj m40mv -edn -B7ria -D;8ha\\cjr -c1*vnq" \ - "-p1 -I;3 -R3lq;vp -er8e -Bgdqjqdy -D -cb6k29z" \ - "-p1 -Ircj -R -e -B -D -c\\vmww" \ - "-p1 -Illc5 -Rug*\\o -e65wof9 -B qr*=x7x5 -D -cgx;" \ - "-p1 -Iyaj420=3 -R -e\" -Bx68j -D -cd'5mi" \ - "-p1 -Ir -Rwd8;;sjl -e -Bxh; -D29\\ -cj2szt;4" \ - "-p1 -Ibno3=b4sk -R*5 -e' -Byl63flos -Dg2-j;e -c2ijx'" \ - "-p1 -I285v7pl -R9a -eo5\\0 -Bfs* -D86s -c-c*v" \ + "-p1 -I4hgy96 -e5oo39p -Ddx8v -c4;" \ + "-p1 -I -esq3wors -Dz -c*eibz8h2e" \ + "-p1 -I a -em339db5 -Du2;c0ps -ch9o\\" \ + "-p1 -Ipfjps4 -ebug4dc -Du8vd fvkl -c" \ + "-p1 -I0\"nspzjyf -e5r3up8h -Dmi;ojp9m -cx;a2fat" \ + "-p1 -Iu -ek7;r -Dcu\"; -c\"hc" \ + "-p1 -Icd4fidq m40mv -edn -D;8ha\\cjr -c1*vnq" \ + "-p1 -I;3 -er8e -D -cb6k29z" \ + "-p1 -Ircj -e -D -c\\vmww" \ + "-p1 -Illc5 -e65wof9 qr*=x7x5 -D -cgx;" \ + "-p1 -Iyaj420=3 -e\" -D -cd'5mi" \ + "-p1 -Ir -e -D29\\ -cj2szt;4" \ + "-p1 -Ibno3=b4sk -e' -Dg2-j;e -c2ijx'" \ + "-p1 -I285v7pl -eo5\\0 -D86s -c-c*v" \ ] set i 0 @@ -150,7 +150,10 @@ foreach options $previously_fixed { # Generate semi-random arguments containing with potential problem characters. # Check that running systemtap with the client/server generates output # comparable to running stap directly. -set dangerous_options [list "-I" "-R" "-e" "-B" "-D" "-c"] +set dangerous_options [list "-I" "-e" "-D" "-c" "-S"] +# NB: Other options could be candidates here, like -r and -B, but +# there stap-server imposes more restrictions than local stap, so +# this simple error-matching test cannot use them. set argchars "0123456789/;*'=-\\\"\n abcdefghijklmnopqrstuvwxyz" for {set i 0} {$i < $iterations} {incr i} { diff --git a/util.cxx b/util.cxx index 736e5a30..73ba167c 100644 --- a/util.cxx +++ b/util.cxx @@ -1,5 +1,5 @@ // Copyright (C) Andrew Tridgell 2002 (original file) -// Copyright (C) 2006, 2009 Red Hat Inc. (systemtap changes) +// Copyright (C) 2006-2010 Red Hat Inc. (systemtap changes) // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as @@ -19,6 +19,8 @@ #include "sys/sdt.h" #include #include +#include +#include extern "C" { #include @@ -31,6 +33,7 @@ extern "C" { #include #include #include +#include } using namespace std; @@ -413,4 +416,35 @@ kill_stap_spawn(int sig) return spawned_pid ? kill(spawned_pid, sig) : 0; } + +void assert_regexp_match (const string& name, const string& value, const string& re) +{ + typedef map cache; + static cache compiled; + cache::iterator it = compiled.find (re); + regex_t* r = 0; + if (it == compiled.end()) + { + r = new regex_t; + int rc = regcomp (r, re.c_str(), REG_ICASE|REG_NOSUB|REG_EXTENDED); + if (rc) { + cerr << "regcomp " << re << " (" << name << ") error rc=" << rc << endl; + exit(1); + } + compiled[re] = r; + } + else + r = it->second; + + // run regexec + int rc = regexec (r, value.c_str(), 0, 0, 0); + if (rc) + { + cerr << "ERROR: Safety pattern mismatch for " << name + << " ('" << value << "' vs. '" << re << "') rc=" << rc << endl; + exit(1); + } +} + + /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */ diff --git a/util.h b/util.h index 8fc64cbd..75e198ca 100644 --- a/util.h +++ b/util.h @@ -21,7 +21,7 @@ const std::string cmdstr_quoted(const std::string& cmd); std::string git_revision(const std::string& path); int stap_system(int verbose, const std::string& command); int kill_stap_spawn(int sig); - +void assert_regexp_match (const std::string& name, const std::string& value, const std::string& re); // stringification generics -- cgit From cc9e5488d82b728e568bca1f8d6094856fc8e641 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Fri, 12 Feb 2010 10:39:58 -0500 Subject: PR11105 part 2a, fix buggy \\. in -r option regexp --- main.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cxx b/main.cxx index 2dba179f..b5fdbc0c 100644 --- a/main.cxx +++ b/main.cxx @@ -768,7 +768,7 @@ main (int argc, char * const argv []) case 'r': if (client_options) // NB: no paths! - assert_regexp_match("-r parameter from client", optarg, "^[a-z0-9_\\.-]+$"); + assert_regexp_match("-r parameter from client", optarg, "^[a-z0-9_.-]+$"); setup_kernel_release(s, optarg); break; -- cgit From a7367d45ca743e8842bf824b0fa2285054d26f74 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sat, 13 Feb 2010 20:54:58 +0100 Subject: Test for sendfile syscall can handle non-socket fds now. Since 2.6.33 sendfile can handle non-socket fds, so make the test handle both success and failure. * testsuite/systemtap.syscall/sendfile.c (main): Make buffer 22 bytes, since 22 == EINVAL, test for 22 bytes send or -22 failure. --- testsuite/systemtap.syscall/sendfile.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testsuite/systemtap.syscall/sendfile.c b/testsuite/systemtap.syscall/sendfile.c index 690d078e..a21694fe 100644 --- a/testsuite/systemtap.syscall/sendfile.c +++ b/testsuite/systemtap.syscall/sendfile.c @@ -14,7 +14,7 @@ int main () int write_fd; struct stat stat_buf; off_t offset = 0; - char buff[512]; + char buff[22]; // Note below 22 == EINVAL int ret; memset(buff, 5, sizeof(buff)); @@ -32,11 +32,11 @@ int main () write_fd = creat("foobar2",S_IREAD|S_IWRITE|S_IRWXO); /* - * For kernel2.6 the write_fd has to be a socket otherwise - * sendfile will fail. So we test for failure here. + * For 2.6 the write_fd had to be a socket otherwise + * sendfile would fail. So we also test for failure here. */ ret = sendfile (write_fd, read_fd, &offset, stat_buf.st_size); - //staptest// sendfile (NNNN, NNNN, XXXX, 512) = -22 (EINVAL) + //staptest// sendfile (NNNN, NNNN, XXXX, 22) = -?22 close (read_fd); close (write_fd); -- cgit From c8408b459b88a5aa5f4325e690aef95b5da7c2eb Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Sun, 14 Feb 2010 21:42:06 +0100 Subject: PR11281 Allow negative values for -D argument. Change regexp match to "^[a-z_][a-z_0-9]*(=-?[a-z_0-9]+)?$". * main.cxx (main): case 'D' allow optional single minus sign after equal in assert_regexp_match(). --- main.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.cxx b/main.cxx index b5fdbc0c..faac7f81 100644 --- a/main.cxx +++ b/main.cxx @@ -821,7 +821,7 @@ main (int argc, char * const argv []) break; case 'D': - assert_regexp_match ("-D parameter", optarg, "^[a-z_][a-z_0-9]*(=[a-z_0-9]+)?$"); + assert_regexp_match ("-D parameter", optarg, "^[a-z_][a-z_0-9]*(=-?[a-z_0-9]+)?$"); if (client_options) client_options_disallowed += client_options_disallowed.empty () ? "-D" : ", -D"; s.macros.push_back (string (optarg)); -- cgit