]> git.apps.os.sepia.ceph.com Git - fscrypt.git/log
fscrypt.git
2 years agoUpgrade google.golang.org/protobuf
Eric Biggers [Sat, 9 Sep 2023 22:34:26 +0000 (15:34 -0700)]
Upgrade google.golang.org/protobuf

2 years agoUpgrade golang.org/x/tools
Eric Biggers [Sat, 9 Sep 2023 22:34:26 +0000 (15:34 -0700)]
Upgrade golang.org/x/tools

2 years agoUpgrade golang.org/x/crypto
Eric Biggers [Sat, 9 Sep 2023 22:34:26 +0000 (15:34 -0700)]
Upgrade golang.org/x/crypto

2 years agoUpgrade golang.org/x/term
Eric Biggers [Sat, 9 Sep 2023 22:34:26 +0000 (15:34 -0700)]
Upgrade golang.org/x/term

2 years agoUpgrade golang.org/x/sys
Eric Biggers [Sat, 9 Sep 2023 22:34:26 +0000 (15:34 -0700)]
Upgrade golang.org/x/sys

2 years agoFixup for previous commit
Eric Biggers [Sat, 9 Sep 2023 22:02:06 +0000 (15:02 -0700)]
Fixup for previous commit

2 years agoStop using golang.org/x/lint
Eric Biggers [Sat, 9 Sep 2023 21:55:52 +0000 (14:55 -0700)]
Stop using golang.org/x/lint

golint is not supported anymore.  See
https://github.com/golang/go/issues/38968.

We already use both 'go vet' and 'staticcheck' which are maintained.

2 years agoREADME.md: don't recommend 'go get'
Eric Biggers [Sat, 9 Sep 2023 21:43:01 +0000 (14:43 -0700)]
README.md: don't recommend 'go get'

With the latest version of go, the recommended 'go get' commands fail:

    go: go.mod file not found in current directory or any parent directory.
            'go get' is no longer supported outside a module.
            To build and install a command, use 'go install' with a version,
            like 'go install example.com/cmd@latest'
            For more information, see https://golang.org/doc/go-get-install-deprecation
            or run 'go help get' or 'go help install'.

Replace them with commands that work.

2 years agomountpoint_test: skip TestLoadSourceDevice if loop0 doesn't exist
Eric Biggers [Sat, 9 Sep 2023 18:30:45 +0000 (11:30 -0700)]
mountpoint_test: skip TestLoadSourceDevice if loop0 doesn't exist

Probably resolves https://github.com/google/fscrypt/issues/382

2 years agoRe-run 'make format' with latest version of gofmt
Eric Biggers [Sat, 9 Sep 2023 18:30:45 +0000 (11:30 -0700)]
Re-run 'make format' with latest version of gofmt

2 years agoAdjust nested lists to prevent gofmt from flattening them
Eric Biggers [Sat, 9 Sep 2023 18:30:45 +0000 (11:30 -0700)]
Adjust nested lists to prevent gofmt from flattening them

The latest version of gofmt flattens the nested lists in comments in
crypto.go and filesystem.go.  According to
https://go.dev/doc/comment#mistakes, "Go doc comments do not support
nested lists".  However, that page also mentions that a workaround is to
use different list markers for each level.  Do that.

2 years agov0.3.4
Eric Biggers [Tue, 31 Jan 2023 06:59:20 +0000 (22:59 -0800)]
v0.3.4

2 years agoAdd a NEWS file
Eric Biggers [Tue, 31 Jan 2023 06:59:20 +0000 (22:59 -0800)]
Add a NEWS file

Copy the GitHub release notes into a NEWS.md file so that the release
notes are included in the actual git repo.  This way, they aren't hidden
away in GitHub, where they require an internet connection to access and
will be lost if GitHub ever goes away.  This also makes the release
notes be properly versioned; GitHub allows past release notes to be
edited, and there doesn't seem to be any record of what changed.

Finally, this allows packages to install the release notes into
/usr/share/doc/$pkgname/, as is the usual convention.

2 years agoci.yml: upgrade to actions/checkout@v3
Eric Biggers [Tue, 31 Jan 2023 06:59:20 +0000 (22:59 -0800)]
ci.yml: upgrade to actions/checkout@v3

This avoids the following warning from GitHub Actions:

    Node.js 12 actions are deprecated. Please update the following
    actions to use Node.js 16: actions/checkout@v2.

2 years agoOnly use up to MaxParallelism CPUs
Joe Richey [Sat, 27 Aug 2022 08:01:31 +0000 (01:01 -0700)]
Only use up to MaxParallelism CPUs

This prevents panics on 256-core systems, and has a 300-core system use
255 CPUs (the max) rather than 44 CPUs (300 casted to a uint8).

