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)
Sat, Jun 8, 4:01 AM
Unknown Object (File)
Sat, Jun 8, 4:01 AM
Unknown Object (File)
Fri, Jun 7, 1:27 AM
Unknown Object (File)
Fri, Jun 7, 1:14 AM
Unknown Object (File)
Fri, May 17, 7:21 PM
Unknown Object (File)
Jan 18 2024, 1:18 PM
Unknown Object (File)
Jan 14 2024, 7:38 AM
Unknown Object (File)
Jan 8 2024, 7:17 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 Not Applicable
Unit
Tests Not Applicable

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