From 9ecb627726cf90008e6b6e135be958795d5dc91e Mon Sep 17 00:00:00 2001 From: Nayana Bidari Date: Mon, 26 Aug 2024 16:48:23 -0700 Subject: [PATCH] Fix syzkaller panic for unknown error 58. The errno 58 is not defined and it is the same as deadlock error. Update this in the host_linux.go file. Reported-by: syzbot+60bb099bed4694a37f61@syzkaller.appspotmail.com PiperOrigin-RevId: 667762290 --- pkg/sentry/fsimpl/fuse/connection.go | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/pkg/sentry/fsimpl/fuse/connection.go b/pkg/sentry/fsimpl/fuse/connection.go index bc7cb9887..90cdc326b 100644 --- a/pkg/sentry/fsimpl/fuse/connection.go +++ b/pkg/sentry/fsimpl/fuse/connection.go @@ -185,6 +185,19 @@ type connection struct { noOpen bool } +func connError(err error) error { + errno, ok := linuxerr.TranslateError(err) + if !ok { + log.Warningf("fuse: failed with invalid error: %v", err) + return linuxerr.EINVAL + } + if !linuxerr.IsValid(linuxerr.ToUnix(errno)) { + log.Warningf("fuse: failed with invalid error: %v", err) + return linuxerr.EINVAL + } + return err +} + func (conn *connection) saveInitializedChan() bool { select { case <-conn.initializedChan: @@ -255,7 +268,7 @@ func (conn *connection) Call(ctx context.Context, r *Request) (*Response, error) // Block requests sent before connection is initialized. if !conn.Initialized() && r.hdr.Opcode != linux.FUSE_INIT { if err := ctx.Block(conn.initializedChan); err != nil { - return nil, err + return nil, connError(err) } } @@ -278,10 +291,15 @@ func (conn *connection) Call(ctx context.Context, r *Request) (*Response, error) fut, err := conn.callFuture(ctx, r) conn.fd.mu.Unlock() if err != nil { - return nil, err + return nil, connError(err) } - return fut.resolve(ctx) + var res *Response + res, err = fut.resolve(ctx) + if err != nil { + return res, connError(err) + } + return res, nil } // callFuture makes a request to the server and returns a future response.