FUSE: Only block with a task if it is the task goroutine.

Reported-by: syzbot+1a872f529c835812552c@syzkaller.appspotmail.com
PiperOrigin-RevId: 660505372
This commit is contained in:
Nicolas Lacasse
2024-08-07 13:04:35 -07:00
committed by gVisor bot
parent 918a4d7089
commit e30fa67177
2 changed files with 3 additions and 12 deletions
+3 -4
View File
@@ -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.
-8
View File
@@ -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 {