Page MenuHomeFreeBSD

kinst: fix memcpy() tracing crash
ClosedPublic

Authored by christos on May 26 2023, 3:10 PM.
Tags
None
Referenced Files
F98899174: D40284.diff
Sat, Oct 5, 5:18 AM
Unknown Object (File)
Thu, Oct 3, 9:38 PM
Unknown Object (File)
Tue, Oct 1, 6:43 PM
Unknown Object (File)
Mon, Sep 23, 5:46 PM
Unknown Object (File)
Wed, Sep 18, 6:44 PM
Unknown Object (File)
Wed, Sep 18, 11:52 AM
Unknown Object (File)
Tue, Sep 17, 7:32 PM
Unknown Object (File)
Tue, Sep 17, 8:00 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 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.