diff options
| author | Jakob Unterwurzacher | 2026-11-17 21:21:19 +0100 |
|---|---|---|
| committer | Jakob Unterwurzacher | 2026-11-17 21:21:19 +0100 |
| commit | 07ad4b3703912a246a9b75713fd757dc2be9a29d (patch) | |
| tree | f0fc1f486b840ff361d5f3d96a84cddc03efd847 | |
| parent | 851188164274de96cd581c3da1b5e847a42e2948 (diff) | |
ctlsocksrv.Serve() was started at the end of initFuseFrontend(), before
initGoFuse() calls fs.NewNodeFS(), which initializes the root inode.
In forward mode, EncryptPath/DecryptPath call prepareAtSyscallMyself(),
which calls Inode.IsRoot() and dereferences the still-nil bridge pointer.
As the socket is opened before asking for the password, a client can
queue a request during the password prompt. It is then accepted right
away and races initGoFuse(). If it wins, gocryptfs crashes with a nil
pointer dereference. The race detector reports the race on every such run.
Start Serve() in doMount() after initGoFuse() returns. The socket is still
opened early, and queued requests wait in the listen backlog.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| -rw-r--r-- | mount.go | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -109,6 +109,12 @@ func doMount(args *argContainer) { defer wipeKeys() // Initialize go-fuse FUSE server srv := initGoFuse(fs, args) + // Start serving the control socket only now. fusefrontend's + // EncryptPath/DecryptPath use the root inode, which go-fuse initializes + // in initGoFuse. Requests that arrived earlier wait in the listen backlog. + if args._ctlsockFd != nil { + go ctlsocksrv.Serve(args._ctlsockFd, fs.(ctlsocksrv.Interface)) + } if x, ok := fs.(AfterUnmounter); ok { defer x.AfterUnmount() } @@ -351,11 +357,6 @@ func initFuseFrontend(args *argContainer) (rootNode fs.InodeEmbedder, wipeKeys f } else { rootNode = fusefrontend.NewRootNode(frontendArgs, cEnc, nameTransform) } - // We have opened the socket early so that we cannot fail here after - // asking the user for the password - if args._ctlsockFd != nil { - go ctlsocksrv.Serve(args._ctlsockFd, rootNode.(ctlsocksrv.Interface)) - } return rootNode, func() { cCore.Wipe() } } |