Signed-off-by: Joe Richey <joerichey@google.com>
[ebiggers: also set TruncationFixed at the end of getHashingCosts()]
Signed-off-by: Eric Biggers <ebiggers@google.com>
2 years agoIncrease checks for invalid HashingCosts
Joe Richey [Sat, 27 Aug 2022 07:32:56 +0000 (00:32 -0700)]
Increase checks for invalid HashingCosts

Signed-off-by: Joe Richey <joerichey@google.com>
[ebiggers: moved the new checks from PassphraseHash to CheckValidity]
Signed-off-by: Eric Biggers <ebiggers@google.com>
2 years agoAdd truncation_fixed field to HashingCosts
Joe Richey [Sat, 27 Aug 2022 06:40:44 +0000 (23:40 -0700)]
Add truncation_fixed field to HashingCosts

This allows us to fix the bug where Parallelism is inadvertantly
truncated to 8 bits in a backwards compatible way.

Signed-off-by: Joe Richey <joerichey@google.com>
2 years agoUpdate file comment
Joe Richey [Sat, 27 Aug 2022 06:35:33 +0000 (23:35 -0700)]
Update file comment

We now create the `*pb.go` files via the makefile instead of though
`go generate`.

Signed-off-by: Joe Richey <joerichey@google.com>
2 years agoStop using deprecated package io/ioutil
Eric Biggers [Sun, 4 Dec 2022 21:27:43 +0000 (13:27 -0800)]
Stop using deprecated package io/ioutil

Since Go 1.16 (which recently became the minimum supported Go version
for this project), the package io/ioutil is deprecated in favor of
equivalent functionality in the io and os packages.  staticcheck warns
about this.  Address all the warnings by switching to the non-deprecated
replacement functions.

2 years agopam_fscrypt: filter out irrelevant policies earlier
Eric Biggers [Sat, 3 Dec 2022 06:13:01 +0000 (22:13 -0800)]
pam_fscrypt: filter out irrelevant policies earlier

If a session is opened for a user twice and the second doesn't have the
AUTHTOK data, pam_fscrypt prints an error message that says it failed to
unlock a protector because AUTHTOK data is missing.  This is misleading
because the protector and its associated policies were already unlocked
by the first session.

To avoid this, move the check for whether the policy is provisioned or
not into policiesUsingProtector().  Also do the same for CloseSession.

2 years agoMake pam_fscrypt.so support the unlock_only option
Eric Biggers [Tue, 18 Oct 2022 17:12:02 +0000 (10:12 -0700)]
Make pam_fscrypt.so support the unlock_only option

Now that it's been requested by users, bring back the "unlock_only"
option, which was originally proposed as part of
https://github.com/google/fscrypt/pull/281 but was dropped in the final
version of that pull request.

Resolves https://github.com/google/fscrypt/issues/357

2 years agoAdd support for AES_256_HCTR2 filenames encryption
Eric Biggers [Tue, 18 Oct 2022 17:02:50 +0000 (10:02 -0700)]
Add support for AES_256_HCTR2 filenames encryption

Support for AES_256_HCTR2 filenames encryption was added in kernel
version 6.0.  The kernel doesn't yet support AES_256_HCTR2 for contents
encryption.

