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
F106333094: D39343.diff
Sat, Dec 28, 8:55 PM
Unknown Object (File)
Sat, Dec 14, 5:40 PM
Unknown Object (File)
Thu, Dec 5, 10:21 AM
Unknown Object (File)
Nov 12 2024, 1:57 AM
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
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