]> git.apps.os.sepia.ceph.com Git - fscrypt.git/commit
filesystem: handle bind mounts properly
authorEric Biggers <ebiggers@google.com>
Tue, 29 Oct 2019 07:33:54 +0000 (00:33 -0700)
committerEric Biggers <ebiggers@google.com>
Wed, 30 Oct 2019 16:21:59 +0000 (09:21 -0700)
commitdbafdbaa9b0767f71affaf15fb8c626f64e27122
tree4a00cc9611161d0157f1932b2339ae89c3eee20b
parentfe58e7236a3285e172733aeab0b136bec968ac4d
filesystem: handle bind mounts properly

Currently, fscrypt treats bind mounts as separate filesystems.  This is
broken because fscrypt will look for a directory's encryption policy in
different places depending on which mount it's accessed through.  This
forces users to create an fscrypt metadata directory at every bind
mount, and to copy fscrypt metadata around between mounts.

Fix this by storing fscrypt metadata only at the root of the filesystem.

To accomplish this:

- Make mountsByDevice store only a single Mount per filesystem, rather
  than multiple.  For this Mount, choose a mount of the full filesystem
  if available, preferably a read-write mount.  If the filesystem has
  only bind mounts, store a nil entry in mountsByDevice so we can show a
  proper error message later.

- Change FindMount() and GetMount() to look up the Mount by device
  number rather than by path, so that they don't return different Mounts
  depending on which path is used.

- Change AllFilesystems() to not return bind mounts.

- Due to the above changes, the mountsByPath map is no longer needed
  outside of loadMountInfo().  So make it a local variable there.

Resolves https://github.com/google/fscrypt/issues/59
filesystem/filesystem.go
filesystem/mountpoint.go
filesystem/path.go