Move VDSOParamPage out of Timekeeper.

We want to decouple the netstack from the kernel. This coupling is
causing bugs in restore because netstack needs to be created before the Kernel
is restored. So right now, netstack ends up using a "temporary" Kernel which is
later destroyed in the restore sequence, but netstack keeps referencing it.

Before this change, netstack was being initialized with a `kernel.TimeKeeper`.
This `Timekeeper` was being initialized with `VDSOParamPage`, which references
the MemoryFile of the kernel. So as a result, on restore the netstack ends up
referencing the destroyed kernel's MemoryFile.

So instead move out VDSOParamPage from TimeKeeper altogether. The callers of
`TimeKeeper.SetClocks()` and `TimeKeeper.ResumeUpdates()` pass VDSOParamPage
from the correct kernel being used currently.

PiperOrigin-RevId: 647168588
This commit is contained in:
Ayush Ranjan
2024-06-26 20:31:38 -07:00
committed by gVisor bot
parent abde965590
commit 69c3e8d632
5 changed files with 35 additions and 34 deletions
+4 -2
View File
@@ -83,8 +83,9 @@ func Boot() (*kernel.Kernel, error) {
}
// Create timekeeper.
tk := kernel.NewTimekeeper(k.MemoryFile(), vdso.ParamPage.FileRange())
tk.SetClocks(time.NewCalibratedClocks())
tk := kernel.NewTimekeeper()
params := kernel.NewVDSOParamPage(k.MemoryFile(), vdso.ParamPage.FileRange())
tk.SetClocks(time.NewCalibratedClocks(), params)
creds := auth.NewRootCredentials(auth.NewRootUserNamespace())
@@ -96,6 +97,7 @@ func Boot() (*kernel.Kernel, error) {
Timekeeper: tk,
RootUserNamespace: creds.UserNamespace,
Vdso: vdso,
VdsoParams: params,
RootUTSNamespace: kernel.NewUTSNamespace("hostname", "domain", creds.UserNamespace),
RootIPCNamespace: kernel.NewIPCNamespace(creds.UserNamespace),
PIDNamespace: kernel.NewRootPIDNamespace(creds.UserNamespace),