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)
Wed, Nov 6, 11:47 PM
Unknown Object (File)
Sat, Oct 26, 7:39 AM
Unknown Object (File)
Fri, Oct 18, 7:07 AM
Unknown Object (File)
Oct 16 2024, 5:19 AM
Unknown Object (File)
Oct 14 2024, 6:56 PM
Unknown Object (File)
Oct 11 2024, 8:25 AM
Unknown Object (File)
Oct 10 2024, 4:22 PM
Unknown Object (File)
Oct 6 2024, 5:51 PM
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.