3 years agoIgnore JSON whitespace in tests (#364)
Joseph Richey [Sat, 27 Aug 2022 07:44:21 +0000 (00:44 -0700)]
Ignore JSON whitespace in tests (#364)

Follow up to #362

Protojson randomly inserts whitespace to indicate that the output is
unstable, breaking out tests. To fix this, compact the output before
comparison.

Signed-off-by: Joe Richey <joerichey@google.com>
Signed-off-by: Joe Richey <joerichey@google.com>
3 years agofsync set policy ioctls
Marcel Lauhoff [Fri, 12 Aug 2022 12:45:29 +0000 (14:45 +0200)]
fsync set policy ioctls

Split policyIoctl into setPolicyIoctl and getPolicyIoctl. Add a
os.Sync() call to setPolicyIoctl.

Policy ioctls are not necessary durable on return. For example, on
ext4 (ref: fs/ext4/crypto.c: ext4_set_context) they are not. This may
lead to a filesystem containing fscrypt metadata (in .fscrypt), but
without the policy applied on an encrypted directory.

Example:
Snapshotting a mounted ext4 filesystem on Ceph RBD right after
setting the policy. While subject to timing, with high probability the
snapshot will not have the policy set. Calling fsync fixes this.

Signed-off-by: Marcel Lauhoff <marcel.lauhoff@suse.com>
3 years agoMerge pull request #362 from google/fix-cli-tests-2
Joseph Richey [Fri, 19 Aug 2022 02:06:15 +0000 (19:06 -0700)]
Merge pull request #362 from google/fix-cli-tests-2

cli-tests: account for protojson whitespace randomization

3 years agocli-tests: account for protojson whitespace randomization
Eric Biggers [Thu, 18 Aug 2022 05:15:52 +0000 (22:15 -0700)]
cli-tests: account for protojson whitespace randomization

Annoyingly, for JSON formatting protojson randomly selects a spacing
method (one space or two spaces) depending on a hash of some sections of
the Go binary, to discourage depending on its output being stable.  This
breaks some checks in the CLI tests of the contents of fscrypt.conf and
the output of 'fscrypt status'.  As there doesn't appear to be a
straightforward alternative currently, for now just update the tests to
take into consideration the possible extra space.

3 years agoTry to detect process being forked during PAM transaction
Eric Biggers [Sun, 17 Apr 2022 05:31:32 +0000 (22:31 -0700)]
Try to detect process being forked during PAM transaction

Update https://github.com/google/fscrypt/issues/350

3 years agoMerge pull request #354 from google/staticcheck-fix
Joseph Richey [Sat, 9 Apr 2022 08:44:51 +0000 (01:44 -0700)]
Merge pull request #354 from google/staticcheck-fix

Upgrade dependencies to latest version

3 years agoMerge pull request #355 from google/supported-filesystems
Joseph Richey [Sat, 9 Apr 2022 06:43:01 +0000 (23:43 -0700)]
Merge pull request #355 from google/supported-filesystems

Add lustre to allowed filesystems and update documentation

3 years agoRe-run 'make format' with latest version of gofmt
Eric Biggers [Sat, 9 Apr 2022 06:41:08 +0000 (23:41 -0700)]
Re-run 'make format' with latest version of gofmt

3 years agoSwitch to google.golang.org/protobuf/proto
Eric Biggers [Sat, 9 Apr 2022 06:16:59 +0000 (23:16 -0700)]
Switch to google.golang.org/protobuf/proto

github.com/golang/protobuf/proto has been deprecated in favor of
google.golang.org/protobuf/proto, so migrate to the non-deprecated one.

3 years agoAdd lustre to allowed filesystems and update documentation
Eric Biggers [Sat, 9 Apr 2022 03:08:42 +0000 (20:08 -0700)]
Add lustre to allowed filesystems and update documentation

3 years agoUse Go 1.18 in all other CI steps
Joe Richey [Fri, 8 Apr 2022 23:36:23 +0000 (16:36 -0700)]
Use Go 1.18 in all other CI steps

Signed-off-by: Joe Richey <joerichey@google.com>
3 years agoRegenerate go.mod and go.sum with go 1.16
Joe Richey [Fri, 8 Apr 2022 23:32:57 +0000 (16:32 -0700)]
Regenerate go.mod and go.sum with go 1.16

Signed-off-by: Joe Richey <joerichey@google.com>
3 years agoUpgrade honnef.co/go/tools to latest version
Eric Biggers [Fri, 8 Apr 2022 23:15:24 +0000 (16:15 -0700)]
Upgrade honnef.co/go/tools to latest version

The version of 'staticcheck' (part of honnef.co/go/tools) we were
pinning is incompatible with Go 1.18, as per
https://github.com/dominikh/go-tools/issues/1165.

To allow 'make lint' to work with Go 1.18 and later, upgrade
honnef.co/go/tools to the latest version.

This requires that several other modules be upgraded too.

3 years agoRemove unnecessary uses of fmt.Sprintf()
Eric Biggers [Fri, 8 Apr 2022 23:15:22 +0000 (16:15 -0700)]
Remove unnecessary uses of fmt.Sprintf()

The latest version of 'staticcheck' warns about these.

3 years agoMerge pull request #353 from google/go-version
Joseph Richey [Fri, 8 Apr 2022 23:23:54 +0000 (16:23 -0700)]
Merge pull request #353 from google/go-version

Bump up required Go version to 1.16

3 years agoBump up required Go version to 1.16
Eric Biggers [Fri, 8 Apr 2022 22:55:58 +0000 (15:55 -0700)]
Bump up required Go version to 1.16

Bump up the required Go version to 1.16 so that we can assume that Go
modules are enabled by default.  Go 1.16 is the latest end-of-life
release, so this makes it so that we support the latest end-of-life
release (1.16), the current maintainance release (1.17), the current
release (1.18), and future releases.  This the same approach we took
when we last bumped up the required Go version.

Also update the ci.yml file to test with these versions.

3 years agov0.3.3
Eric Biggers [Wed, 23 Feb 2022 20:48:48 +0000 (12:48 -0800)]
v0.3.3

3 years agoMerge pull request #346 from google/fixes
Eric Biggers [Wed, 23 Feb 2022 20:44:31 +0000 (12:44 -0800)]
Merge pull request #346 from google/fixes

Metadata validation and other security improvements

3 years agopam_fscrypt: ignore system users
Eric Biggers [Wed, 23 Feb 2022 20:35:04 +0000 (12:35 -0800)]
pam_fscrypt: ignore system users

pam_fscrypt should never need to do anything for system users, so detect
them early so that we can avoid wasting any resources looking for their
login protector.

3 years agopam_fscrypt: log errors getting protector in policiesUsingProtector()
Eric Biggers [Wed, 23 Feb 2022 20:35:04 +0000 (12:35 -0800)]
pam_fscrypt: log errors getting protector in policiesUsingProtector()

If the error is anything other than ErrNotSetup, it might be helpful to
know what is going on.

3 years agofilesystem: create metadata files with mode 0600
Eric Biggers [Wed, 23 Feb 2022 20:35:04 +0000 (12:35 -0800)]
filesystem: create metadata files with mode 0600

Currently, fscrypt policies and protectors are world readable, as they
are created with mode 0644.  While this can be nice for use cases where
users share these files, those use cases seem to be quite rare, and it's
not a great default security-wise since it exposes password hashes to
all users.  While fscrypt uses a very strong password hash algorithm, it
would still be best to follow the lead of /etc/shadow and keep this
information non-world-readable.

Therefore, start creating these files with mode 0600.

Of course, if users do actually want to share these files, they have the
option of simply chmod'ing them to a less restrictive mode.  An option
could also be added to make fscrypt use the old mode 0644; however, the
need for that is currently unclear.

3 years agofilesystem: preserve metadata file permissions on updates
Eric Biggers [Wed, 23 Feb 2022 20:35:04 +0000 (12:35 -0800)]
filesystem: preserve metadata file permissions on updates

Since fscrypt replaces metadata files rather than overwrites them (to
get atomicity), their owner will change to root if root makes a change.
That isn't too much of an issue when the files have mode 0644.  However,
it will become a much bigger issue when the files have mode 0600,
especially because existing files with mode 0644 would also get changed
to have mode 0600.

In preparation for this, start preserving the previous owner and mode of
policy and protector files when they are updated.

3 years agoMake all new metadata files owned by user when needed
Eric Biggers [Wed, 23 Feb 2022 20:35:04 +0000 (12:35 -0800)]
Make all new metadata files owned by user when needed

Since commit 4c7c6631cc5a ("Set owner of login protectors to correct
user"), login protectors are made owned by the user when root creates
one on a user's behalf.  That's good, but the same isn't true of other
files that get created at the same time:

- The policy protecting the directory
- The protector link file, if the policy is on a different filesystem
- The recovery protector, if the policy is on a different filesystem
- The recovery instructions file

In preparation for setting all metadata files to mode 0600, start making
all these files owned by the user in this scenario as well.

3 years agoExtend ownership validation to entire directory structure
Eric Biggers [Wed, 23 Feb 2022 20:35:04 +0000 (12:35 -0800)]
Extend ownership validation to entire directory structure

A previous commit extended file ownership validation to policy and
protector files (by default -- there's an opt-out in /etc/fscrypt.conf).

However, that didn't apply to the parent directories:

MOUNTPOINT
MOUNTPOINT/.fscrypt
MOUNTPOINT/.fscrypt/policies
MOUNTPOINT/.fscrypt/protectors

The problem is that if the parent directories aren't trusted (owned by
another non-root user), then untrusted changes to their contents can be
made at any time, including the introduction of symlinks and so on.

While it's debatable how much of a problem this really is, given the
other validations that are done, it seems to be appropriate to validate
the parent directories too.

Therefore, this commit applies the same ownership validations to the
above four directories as are done on the metadata files themselves.

In addition, it is validated that none of these directories are symlinks
except for ".fscrypt" where this is explicitly supported.

3 years agoStrictly validate metadata file ownership by default
Eric Biggers [Wed, 23 Feb 2022 20:35:04 +0000 (12:35 -0800)]
Strictly validate metadata file ownership by default

The metadata validation checks introduced by the previous commits are
good, but to reduce the attack surface it would be much better to avoid
reading and parsing files owned by other users in the first place.

There are some possible use cases for users sharing fscrypt metadata
files, but I think that for the vast majority of users it is unneeded
and just opens up attack surface.  Thus, make fscrypt (and pam_fscrypt)
not process policies or protectors owned by other users by default.
Specifically,

   * If fscrypt or pam_fscrypt is running as a non-root user, only
     policies and protectors owned by the user or by root can be used.

   * If fscrypt is running as root, any policy or protector can be used.
     (This is to match user expectations -- starting a sudo session
     should gain rights, not remove rights.)

   * If pam_fscrypt is running as root, only policies and protectors
     owned by root can be used.  Note that this only applies when the
     root user themselves has an fscrypt login protector, which is rare.

Add an option 'allow_cross_user_metadata' to /etc/fscrypt.conf which
allows restoring the old behavior for anyone who really needs it.

3 years agoMake 'fscrypt setup' offer a choice of directory modes
Eric Biggers [Wed, 23 Feb 2022 20:35:04 +0000 (12:35 -0800)]
Make 'fscrypt setup' offer a choice of directory modes

World-writable directories are not appropriate for some systems, so
offer a choice of single-user-writable and world-writable modes, with
single-user-writable being the default.  Add a new documentation section
to help users decide which one to use.

3 years agofilesystem: fall back to non-atomic overwrites when required
Eric Biggers [Wed, 23 Feb 2022 20:35:04 +0000 (12:35 -0800)]
filesystem: fall back to non-atomic overwrites when required

To allow users to update fscrypt metadata they own in
single-user-writable metadata directories (introduced by the next
commit), fall back to non-atomic overwrites when atomic ones can't be
done due to not having write access to the directory.

3 years agofilesystem: reject spoofed login protectors
Eric Biggers [Wed, 23 Feb 2022 20:35:04 +0000 (12:35 -0800)]
filesystem: reject spoofed login protectors

If a login protector contains a UID that differs from the file owner
(and the file owner is not root), it might be a spoofed file that was
created maliciously, so make sure to consider such files to be invalid.

3 years agofilesystem: validate size and type of metadata files
Eric Biggers [Wed, 23 Feb 2022 20:35:04 +0000 (12:35 -0800)]
filesystem: validate size and type of metadata files

Don't allow reading metadata files that are very large, as they can
crash the program due to the memory required.  Similarly, don't allow
reading metadata files that aren't regular files, such as FIFOs, or
symlinks (which could point to a device node like /dev/zero), as that
can hang the program.  Both issues were particularly problematic for
pam_fscrypt, as they could prevent users from being able to log in.

Note: these checks are arguably unneeded if we strictly check the file
ownership too, which a later commit will do.  But there's no reason not
to do these basic checks too.

3 years agobash_completion: fix command injection and incorrect completions
Eric Biggers [Wed, 23 Feb 2022 20:35:04 +0000 (12:35 -0800)]
bash_completion: fix command injection and incorrect completions

Mountpoint paths might be untrusted arbitrary strings; the fscrypt bash
completion script might need to complete to such strings.
Unfortunately, the design of bash completion places some major footguns
in the way of doing this correctly and securely:

   - "compgen -W" expands anything passed to it, so the argument to -W
     must be single-quoted to avoid an extra level of expansion.

   - The backslashes needed to escape meta-characters in the completed
     text aren't added automatically; they must be explicitly added.

Note that the completion script for 'umount' used to have these same
bugs (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=892179,
https://github.com/util-linux/util-linux/issues/539).

Fix these bugs in roughly the same way that 'umount' fixed them.

3 years agoMake the output of 'fscrypt status' unambiguous
Eric Biggers [Wed, 23 Feb 2022 20:35:04 +0000 (12:35 -0800)]
Make the output of 'fscrypt status' unambiguous

Following the example of /proc/self/mountinfo, replace the space,
newline, tab, and backslash characters with octal escape sequences so
that the output can be parsed unambiguously.

3 years agoMerge pull request #345 from google/contributing
Joseph Richey [Sat, 12 Feb 2022 02:06:29 +0000 (18:06 -0800)]
Merge pull request #345 from google/contributing

CONTRIBUTING: update maintainers list

3 years agoCONTRIBUTING: update maintainers list
Eric Biggers [Sat, 12 Feb 2022 01:32:28 +0000 (17:32 -0800)]
CONTRIBUTING: update maintainers list

3 years agov0.3.2
Eric Biggers [Sun, 6 Feb 2022 18:33:01 +0000 (10:33 -0800)]
v0.3.2

3 years agofilesystem: remove an outdated comment
Eric Biggers [Sun, 6 Feb 2022 18:32:34 +0000 (10:32 -0800)]
filesystem: remove an outdated comment

3 years agoMerge pull request #340 from google/fix-btrfs
Eric Biggers [Thu, 27 Jan 2022 07:29:51 +0000 (23:29 -0800)]
Merge pull request #340 from google/fix-btrfs

Allow the root directory to be a btrfs filesystem

3 years agofilesystem: fall back to path-only links if UUID cannot be determined
Eric Biggers [Wed, 19 Jan 2022 07:43:35 +0000 (23:43 -0800)]
filesystem: fall back to path-only links if UUID cannot be determined

This is needed to allow creating protector links to btrfs filesystems.

Update https://github.com/google/fscrypt/issues/339

3 years agofilesystem: make FindMount() fall back to search by path
Eric Biggers [Wed, 19 Jan 2022 07:43:35 +0000 (23:43 -0800)]
filesystem: make FindMount() fall back to search by path

This is needed to make FindMount() work on btrfs filesystems.

Update https://github.com/google/fscrypt/issues/339

3 years agofilesystem: add back canonicalizePath()
Eric Biggers [Wed, 19 Jan 2022 07:43:35 +0000 (23:43 -0800)]
filesystem: add back canonicalizePath()

Restore the canonicalizePath() function from before commit
f2eb79fb5fb10275c014b55c13e28ff02d3b70a8, since it's needed again.

Update https://github.com/google/fscrypt/issues/339

3 years agofilesystem: add back the mountsByPath map
Eric Biggers [Wed, 19 Jan 2022 07:43:35 +0000 (23:43 -0800)]
filesystem: add back the mountsByPath map

Add back the mountsByPath map, which indexes all Mounts by mountpoint.
This is needed again.

To avoid confusion, also rename two local variables named mountsByPath.

mountsByPath won't contain nil entries, so also make AllFilesystems()
use it instead of mountsByDevice.  This shouldn't change its behavior.

Update https://github.com/google/fscrypt/issues/339

3 years agoMerge pull request #341 from google/fix-test
Eric Biggers [Wed, 19 Jan 2022 19:11:53 +0000 (11:11 -0800)]
Merge pull request #341 from google/fix-test

cli-tests: fix broken test

3 years agocli-tests: fix broken test
Eric Biggers [Wed, 19 Jan 2022 19:07:00 +0000 (11:07 -0800)]
cli-tests: fix broken test

I'm not sure how this passed the GitHub checks.

3 years agoMerge pull request #337 from google/broken-links
Eric Biggers [Wed, 19 Jan 2022 05:11:01 +0000 (21:11 -0800)]
Merge pull request #337 from google/broken-links

filesystem: store mountpoint in link files as a fallback

3 years agoMerge pull request #338 from google/remove-protector-from-policy
Eric Biggers [Wed, 19 Jan 2022 05:03:51 +0000 (21:03 -0800)]
Merge pull request #338 from google/remove-protector-from-policy

cmd/fscrypt: don't load protector in remove-protector-from-policy

3 years agocmd/fscrypt: don't load protector in remove-protector-from-policy
Eric Biggers [Thu, 23 Dec 2021 17:39:08 +0000 (11:39 -0600)]
cmd/fscrypt: don't load protector in remove-protector-from-policy

Make remove-protector-from-policy work even if the protector cannot be
loaded (for example, due to having been deleted already).

Fixes https://github.com/google/fscrypt/issues/258
Fixes https://github.com/google/fscrypt/issues/272

3 years agocli-tests: add helper functions to get protector descriptors
Eric Biggers [Thu, 23 Dec 2021 17:39:08 +0000 (11:39 -0600)]
cli-tests: add helper functions to get protector descriptors

3 years agofilesystem: store mountpoint in link files as a fallback
Eric Biggers [Thu, 23 Dec 2021 04:46:16 +0000 (22:46 -0600)]
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

3 years agoMerge pull request #336 from google/test-fix
Eric Biggers [Thu, 23 Dec 2021 02:45:23 +0000 (20:45 -0600)]
Merge pull request #336 from google/test-fix

context_text: remove pre-existing test.conf

3 years agocontext_text: remove pre-existing test.conf
Eric Biggers [Thu, 23 Dec 2021 02:36:28 +0000 (20:36 -0600)]
context_text: remove pre-existing test.conf

This fixes a test failure in the case where test.conf gets left over.

3 years agoMerge pull request #335 from google/fix-typos
Eric Biggers [Wed, 22 Dec 2021 05:29:41 +0000 (23:29 -0600)]
Merge pull request #335 from google/fix-typos

Fix a few typos

3 years agoFix a few typos
Eric Biggers [Wed, 22 Dec 2021 04:59:58 +0000 (22:59 -0600)]
Fix a few typos

3 years agoMerge pull request #334 from ebiggers/warn-on-chauthtok-fail
Eric Biggers [Wed, 22 Dec 2021 03:59:01 +0000 (21:59 -0600)]
Merge pull request #334 from ebiggers/warn-on-chauthtok-fail

pam_fscrypt: warn user if OLDAUTHTOK not given in chauthtok

3 years agopam_fscrypt: warn user if OLDAUTHTOK not given in chauthtok
Eric Biggers [Wed, 22 Dec 2021 02:38:03 +0000 (20:38 -0600)]
pam_fscrypt: warn user if OLDAUTHTOK not given in chauthtok

If someone runs 'passwd USER' as root, the user is assigned a new login
passphrase without their fscrypt login protector being updated.  Detect
this case and show a warning message using pam_info().

Fixes https://github.com/google/fscrypt/issues/273

3 years agoMerge pull request #333 from ebiggers/doc-encryption-solutions
Eric Biggers [Wed, 22 Dec 2021 03:21:34 +0000 (21:21 -0600)]
Merge pull request #333 from ebiggers/doc-encryption-solutions

README: elaborate on alternatives and threat model

3 years agoREADME: elaborate on alternatives and threat model
Eric Biggers [Wed, 22 Dec 2021 00:03:08 +0000 (18:03 -0600)]
README: elaborate on alternatives and threat model

Fixes https://github.com/google/fscrypt/issues/318

3 years agoREADME: write "Linux native filesystem encryption"
Eric Biggers [Wed, 22 Dec 2021 00:03:08 +0000 (18:03 -0600)]
README: write "Linux native filesystem encryption"

"Linux filesystem encryption" sounds too vague.  Write "Linux native
filesystem encryption" instead.

3 years agoMerge pull request #332 from ebiggers/skip-irrelevant-filesystems
Eric Biggers [Mon, 20 Dec 2021 17:28:26 +0000 (11:28 -0600)]
Merge pull request #332 from ebiggers/skip-irrelevant-filesystems

filesystem: avoid accessing irrelevant filesystems

3 years agofilesystem: avoid accessing irrelevant filesystems
Eric Biggers [Mon, 20 Dec 2021 04:17:20 +0000 (22:17 -0600)]
filesystem: avoid accessing irrelevant filesystems

Forbid 'fscrypt setup' on filesystems that aren't expected to support
encryption (other than the root filesystem), and skip looking for
fscrypt metadata directories on such filesystems.  This has two
benefits.  First, it avoids the printing of annoying warnings like:

pam_fscrypt[75038]: stat /run/user/0/.fscrypt: permission denied
pam_fscrypt[75038]: stat /run/user/0/.fscrypt/policies: permission denied
pam_fscrypt[75038]: stat /run/user/0/.fscrypt/protectors: permission denied
pam_fscrypt[75038]: stat /sys/firmware/efi/efivars/.fscrypt: invalid argument
pam_fscrypt[75038]: stat /sys/firmware/efi/efivars/.fscrypt/policies: invalid argument
pam_fscrypt[75038]: stat /sys/firmware/efi/efivars/.fscrypt/protectors: invalid argument
pam_fscrypt[75038]: stat /sys/fs/pstore/.fscrypt: permission denied
pam_fscrypt[75038]: stat /sys/fs/pstore/.fscrypt/policies: permission denied
pam_fscrypt[75038]: stat /sys/fs/pstore/.fscrypt/protectors: permission denied

Second, it avoids long delays or side effects on some filesystems.

To do this, introduce an allowlist of filesystem types that fscrypt will
recognize.  I wanted to avoid doing this, since this list will need to
be updated in the future, but I don't see a better solution.

3 years agoMerge pull request #331 from ebiggers/login-protector-perms
Eric Biggers [Mon, 20 Dec 2021 15:54:40 +0000 (09:54 -0600)]
Merge pull request #331 from ebiggers/login-protector-perms

Set owner of login protectors to correct user

3 years agoMerge pull request #329 from ebiggers/doc-ssh-issue
Eric Biggers [Mon, 20 Dec 2021 15:41:55 +0000 (09:41 -0600)]
Merge pull request #329 from ebiggers/doc-ssh-issue

README: document issue with ssh ChallengeResponseAuthentication

3 years agoMerge pull request #330 from google/avoid-warning
Eric Biggers [Mon, 20 Dec 2021 15:40:35 +0000 (09:40 -0600)]
Merge pull request #330 from google/avoid-warning

pam: avoid compiler warning in copyIntoSecret()

3 years agoSet owner of login protectors to correct user
Eric Biggers [Mon, 20 Dec 2021 03:19:25 +0000 (21:19 -0600)]
Set owner of login protectors to correct user

When the root user creates a login protector for a non-root user, make
sure to chown() the protector file to make it owned by the user.
Without this, the protector cannot be updated by the user, which causes
it to get out of sync if the user changes their login passphrase.

Fixes https://github.com/google/fscrypt/issues/319

3 years agopam: avoid compiler warning in copyIntoSecret()
Eric Biggers [Mon, 20 Dec 2021 03:20:54 +0000 (21:20 -0600)]
pam: avoid compiler warning in copyIntoSecret()

gcc 11 enabled -Wmaybe-uninitialized by default.  It causes a
false-positive warning in copyIntoSecret() because gcc doesn't
understand that mlock() is special and doesn't read from the memory.

Just initialize the memory to avoid this warning.

3 years agoREADME: document issue with ssh ChallengeResponseAuthentication
Eric Biggers [Mon, 20 Dec 2021 02:39:26 +0000 (20:39 -0600)]
README: document issue with ssh ChallengeResponseAuthentication

Update https://github.com/google/fscrypt/issues/321
Update https://github.com/google/fscrypt/issues/324

3 years agoMerge pull request #326 from dimitry-ishenko/stdin
Eric Biggers [Tue, 30 Nov 2021 03:51:38 +0000 (19:51 -0800)]
Merge pull request #326 from dimitry-ishenko/stdin

cmd/fscrypt: read key from stdin in non-interactive shell

3 years agocmd/fscrypt: read key from stdin
Dimitry Ishenko [Tue, 30 Nov 2021 01:25:56 +0000 (20:25 -0500)]
cmd/fscrypt: read key from stdin

Fixes #123

3 years agoRelease version v0.3.1
Eric Biggers [Mon, 18 Oct 2021 18:19:17 +0000 (11:19 -0700)]
Release version v0.3.1

3 years agoAdjust recovery passphrase generation
Eric Biggers [Tue, 14 Sep 2021 21:12:39 +0000 (14:12 -0700)]
Adjust recovery passphrase generation

As per the feedback at https://github.com/google/fscrypt/issues/115
where users didn't understand that the recovery passphrase is important,
restore the original behavior where recovery passphrase generation
happens automatically without a prompt.  This applies to the case where
'fscrypt encrypt' is using a login protector on a non-root filesystem.

However, leave the --no-recovery option so that the recovery passphrase
can still be disabled if the user really wants to.  Also, clarify the
information provided about the recovery passphrase.

Update https://github.com/google/fscrypt/issues/115

4 years agoMerge pull request #317 from ebiggers/readme-symlink-bug
Joseph Richey [Wed, 22 Sep 2021 19:24:19 +0000 (12:24 -0700)]
Merge pull request #317 from ebiggers/readme-symlink-bug

README: mention LTS kernel versions with symlink bug fix

4 years agoREADME: mention LTS kernel versions with symlink bug fix
Eric Biggers [Wed, 22 Sep 2021 18:00:27 +0000 (11:00 -0700)]
README: mention LTS kernel versions with symlink bug fix

Resolves https://github.com/google/fscrypt/issues/305

4 years agocmd/fscrypt: recognize no-key names containing hyphen
Eric Biggers [Tue, 14 Sep 2021 21:37:46 +0000 (14:37 -0700)]
cmd/fscrypt: recognize no-key names containing hyphen

In Linux 5.15, the no-key name format is changing again; see
https://git.kernel.org/linus/ba47b515f5940603.  isPossibleNoKeyName()
sometimes doesn't recognize the new no-key names.  Update it accordingly
to recognize all possible no-key names.

Note: isPossibleNoKeyName() is only used as a heuristic to check whether
a v1-encrypted directory is incompletely locked or not.  Therefore, it's
not too important whether it works.  However, this change is needed for
cli-tests/t_v1_policy to pass.

4 years agocli-tests/common.sh: remove argument count checks
Eric Biggers [Tue, 14 Sep 2021 21:27:59 +0000 (14:27 -0700)]
cli-tests/common.sh: remove argument count checks

These confuse the latest version of shellcheck into thinking that
functions which take no arguments actually take arguments, which
triggers a bunch of warnings like "Use func "$@" if function's $1 should
mean script's $1", which causes 'make lint' to fail.  These checks
aren't too useful, so just remove them.

4 years agoREADME: clarify how restoring /.fscrypt directory works
Eric Biggers [Tue, 14 Sep 2021 18:07:42 +0000 (11:07 -0700)]
README: clarify how restoring /.fscrypt directory works

Update https://github.com/google/fscrypt/issues/115

4 years agoMerge pull request #310 from ebiggers/readme-updates
Joseph Richey [Tue, 14 Sep 2021 03:16:07 +0000 (20:16 -0700)]
Merge pull request #310 from ebiggers/readme-updates

Readme updates

4 years agoREADME: add section about encrypting existing files
Eric Biggers [Mon, 13 Sep 2021 23:23:50 +0000 (16:23 -0700)]
README: add section about encrypting existing files

4 years agoREADME: consistently format section titles
Eric Biggers [Mon, 13 Sep 2021 21:45:34 +0000 (14:45 -0700)]
README: consistently format section titles

Capitalize the first word only, and don't use periods.

4 years agoREADME: add section about backup, restore, and recovery
Eric Biggers [Mon, 13 Sep 2021 19:40:14 +0000 (12:40 -0700)]
README: add section about backup, restore, and recovery

Resolves https://github.com/google/fscrypt/issues/51
Resolves https://github.com/google/fscrypt/issues/115

4 years agoREADME: remove note about stability
Eric Biggers [Mon, 13 Sep 2021 19:40:14 +0000 (12:40 -0700)]
README: remove note about stability

A lot of people are already using fscrypt, so in practice we haven't
been breaking backwards compatibility and aren't going to.  Just remove
the scary-sounding "Note about stability".