]> git.apps.os.sepia.ceph.com Git - fscrypt.git/commit
filesystem: store mountpoint in link files as a fallback
authorEric Biggers <ebiggers@google.com>
Thu, 23 Dec 2021 04:46:16 +0000 (22:46 -0600)
committerEric Biggers <ebiggers@google.com>
Thu, 23 Dec 2021 04:46:16 +0000 (22:46 -0600)
commit5ae7da4ee6582099de5d1b14733f8d58f4dc2816
treea2fd322f6e829fa5718507d510c9db17bf4131c1
parent6ec8ee00398c435aba7cbb68f8246c1772e12908
filesystem: store mountpoint in link files as a fallback

Currently, linked protectors use filesystem link files of the form
"UUID=<uuid>".  These links get broken if the filesystem's UUID changes,
e.g. due to the filesystem being re-created even if the ".fscrypt"
directory is backed up and restored.

To prevent links from being broken (in most cases), start storing the
mountpoint path in the link files too, in the form
"UUID=<uuid>\nPATH=<path>\n".  When following a link, try the UUID
first, and if it doesn't work try the PATH.  While it's possible that
the path changed too, for login protectors (the usual use case of linked
protectors) this won't be an issue as the path will always be "/".

An alternative solution would be to fall back to scanning all
filesystems for the needed protector descriptor.  I decided not to do
that, since relying on a global scan doesn't seem to be a good design.
It wouldn't scale to large numbers of filesystems, it could cross
security boundaries, and it would make it possible for adding a new
filesystem to break fscrypt on existing filesystems.  And if a global
scan was an acceptable way to find protectors during normal use, then
there would be no need for link files in the first place.

Note: this change is backwards compatible (i.e., fscrypt will continue
to recognize old link files) but not forwards-compatible (i.e., previous
versions of fscrypt won't recognize new link files).

Fixes https://github.com/google/fscrypt/issues/311
cli-tests/t_encrypt_login.out
cli-tests/t_encrypt_login.sh
filesystem/filesystem.go
filesystem/mountpoint.go
filesystem/mountpoint_test.go