Page MenuHomeFreeBSD

kinst: fix memcpy() tracing crash
ClosedPublic

Authored by christos on May 26 2023, 3:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 27, 8:17 AM
Unknown Object (File)
Sat, Apr 27, 8:11 AM
Unknown Object (File)
Sat, Apr 27, 8:11 AM
Unknown Object (File)
Sat, Apr 27, 8:11 AM
Unknown Object (File)
Sat, Apr 27, 8:11 AM
Unknown Object (File)
Sat, Apr 27, 6:30 AM
Unknown Object (File)
Mar 8 2024, 1:55 AM
Unknown Object (File)
Mar 8 2024, 1:55 AM
Subscribers

Details

Summary

Tracing memcpy() would crash the kernel, because we'd also trace the
memcpy()s called from kinst. To fix this, introduce kinst_memcpy() whose
arguments are 'volatile', so that we avoid having the compiler replace
it with a regular memcpy().

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/cddl/dev/kinst/amd64/kinst_isa.c
485

These calls can simply be memcpy().

sys/cddl/dev/kinst/kinst.c
68

I think there's no need to have a volatile qualifier on the return type.

69

This function should have a comment explaining its existence.

sys/cddl/dev/kinst/trampoline.c
57 ↗(On Diff #122473)

This can be regular memcpy().

christos added inline comments.
sys/cddl/dev/kinst/kinst.c
68

It didn't compile without it.

69

Forgot about it. Thanks.

christos marked 3 inline comments as done.

Use regular memcpy()s outside of probe context.

Approved with the comments addressed

sys/cddl/dev/kinst/amd64/kinst_isa.c
245

This also can use regular memcpy().

sys/cddl/dev/kinst/kinst.c
70
This revision is now accepted and ready to land.May 26 2023, 3:39 PM
christos marked 2 inline comments as done.

Address comments.

This revision now requires review to proceed.May 26 2023, 3:42 PM
This revision was not accepted when it landed; it landed in state Needs Review.May 26 2023, 3:44 PM
This revision was automatically updated to reflect the committed changes.