summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Cantrill <bryan@joyent.com>2013-11-19 17:20:43 +0000
committerBryan Cantrill <bryan@joyent.com>2013-11-19 17:20:43 +0000
commit4a6f2ba4e313d3ba11ec5fd34d3c18c9c28be355 (patch)
tree0ac946004fa2b45722ec3d9008c5b872a74d44b7
parent2aaa6175dee1cf15bae7e74e9a74f04bd700e164 (diff)
downloadillumos-joyent-4a6f2ba4e313d3ba11ec5fd34d3c18c9c28be355.tar.gz
OS-2631 pid provider rejects probes with valid UTF-8 names
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probefunc.ksh56
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probefunc.ksh.out3
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probemod.ksh64
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probemod.ksh.out3
-rw-r--r--usr/src/uts/common/dtrace/fasttrap.c23
5 files changed, 136 insertions, 13 deletions
diff --git a/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probefunc.ksh b/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probefunc.ksh
new file mode 100644
index 0000000000..c5d4abfb59
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probefunc.ksh
@@ -0,0 +1,56 @@
+#!/bin/ksh -p
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2013 Joyent, Inc. All rights reserved.
+#
+
+DIR=/var/tmp/dtest.$$
+mkdir $DIR
+cd $DIR
+
+cat > foo.c <<EOF
+#include <stdio.h>
+
+void
+foo()
+{
+ printf("in foo\n");
+}
+
+void
+main()
+{
+ foo();
+}
+EOF
+
+if ! gcc -m32 -S -o foo.orig.s foo.c ; then
+ print -u 2 "failed to compile foo in $DIR"
+ exit 1
+fi
+
+#
+# There's the right way, the wrong way, and the Max Power way!
+#
+cat foo.orig.s | sed 's/foo/foø/g' > foo.s
+gcc -o foo foo.s
+
+if ! dtrace -n 'pid$target:a.out:f*:entry{printf("probefunc: %s\n", \
+ probefunc)}' -qc ./foo ; then
+ print -u 2 "dtrace failed in $DIR"
+ exit 1
+fi
+
+cd
+rm -rf $DIR
+exit 0
diff --git a/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probefunc.ksh.out b/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probefunc.ksh.out
new file mode 100644
index 0000000000..d575ad8418
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probefunc.ksh.out
@@ -0,0 +1,3 @@
+in foø
+probefunc: foø
+
diff --git a/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probemod.ksh b/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probemod.ksh
new file mode 100644
index 0000000000..d56ef1ca18
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probemod.ksh
@@ -0,0 +1,64 @@
+#!/bin/ksh -p
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright (c) 2013 Joyent, Inc. All rights reserved.
+#
+
+DIR=/var/tmp/dtest.$$
+mkdir $DIR
+cd $DIR
+
+cat > foo.c <<EOF
+#include <stdlib.h>
+
+extern void foo();
+
+void
+main()
+{
+ foo();
+}
+EOF
+
+cat > libfoo.c <<EOF
+#include <stdio.h>
+
+void
+foo()
+{
+ printf("called foo\n");
+}
+EOF
+
+if ! gcc -m32 -fPIC -shared -o libføo.so libfoo.c -lc ; then
+ print -u 2 "failed to compile libfoo in $DIR"
+ exit 1
+fi
+
+
+if ! gcc -m32 -o foo foo.c -lføo -L. ; then
+ print -u 2 "failed to compile foo in $DIR"
+ exit 1
+fi
+
+export LD_LIBRARY_PATH=`pwd`
+
+if ! dtrace -n 'pid$target:libf*::entry{printf("probemod: %s\n", probemod)}' \
+ -qc ./foo ; then
+ print -u 2 "dtrace failed in $DIR"
+ exit 1
+fi
+
+cd
+rm -rf $DIR
+
diff --git a/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probemod.ksh.out b/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probemod.ksh.out
new file mode 100644
index 0000000000..0d959f3bf0
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/pid/tst.utf8probemod.ksh.out
@@ -0,0 +1,3 @@
+called foo
+probemod: libføo.so
+
diff --git a/usr/src/uts/common/dtrace/fasttrap.c b/usr/src/uts/common/dtrace/fasttrap.c
index 8cfe4cd33b..f486c06b2c 100644
--- a/usr/src/uts/common/dtrace/fasttrap.c
+++ b/usr/src/uts/common/dtrace/fasttrap.c
@@ -25,7 +25,7 @@
*/
/*
- * Copyright (c) 2011, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2013, Joyent, Inc. All rights reserved.
*/
#include <sys/atomic.h>
@@ -1936,8 +1936,7 @@ fasttrap_ioctl(dev_t dev, int cmd, intptr_t arg, int md, cred_t *cr, int *rv)
fasttrap_probe_spec_t *probe;
uint64_t noffs;
size_t size;
- int ret;
- char *c;
+ int ret, err;
if (copyin(&uprobe->ftps_noffs, &noffs,
sizeof (uprobe->ftps_noffs)))
@@ -1967,18 +1966,16 @@ fasttrap_ioctl(dev_t dev, int cmd, intptr_t arg, int md, cred_t *cr, int *rv)
* Verify that the function and module strings contain no
* funny characters.
*/
- for (c = &probe->ftps_func[0]; *c != '\0'; c++) {
- if (*c < 0x20 || 0x7f <= *c) {
- ret = EINVAL;
- goto err;
- }
+ if (u8_validate(probe->ftps_func, strlen(probe->ftps_func),
+ NULL, U8_VALIDATE_ENTIRE, &err) < 0) {
+ ret = EINVAL;
+ goto err;
}
- for (c = &probe->ftps_mod[0]; *c != '\0'; c++) {
- if (*c < 0x20 || 0x7f <= *c) {
- ret = EINVAL;
- goto err;
- }
+ if (u8_validate(probe->ftps_mod, strlen(probe->ftps_mod),
+ NULL, U8_VALIDATE_ENTIRE, &err) < 0) {
+ ret = EINVAL;
+ goto err;
}
if (!PRIV_POLICY_CHOICE(cr, PRIV_ALL, B_FALSE)) {