-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dtprobed's ioctl handler is a state machine that reads in client DOF in multiple phases: DTP_IOCTL_START: read the struct dof_helper_t DTP_IOCTL_HDR: read the struct dof_hdr_t, giving us the size of the DOF DTP_IOCTL_DOFHDR: read the DOF itself DTP_IOCTL_DOF: (everything is read; actually parse the DOF) These various phases are triggered by issuing a fuse_reply_ioctl_retry() to ask FUSE to read things out of the ioctl() caller for us and call us back with the new stuff. We can read from any address in the client (we are root), but that doesn't mean we can read any *length* -- the kernel refuses to read beyond a certain length and alas that length is customizable via mount options (or, for CUSE, via kernel command-line options) and we can't easily tell what it is. I think it reasonable to say that anyone who *reduces* the length below the default is asking for it: I can't find any CUSE or FUSE-using code anywhere on the Internet that does anything more than hardwire this value to 128KiB. For paranoia, we use 64KiB ourselves -- that's still a lot of probes in one go. We add a new state, DTP_IOCTL_DOFCHUNK, and read in one piece of DOF per chunk until all the chunks are read in, concatenating them before handing it off to the parser. A new test checks this stuff: it has 206KiB of DOF which is enough to test "first chunk", "neither first nor last chunk" and "last chunk" cases: the DOF itself isn't formatted such that this equates to "first probe, probe in the middle, last probe" but if any of those chunks is missing or misaligned the string tables will be fubared and all the probe names will be wrong, triggering a test failure (at best). Orabug: 35411920 Signed-off-by: Nick Alcock <nick.alcock@oracle.com> Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
- Loading branch information
1 parent
98e1851
commit ea56ab0
Showing
3 changed files
with
175 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
test:main:test1 | ||
test:main:test750 | ||
test:main:test1999 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/bash | ||
# | ||
# Oracle Linux DTrace. | ||
# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at | ||
# http://oss.oracle.com/licenses/upl. | ||
# | ||
if [ $# != 1 ]; then | ||
echo expected one argument: '<'dtrace-path'>' | ||
exit 2 | ||
fi | ||
|
||
dtrace=$1 | ||
CC=/usr/bin/gcc | ||
CFLAGS="-I${PWD}/uts/common" | ||
DIRNAME="$tmpdir/usdt-manyprobes.$$.$RANDOM" | ||
mkdir -p $DIRNAME | ||
cd $DIRNAME | ||
|
||
gen_test() | ||
{ | ||
local n=$1 | ||
echo "#include <sys/sdt.h>" | ||
echo "void main(void) {" | ||
for i in $(seq 1 $n); do | ||
echo 'DTRACE_PROBE1(manyprobes, 'test$i, '"foo");' | ||
done | ||
echo "}" | ||
} | ||
|
||
gen_provider() | ||
{ | ||
local n=$1 | ||
echo "provider manyprobes {" | ||
for i in $(seq 1 $n); do | ||
echo "probe test$i(string);" | ||
done | ||
echo "};" | ||
} | ||
|
||
nprobes=2000 | ||
gen_test $nprobes > test.c | ||
gen_provider $nprobes > manyprobes.d | ||
|
||
${CC} ${CFLAGS} -c test.c | ||
if [ $? -ne 0 ]; then | ||
echo "failed to compile test.c" >& 2 | ||
exit 1 | ||
fi | ||
$dtrace -G -s manyprobes.d test.o | ||
if [ $? -ne 0 ]; then | ||
echo "failed to create DOF" >& 2 | ||
exit 1 | ||
fi | ||
${CC} ${CFLAGS} -o test test.o manyprobes.o | ||
if [ $? -ne 0 ]; then | ||
echo "failed to link final executable" >& 2 | ||
exit 1 | ||
fi | ||
|
||
script() | ||
{ | ||
$dtrace -c ./test -qs /dev/stdin <<EOF | ||
manyprobes\$target:::test1, manyprobes\$target:::test750, manyprobes\$target:::test1999 | ||
{ | ||
printf("%s:%s:%s\n", probemod, probefunc, probename); | ||
} | ||
EOF | ||
} | ||
|
||
script | ||
status=$? | ||
|
||
# Temporary, until autocleanup is implemented | ||
echo - > /sys/kernel/tracing/uprobe_events 2>/dev/null | ||
|
||
exit $status |