Page MenuHomeFreeBSD

kinst: fix memcpy() tracing crash
ClosedPublic

Authored by christos on May 26 2023, 3:10 PM.
Tags
None
Referenced Files
F136017625: D40284.diff
Sat, Nov 15, 3:14 AM
F136014285: D40284.diff
Sat, Nov 15, 2:29 AM
F135992307: D40284.id122478.diff
Fri, Nov 14, 9:49 PM
Unknown Object (File)
Tue, Nov 11, 3:24 AM
Unknown Object (File)
Sun, Nov 9, 4:41 PM
Unknown Object (File)
Sun, Nov 9, 4:41 PM
Unknown Object (File)
Sun, Nov 9, 4:41 PM
Unknown Object (File)
Sun, Nov 9, 4:41 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 Skipped
Unit
Tests Skipped
Build Status
Buildable 51710
Build 48601: arc lint + arc unit

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.