From e30fa671774bafdf8208addf5bf4f43116c3994d Mon Sep 17 00:00:00 2001 From: Nicolas Lacasse Date: Wed, 7 Aug 2024 13:00:38 -0700 Subject: [PATCH] FUSE: Only block with a task if it is the task goroutine. Reported-by: syzbot+1a872f529c835812552c@syzkaller.appspotmail.com PiperOrigin-RevId: 660505372 --- pkg/sentry/fsimpl/fuse/connection.go | 7 +++---- pkg/sentry/fsimpl/fuse/inode.go | 8 -------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/pkg/sentry/fsimpl/fuse/connection.go b/pkg/sentry/fsimpl/fuse/connection.go index f83438c89..bc7cb9887 100644 --- a/pkg/sentry/fsimpl/fuse/connection.go +++ b/pkg/sentry/fsimpl/fuse/connection.go @@ -252,10 +252,9 @@ func (conn *connection) CallAsync(ctx context.Context, r *Request) error { // The forget request does not have a reply, // as documented in include/uapi/linux/fuse.h:FUSE_FORGET. func (conn *connection) Call(ctx context.Context, r *Request) (*Response, error) { - b := blockerFromContext(ctx) // Block requests sent before connection is initialized. if !conn.Initialized() && r.hdr.Opcode != linux.FUSE_INIT { - if err := b.Block(conn.initializedChan); err != nil { + if err := ctx.Block(conn.initializedChan); err != nil { return nil, err } } @@ -276,13 +275,13 @@ func (conn *connection) Call(ctx context.Context, r *Request) (*Response, error) return nil, linuxerr.ECONNREFUSED } - fut, err := conn.callFuture(b, r) + fut, err := conn.callFuture(ctx, r) conn.fd.mu.Unlock() if err != nil { return nil, err } - return fut.resolve(b) + return fut.resolve(ctx) } // callFuture makes a request to the server and returns a future response. diff --git a/pkg/sentry/fsimpl/fuse/inode.go b/pkg/sentry/fsimpl/fuse/inode.go index 101e97b2a..6f8e8a142 100644 --- a/pkg/sentry/fsimpl/fuse/inode.go +++ b/pkg/sentry/fsimpl/fuse/inode.go @@ -115,14 +115,6 @@ type inode struct { blockSize atomicbitops.Uint32 // 0 if unknown. } -func blockerFromContext(ctx context.Context) context.Blocker { - kernelTask := kernel.TaskFromContext(ctx) - if kernelTask == nil { - return ctx - } - return kernelTask -} - func pidFromContext(ctx context.Context) uint32 { kernelTask := kernel.TaskFromContext(ctx) if kernelTask == nil {