Page MenuHomeFreeBSD

arm64: Ensure that thread0's PCB flags are initialized
ClosedPublic

Authored by markj on Mar 30 2023, 4:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 2 2024, 8:02 AM
Unknown Object (File)
Sep 24 2024, 5:45 PM
Unknown Object (File)
Sep 23 2024, 9:25 PM
Unknown Object (File)
Sep 10 2024, 6:31 PM
Unknown Object (File)
Sep 7 2024, 5:48 PM
Unknown Object (File)
Sep 3 2024, 2:42 PM
Unknown Object (File)
Aug 31 2024, 11:22 AM
Unknown Object (File)
Aug 6 2024, 5:15 AM
Subscribers

Details

Summary

On arm64, the PCB is stored at the top of the thread stack. For thread0
this comes from the static "initstack" region, which is placed in the
.init_pagetable section, which is not part of the BSS and thus doesn't
get zeroed by locore. (See the comment in ldscript.arm64.) It is thus
possible for the pcb_flags field to be uninitialized, which can result
in PCB_SINGLE_STEP being set.

Fix this by simply initializing the field. Alternately we could move
initstack to the BSS. OTOH, kernel stacks for all other threads also
should not be assumed to be zero-filled, so it's probably better to be
consistent.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 50680
Build 47571: arc lint + arc unit

Event Timeline

markj requested review of this revision.Mar 30 2023, 4:10 PM

I think it's an accident it's in the .init_pagetable section. I don't see a reason to not move it to .bss if it fixes issues where the pcb has uninitialised data.

This revision is now accepted and ready to land.Mar 31 2023, 10:44 AM

I think it's an accident it's in the .init_pagetable section. I don't see a reason to not move it to .bss if it fixes issues where the pcb has uninitialised data.

I suspect we should simply do both. Explicit initialization here is better, but there's no reason for initstack to be in init_pagetable.

I think it's an accident it's in the .init_pagetable section. I don't see a reason to not move it to .bss if it fixes issues where the pcb has uninitialised data.

I suspect we should simply do both. Explicit initialization here is better, but there's no reason for initstack to be in init_pagetable.

https://reviews.freebsd.org/D39367