Commit 96c47482 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Fix raciness in MountState.kernelSettings access.

parent 3a2e2a0c
...@@ -35,13 +35,13 @@ type MountState struct { ...@@ -35,13 +35,13 @@ type MountState struct {
latencies *LatencyMap latencies *LatencyMap
opts *MountOptions opts *MountOptions
kernelSettings raw.InitIn
reqMu sync.Mutex reqMu sync.Mutex
reqPool []*request reqPool []*request
readPool [][]byte readPool [][]byte
reqReaders int reqReaders int
outstandingReadBufs int outstandingReadBufs int
kernelSettings raw.InitIn
canSplice bool canSplice bool
loops sync.WaitGroup loops sync.WaitGroup
...@@ -66,7 +66,11 @@ func (ms *MountState) ThreadSanitizerSync() { ...@@ -66,7 +66,11 @@ func (ms *MountState) ThreadSanitizerSync() {
} }
func (ms *MountState) KernelSettings() raw.InitIn { func (ms *MountState) KernelSettings() raw.InitIn {
return ms.kernelSettings ms.reqMu.Lock()
s := ms.kernelSettings
ms.reqMu.Unlock()
return s
} }
func (ms *MountState) MountPoint() string { func (ms *MountState) MountPoint() string {
......
...@@ -85,6 +85,7 @@ func doInit(state *MountState, req *request) { ...@@ -85,6 +85,7 @@ func doInit(state *MountState, req *request) {
return return
} }
state.reqMu.Lock()
state.kernelSettings = *input state.kernelSettings = *input
state.kernelSettings.Flags = input.Flags & (raw.CAP_ASYNC_READ | raw.CAP_BIG_WRITES | raw.CAP_FILE_OPS) state.kernelSettings.Flags = input.Flags & (raw.CAP_ASYNC_READ | raw.CAP_BIG_WRITES | raw.CAP_FILE_OPS)
if input.Minor >= 13 { if input.Minor >= 13 {
...@@ -94,6 +95,7 @@ func doInit(state *MountState, req *request) { ...@@ -94,6 +95,7 @@ func doInit(state *MountState, req *request) {
state.opts.MaxWrite = maxW state.opts.MaxWrite = maxW
} }
} }
state.reqMu.Unlock()
out := &raw.InitOut{ out := &raw.InitOut{
Major: FUSE_KERNEL_VERSION, Major: FUSE_KERNEL_VERSION,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment