Commit 47211c2b authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher Committed by Han-Wen Nienhuys

pathfs: fix possible nil pointer dereference in GetAttr

gocryptfs user Felix Lechner reported a nil pointer dereference
in GetAttr: https://github.com/rfjakob/gocryptfs/issues/260

The crash is in line

	n.setClientInode(fi.Ino)

because fi is nil.

This can happen when file.GetAttr() returns an error code other than
ENOSYS and EBADF. For gocryptfs, this can only happen when an open
file descriptor breaks. In this case it was triggered by a failing
NFS volume.

Fix the crash by erroring out for error codes that are not handled
by the retry-by-path logic.
parent f4f7205f
...@@ -596,6 +596,10 @@ func (n *pathInode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Cont ...@@ -596,6 +596,10 @@ func (n *pathInode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Cont
if code.Ok() { if code.Ok() {
return code return code
} }
// ENOSYS and EBADF are retried below. Error out for other codes.
if code != fuse.ENOSYS && code != fuse.EBADF {
return code
}
} }
// If we don't have an open file, or fstat on it failed due to an internal // If we don't have an open file, or fstat on it failed due to an internal
// error, stat by path. // error, stat by path.
......
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