Skip to content

Commit

Permalink
fusefrontend_reverse: Reject access to device nodes in newFile function
Browse files Browse the repository at this point in the history
Steps to reproduce:

* Create a regular reverse mount point
* Create a file "test" in the original directory
* Access the corresponding encrypted directory in the mount point (ls <encrypted dir>)
* Quickly delete the file in the original data - instead create a device node
* Access the file again, it will access the device node and attempt to read from it

Fixes #187
  • Loading branch information
slackner authored and rfjakob committed Dec 11, 2017
1 parent 3af5173 commit 96dc2ca
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/fusefrontend_reverse/rfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ func (rfs *ReverseFS) newFile(relPath string) (*reverseFile, fuse.Status) {
syscall.Close(fd)
return nil, fuse.ToStatus(err)
}
// Reject access if the file descriptor does not refer to a regular file.
var a fuse.Attr
a.FromStat(&st)
if !a.IsRegular() {
tlog.Warn.Printf("ino%d: newFile: not a regular file", st.Ino)
syscall.Close(fd)
return nil, fuse.ToStatus(syscall.EACCES)
}
// See if we have that inode number already in the table
// (even if Nlink has dropped to 1)
var derivedIVs pathiv.FileIVs
Expand Down

0 comments on commit 96dc2ca

Please sign in to comment.