Skip to content

Commit

Permalink
pathfs: fix possible nil pointer dereference in GetAttr
Browse files Browse the repository at this point in the history
gocryptfs user Felix Lechner reported a nil pointer dereference
in GetAttr: rfjakob/gocryptfs#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.
  • Loading branch information
rfjakob committed Sep 8, 2018
1 parent 1d35017 commit b11e293
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fuse/pathfs/pathfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,10 @@ func (n *pathInode) GetAttr(out *fuse.Attr, file nodefs.File, context *fuse.Cont
if code.Ok() {
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
// error, stat by path.
Expand Down

0 comments on commit b11e293

Please sign in to comment.