Page MenuHomeFreeBSD

dtrace/arm64: Fix copyout and copyoutstr
Needs ReviewPublic

Authored by freebsd_dev.thsi.be on Sat, Sep 5, 4:25 PM.

Details

Reviewers
markj
andrew
gnn
Summary

Calling dtrace_copy and dtrace_copystr with the kaddr and uaddr
arguments inversed does not work with PAN. Rename them
dtrace_copyin_pan and dtrace_copyinstr_pan, respectively, and
implement dtrace_copyout_pan and dtrace_copyoutstr_pan.

Avoid excessive faulting by checkin DTrace's CPU flags. Implement the
trick from OpenSolaris/Illumos of only checking the flags when
crossing into a new page, altough more effectively by examining the
vaddr instead of the count.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 76570
Build 73453: arc lint + arc unit

Event Timeline

sys/cddl/contrib/opensolaris/uts/common/sys/dtrace_impl.h
1306

I'd like to take care of the armv6 case later. It alsos need the copy -> copyin rename and a new copyout versions. i'd like to use the same names, so dunno maybe it is better to use something else than _pan, e.g. _unpriv ?

For the record, the current broken behavior can be tested like this:

echo "Hello world!" > greetings
cat <<"EOT" > copyout.d
syscall::read:entry
/pid == $target/
{
	this->ubuf = arg1;
}

syscall::read:return
/pid == $target/
{
	self->kbuf = alloca(10);
	copyoutstr("Ciao ", this->ubuf, 5);
	copyinto(this->ubuf, 10, self->kbuf);
	copyout((void*)((uint64_t)self->kbuf+5), this->ubuf, 5);
}
EOT
dtrace -w -s copyout.d -c "cat greetings"

correct output:

dtrace: script 'copyout.d' matched 4 probes
dtrace: allowing destructive actions
 worl world!
dtrace: pid 5724 has exited