aboutsummaryrefslogtreecommitdiff
path: root/actions/config.go
AgeCommit message (Collapse)Author
2026-03-26Add support for cgroup limits (#443)Michele Bertasi
* Add cgroup package * Refactor procGgroup * Add testdata generation * Add v1 testdata generation * Move scripts around * Add integration test in CI * Remove cgroup v1 * Move to cgroup struct * Remove half-core test as it's redundant
2022-12-04Only use up to MaxParallelism CPUsJoe Richey
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>
2022-04-08Switch to google.golang.org/protobuf/protoEric Biggers
github.com/golang/protobuf/proto has been deprecated in favor of google.golang.org/protobuf/proto, so migrate to the non-deprecated one.
2021-05-24Run the Garbage Collector in the timing loopJoe Richey
Running `crypto.PassphraseHash` in a loop allocates a lot of memory. Golang is not always prudent about collecting the garbage from previous runs, resulting in a OOM error on memory-pressured systems. With a `maxMemoryBytes` of 128 MiB, this change reduces the maximum resident memory for `fscrypt setup` to 141 MiB (was perviously 405 MiB) Signed-off-by: Joe Richey <joerichey@google.com>
2021-05-24Only use 1/8 of the system RAMJoe Richey
On systems with high memory pressure, using half of the entire RAM for hashing can result in fscrypt getting OOM killed. Signed-off-by: Joe Richey <joerichey@google.com>
2020-05-09actions/config: improve config file related errorsEric Biggers
ErrBadConfig: Fix backwards wrapping, include the bad config, and make it clear that this is an internal error. ErrBadConfigFile: Fix backwards wrapping, include the config file location, and adjust the suggestion slightly. ErrConfigFileExists: Include the config file location. ErrNoConfigFile: Include the config file location, and adjust the suggestion slightly.
2020-03-23Create /etc/fscrypt.conf with policy_version 2 on kernel v5.4+Eric Biggers
v2 encryption policies are now recommended, due to various security and usability advantages over v1 policies. Many people have been running into the usability problems with v1, so it's desirable to get people onto v2 without having to manually opt-in. Therefore, when 'fscrypt setup' creates /etc/fscrypt.conf, enable policy_version 2 automatically if the kernel supports it. I decided to go with this solution over the policy_version "auto" I suggested originally because this way is simpler, it can still be changed to "auto" later if desired, and "auto" might require changing how we parse the config file (since currently the config file is mapped directly to a protobuf where policy_version is an 'int' and is shared with EncryptionOptions). Resolves https://github.com/google/fscrypt/issues/182
2020-03-23Simplify choosing the key description prefixEric Biggers
There's no real need to allow users to choose the key description prefix (a.k.a. the "service"), since on ext4 and f2fs we can just use "ext4" and "f2fs" for compatibility with all kernels both old and new, and on other filesystems we can just use "fscrypt". So, let's do that. Since this removes the point of the "--legacy" option to 'fscrypt setup' and the "compatibility" field in /etc/fscrypt.conf, remove those too. Specifically, we start ignoring the "compatibility" in existing config files and not writing it to new ones. The corresponding protobuf field number and name are reserved. We stop accepting the "--legacy" option at all, although since it was default true and there was no real reason for anyone to change it to false, probably no one will notice. If anyone does, they should just stop specifying the option. Note that this change only affects user keyrings and thus only affects v1 encryption policies, which are deprecated in favor of v2 anyway.
2020-01-05Metadata support for v2 encryption policiesEric Biggers
Linux v5.4 and later supports v2 encryption policies. These have several advantages over v1 encryption policies: - Their encryption keys can be added/removed to/from the filesystem by non-root users, thus gaining the benefits of the filesystem keyring while also retaining support for non-root use. - They use a more standard, secure, and flexible key derivation function. Because of this, some future kernel-level fscrypt features will be implemented for v2 policies only. - They prevent a denial-of-service attack where a user could associate the wrong key with another user's encrypted files. Prepare the fscrypt tool to support v2 encryption policies by: - Adding a policy_version field to the EncryptionOptions, i.e. to the config file and to the policy metadata files. - Using the kernel-specified algorithm to compute the key descriptor for v2 policies. - Handling setting and getting v2 policies. Actually adding/removing the keys for v2 policies to/from the kernel is left for the next patch.
2019-10-23actions/config: ensure config file is created with mode 0644 (#152)ebiggers
If the user has set a restrictive umask, e.g. 0077, then /etc/fscrypt.conf would be created without the world-readable bit set. Fix it by overriding the umask when creating the file. Resolves https://github.com/google/fscrypt/issues/151
2019-09-08Fix various typos and grammatical errors (#141)ebiggers
These were found by a combination of manual review and a custom script that checks for common errors. Also removed an outdated sentence from the comment for setupBefore().
2018-01-10Format files correctlyJoe Richey joerichey@google.com
2018-01-10Limit the amount of RAM that will be usedJoe Richey joerichey@google.com
Fixes #73. Adds maxMemoryBytes as 128MiB and cleans up the helper functions/variables to make it more clear which values are a number of bytes, and which values are a number of KiB.
2017-08-07actions: calculate password hash difficulty correctlyEric Biggers
'fscrypt setup' is supposed to calibrate the Argon2 password hashing difficulty to 1s by default, but actually it was setting it to only 1s / num_cpus because the hashing is done with all CPUs and it is timed using the CLOCK_PROCESS_CPUTIME_ID clock, which measures the time spent by all threads in the process. Fix this by dividing the elapsed time by HashingCosts.Parallelism, which is used as the number of threads.
2017-06-28Finalize import paths and documentationv0.1.00.1.0Joe Richey joerichey@google.com
This commit changes all the internal import paths from `fscrypt/foo` to `github.com/google/fscrypt/foo` so that it can be built once we release externaly. The documentation in README.md is updated accordingly. Also, the README has a note noting that we do not make any guarantees about project stability before 1.0 (when it ships with Ubuntu). Change-Id: I6ba86e442c74057c8a06ba32a42e17f94833e280
2017-06-28actions: error handling and API changedJoe Richey joerichey@google.com
This commit changes the error handling for the actions package to use the error handling library github.com/pkg/errors. This means replacing "errors" with "github.com/pkg/errors", reworking some of the error values, and wrapping some errors with additional context. This commit also changes the Protector/Policy API, moving most of the package functionality into Protector or Policy methods. These types are now "locked" when they are queried from the filesystem, and Unlock() must be used to get their corresponding keys. Note that only certain operations will require unlocking the keys. Certain unnecessary functions and methods are also removed. This CL also fixes two bugs reported by Tyler Hicks in CreateConfigFile. CPU time is used instead of wall time, and kiB is used instead of kB. Change-Id: I88f45659e9fe4938d148843e3289e7b6d5b698d8
2017-06-26actions: Simplify the callback mechanismJoe Richey joerichey@google.com
This commit makes the callbacks for getting keys easier to understand. Functions which need keys now take a KeyFunc callback. This callback contains a ProtectorInfo parameter (basically a read-only version of metadata.ProtectorData) and a boolean which indicates if the call is being retried. The documentation is also updated to say which functions will retry the KeyFunc. For selecting a protector, there is now an OptionFunc callback which takes a slice of ProtectorOptions. A ProtectorOption is a ProtectorInfo along with additional information about a linked filesystem (if applicable). This commit also adds in methods for getting the protector options for a specific filesystem or policy. It also adds a function for getting the policy descriptor for a specific path. Change-Id: I41e0d94ffd44e7166b0c5cf1b5d18437960bdf90
2017-05-31actions: generate a config file for fscryptJoe Richey joerichey@google.com
This commit adds in the actions package. This package will be the highest-level interface to the fscrypt packages. The public functions in this package will be called directly from cmd/fscrypt. The actions added in this commit pertain to creating and reading the fscrypt global config file "fscrypt.conf". The challenging part about creating this file is finding the correct hashing parameters for the desired time target. The getHashingCosts() function finds the desired costs by doubling the costs and running the passphrase hash until the target is exceeded. Then, a cost estimate is obtained using a linear interpolation between the last two costs (and their time results). Change-Id: I4a0eaf4856ec4ff49eb4360da3267f7caa9d07b2