Page MenuHomeFreeBSD

kinst: fix memcpy() tracing crash
ClosedPublic

Authored by christos on May 26 2023, 3:10 PM.
Tags
None
Referenced Files
F109937645: D40284.diff
Tue, Feb 11, 11:50 AM
Unknown Object (File)
Fri, Feb 7, 3:05 PM
Unknown Object (File)
Sun, Jan 26, 6:17 PM
Unknown Object (File)
Sat, Jan 25, 2:15 AM
Unknown Object (File)
Wed, Jan 15, 3:29 PM
Unknown Object (File)
Jan 11 2025, 2:54 AM
Unknown Object (File)
Jan 9 2025, 4:43 PM
Unknown Object (File)
Dec 28 2024, 12:37 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 51711
Build 48602: 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.