From e219f75d8b3c28d4d41f8b232b9879391688ceb2 Mon Sep 17 00:00:00 2001 From: Etienne Perot Date: Fri, 4 Feb 2022 14:08:51 -0800 Subject: [PATCH] Fuse: Cache `maxActiveRequests` in `connection` to avoid reading it from `fs`. Reported-by: syzbot+6a1f1b6e126622f61c0e@syzkaller.appspotmail.com PiperOrigin-RevId: 426488251 --- pkg/sentry/fsimpl/fuse/connection.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/sentry/fsimpl/fuse/connection.go b/pkg/sentry/fsimpl/fuse/connection.go index 7ac672d83..5e29a6c4b 100644 --- a/pkg/sentry/fsimpl/fuse/connection.go +++ b/pkg/sentry/fsimpl/fuse/connection.go @@ -148,6 +148,11 @@ type connection struct { // Negotiated in FUSE_INIT. maxPages uint16 + // maxActiveRequests specifies the maximum number of active requests that can + // exist at any time. Any further requests will block when trying to CAll + // the server. + maxActiveRequests uint64 + // minor version of the FUSE protocol. // Negotiated and only set in INIT. minor uint32 @@ -217,6 +222,7 @@ func newFUSEConnection(_ context.Context, fuseFD *DeviceFD, opts *filesystemOpti asyncCongestionThreshold: fuseDefaultCongestionThreshold, maxRead: opts.maxRead, maxPages: fuseDefaultMaxPagesPerReq, + maxActiveRequests: opts.maxActiveRequests, initializedChan: make(chan struct{}), connected: true, }, nil @@ -296,7 +302,7 @@ func (conn *connection) callFuture(t *kernel.Task, r *Request) (*futureResponse, // This can potentially starve a request forever but this can only happen // if there are always too many ongoing requests all the time. The // supported maxActiveRequests setting should be really high to avoid this. - for conn.fd.numActiveRequests == conn.fd.fs.opts.maxActiveRequests { + for conn.fd.numActiveRequests == conn.maxActiveRequests { log.Infof("Blocking request %v from being queued. Too many active requests: %v", r.id, conn.fd.numActiveRequests) conn.fd.mu.Unlock()