From 64e48cc3c69b618d0630769a3ec2238bac85a644 Mon Sep 17 00:00:00 2001 From: Jamie Liu Date: Tue, 26 Nov 2024 14:43:46 -0800 Subject: [PATCH] fsimpl/gofer: implement specialFileFD.InvalidateUnsavable() This fixes save/restore of mmapped gofer.specialFileFDs (usually obtained via mount option "disable_file_handle_sharing") for which mappings have actually been used (mm.pmas have been obtained). PiperOrigin-RevId: 700465816 --- pkg/sentry/fsimpl/gofer/special_file.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/sentry/fsimpl/gofer/special_file.go b/pkg/sentry/fsimpl/gofer/special_file.go index 93f9ed811..1a423f9c2 100644 --- a/pkg/sentry/fsimpl/gofer/special_file.go +++ b/pkg/sentry/fsimpl/gofer/special_file.go @@ -482,6 +482,10 @@ func (fd *specialFileFD) Translate(ctx context.Context, required, optional memma // InvalidateUnsavable implements memmap.Mappable.InvalidateUnsavable. func (fd *specialFileFD) InvalidateUnsavable(ctx context.Context) error { + d := fd.dentry() + d.mapsMu.Lock() + defer d.mapsMu.Unlock() + d.mappings.InvalidateAll(memmap.InvalidateOpts{}) return nil }