From 255614124d234e07bf5bd88a001ee620bba71395 Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Fri, 23 Feb 2024 09:34:08 -0800 Subject: [PATCH] Make a copy of handle in handleReadWriter. Earlier we were storing a pointer, which was causing the handle to escape to heap. Suggested-by: Jamie Liu PiperOrigin-RevId: 609753000 --- pkg/sentry/fsimpl/gofer/handle.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/sentry/fsimpl/gofer/handle.go b/pkg/sentry/fsimpl/gofer/handle.go index fb56e8061..7634ec878 100644 --- a/pkg/sentry/fsimpl/gofer/handle.go +++ b/pkg/sentry/fsimpl/gofer/handle.go @@ -104,7 +104,7 @@ func (h *handle) sync(ctx context.Context) error { type handleReadWriter struct { ctx context.Context - h *handle + h handle off uint64 } @@ -117,14 +117,14 @@ var handleReadWriterPool = sync.Pool{ func getHandleReadWriter(ctx context.Context, h *handle, offset int64) *handleReadWriter { rw := handleReadWriterPool.Get().(*handleReadWriter) rw.ctx = ctx - rw.h = h + rw.h = *h rw.off = uint64(offset) return rw } func putHandleReadWriter(rw *handleReadWriter) { rw.ctx = nil - rw.h = nil + rw.h = noHandle handleReadWriterPool.Put(rw) }