* [PATCH] fscrypt: Clean up outdated and incorrect comments
@ 2026-12-04 8:48 Eric Biggers
0 siblings, 0 replies; only message in thread
From: Eric Biggers @ 2026-12-04 8:48 UTC (permalink / raw)
To: linux-fscrypt; +Cc: Eric Biggers
Clean up a lot of comments that aren't worth their own commits:
- Fix outdated comments:
- inode::i_ino is no longer 'unsigned long'
- fscrypt_get_encryption_info() is no longer exported
- fscrypt_initialize() no longer allocates multiple buffers
- fscrypt_encrypt_pagecache_blocks() is no longer used with bios
- blk-crypto is now used for all block-based filesystems, not just
for inline encryption
- fscrypt_verify_key_added() no longer returns arbitrary errno codes
- FSCRYPT_CRYPTOAPI_MASK is no longer passed to multiple functions
- Folios now exist, and various things are now folios, not pages
- Prepared keys can now be blk-crypto keys, not just "tfms"
- Remove some remaining mentions of a file's own name.
- Remove file-level change notes. They're redundant with git, they're
very outdated and incomplete, they convey very little information, and
many of the notes were on the wrong files or referred to removed code.
- Remove vague notes about there not having been a "rigorous security
audit". This code and the cryptography used have been extensively
reviewed by now. It's not clear what the notes had in mind.
- Remove the vague and misplaced AES-XTS standards note from crypto.c.
- Fix inaccurate descriptions and references (@ci->ci_policy.flags,
fscrypt_prepare_link(), ->descriptor / ->identifier, HKDF context
byte placement, and ->set_context() locking).
- Move kernel-doc Return: sections to the end of their comments.
- Fix various typos, grammar errors, and formatting nits.
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
fs/crypto/block.c | 8 +++---
fs/crypto/crypto.c | 34 ++++++++-----------------
fs/crypto/fname.c | 9 ++-----
fs/crypto/fscrypt_private.h | 26 ++++++++-----------
fs/crypto/hooks.c | 2 --
fs/crypto/keyring.c | 24 ++++++++++--------
fs/crypto/keysetup.c | 13 +++++-----
fs/crypto/keysetup_v1.c | 4 +--
fs/crypto/policy.c | 30 +++++++++-------------
include/linux/fscrypt.h | 50 +++++++++++++++++--------------------
10 files changed, 85 insertions(+), 115 deletions(-)
diff --git a/fs/crypto/block.c b/fs/crypto/block.c
index 5193f8ba3ee09..65a68e9c36d24 100644
--- a/fs/crypto/block.c
+++ b/fs/crypto/block.c
@@ -209,7 +209,7 @@ static void fscrypt_generate_dun(const struct fscrypt_inode_info *ci,
}
/**
- * fscrypt_set_bio_crypt_ctx() - prepare a file contents bio for inline crypto
+ * fscrypt_set_bio_crypt_ctx() - prepare a file contents bio for en/decryption
* @bio: a bio which will eventually be submitted to the file
* @inode: the file's inode
* @pos: the first file position (in bytes) in the I/O
@@ -219,7 +219,7 @@ static void fscrypt_generate_dun(const struct fscrypt_inode_info *ci,
* If the contents of the file should be encrypted (or decrypted), then assign
* the appropriate encryption context to the bio.
*
- * Normally the bio should be newly allocated (i.e. no pages added yet), as
+ * Normally the bio should be newly allocated (i.e. no data added yet), as
* otherwise fscrypt_mergeable_bio() won't work as intended.
*
* The encryption context will be freed automatically when the bio is freed.
@@ -289,7 +289,7 @@ EXPORT_SYMBOL_GPL(fscrypt_mergeable_bio);
/**
* fscrypt_limit_io_blocks() - limit I/O blocks to avoid discontiguous DUNs
* @inode: the file on which I/O is being done
- * @lblk: the block at which the I/O is being started from
+ * @lblk: the block at which the I/O is being started
* @nr_blocks: the number of blocks we want to submit starting at @lblk
*
* Determine the limit to the number of blocks that can be submitted in a bio
@@ -363,7 +363,7 @@ static void fscrypt_zeroout_range_end_io(struct bio *bio)
* ciphertext blocks which decrypt to the all-zeroes block. The blocks must be
* both logically and physically contiguous. It's also assumed that the
* filesystem only uses a single block device, ->s_bdev. @len must be a
- * multiple of the file system logical block size.
+ * multiple of the filesystem logical block size.
*
* Note that since each block uses a different IV, this involves writing a
* different ciphertext to each block; we can't simply reuse the same one.
diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c
index b6a253217a5ac..2bb60c7c4f2a3 100644
--- a/fs/crypto/crypto.c
+++ b/fs/crypto/crypto.c
@@ -4,20 +4,6 @@
*
* Copyright (C) 2015, Google, Inc.
* Copyright (C) 2015, Motorola Mobility
- *
- * Written by Michael Halcrow, 2014.
- *
- * Filename encryption additions
- * Uday Savagaonkar, 2014
- * Encryption policy handling additions
- * Ildar Muslukhov, 2014
- * Add fscrypt_pullback_bio_page()
- * Jaegeuk Kim, 2015.
- *
- * This has not yet undergone a rigorous security audit.
- *
- * The usage of AES-XTS should conform to recommendations in NIST
- * Special Publication 800-38E and IEEE P1619/D16.
*/
#include <crypto/skcipher.h>
@@ -154,7 +140,7 @@ static int fscrypt_crypt_data_unit(const struct fscrypt_inode_info *ci,
* fscrypt_encrypt_pagecache_blocks() - Encrypt data from a pagecache folio
* @folio: the locked pagecache folio containing the data to encrypt
* @len: size of the data to encrypt, in bytes
- * @offs: offset within @page of the data to encrypt, in bytes
+ * @offs: offset within @folio of the data to encrypt, in bytes
* @gfp_flags: memory allocation flags; see details below
*
* This allocates a new bounce page and encrypts the given data into it. The
@@ -163,15 +149,16 @@ static int fscrypt_crypt_data_unit(const struct fscrypt_inode_info *ci,
* the filesystem block size is always a multiple of the data unit size.
*
* In the bounce page, the ciphertext data will be located at the same offset at
- * which the plaintext data was located in the source page. Any other parts of
+ * which the plaintext data was located in the source folio. Any other parts of
* the bounce page will be left uninitialized.
*
* This is for use by the ->writepages() method of non-block-based filesystems.
*
* The bounce page allocation is mempool-backed, so it will always succeed when
* @gfp_flags includes __GFP_DIRECT_RECLAIM, e.g. when it's GFP_NOFS. However,
- * only the first page of each bio can be allocated this way. To prevent
- * deadlocks, for any additional pages a mask like GFP_NOWAIT must be used.
+ * only the first page of each writeback request can be allocated this way. To
+ * prevent deadlocks, for any additional pages a mask like GFP_NOWAIT must be
+ * used.
*
* Return: the new encrypted bounce page on success; an ERR_PTR() on failure
*/
@@ -230,7 +217,7 @@ EXPORT_SYMBOL(fscrypt_encrypt_pagecache_blocks);
* number of the block within the file
*
* Encrypt a possibly-compressed filesystem block that is located in an
- * arbitrary page, not necessarily in the original pagecache page. The @inode
+ * arbitrary page, not necessarily in the original pagecache folio. The @inode
* and @lblk_num must be specified, as they can't be determined from @page.
*
* This function only supports non-block-based filesystems that don't support
@@ -261,7 +248,7 @@ EXPORT_SYMBOL(fscrypt_encrypt_block_inplace);
* number of the block within the file
*
* Decrypt a possibly-compressed filesystem block that is located in an
- * arbitrary page, not necessarily in the original pagecache page. The @inode
+ * arbitrary page, not necessarily in the original pagecache folio. The @inode
* and @lblk_num must be specified, as they can't be determined from @page.
*
* This function only supports non-block-based filesystems that don't support
@@ -282,11 +269,12 @@ int fscrypt_decrypt_block_inplace(const struct inode *inode, struct page *page,
EXPORT_SYMBOL(fscrypt_decrypt_block_inplace);
/**
- * fscrypt_initialize() - allocate major buffers for fs encryption.
+ * fscrypt_initialize() - allocate bounce page pool if needed
* @sb: the filesystem superblock
*
- * We only call this when we start accessing encrypted files, since it
- * results in memory getting allocated that wouldn't otherwise be used.
+ * If the filesystem needs bounce pages, allocate the global bounce page pool if
+ * not already done. We only call this when we start accessing encrypted files,
+ * since it results in memory getting allocated that wouldn't otherwise be used.
*
* Return: 0 on success; -errno on failure
*/
diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c
index 629eb0d72e860..d8c9d442c7fbb 100644
--- a/fs/crypto/fname.c
+++ b/fs/crypto/fname.c
@@ -4,11 +4,6 @@
*
* Copyright (C) 2015, Google, Inc.
* Copyright (C) 2015, Motorola Mobility
- *
- * Written by Uday Savagaonkar, 2014.
- * Modified by Jaegeuk Kim, 2015.
- *
- * This has not yet undergone a rigorous security audit.
*/
#include <crypto/sha2.h>
@@ -190,8 +185,8 @@ bool __fscrypt_fname_encrypted_size(const union fscrypt_policy *policy,
* Filenames that are shorter than the maximum length may have their lengths
* increased slightly by encryption, due to padding that is applied.
*
- * Return: false if the orig_len is greater than max_len. Otherwise, true and
- * fill out encrypted_len_ret with the length (up to max_len).
+ * Return: %false if @orig_len is greater than @max_len. Otherwise, %true and
+ * fill out @encrypted_len_ret with the length (up to @max_len).
*/
bool fscrypt_fname_encrypted_size(const struct inode *inode, u32 orig_len,
u32 max_len, u32 *encrypted_len_ret)
diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h
index e602c31b3844e..544d52ff02f21 100644
--- a/fs/crypto/fscrypt_private.h
+++ b/fs/crypto/fscrypt_private.h
@@ -1,11 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
- * fscrypt_private.h
- *
* Copyright (C) 2015, Google, Inc.
- *
- * Originally written by Michael Halcrow, Ildar Muslukhov, and Uday Savagaonkar.
- * Heavily modified since then.
*/
#ifndef _FSCRYPT_PRIVATE_H
@@ -46,8 +41,8 @@
#undef FSCRYPT_MAX_KEY_SIZE
/*
- * This mask is passed as the third argument to the crypto_alloc_*() functions
- * to prevent fscrypt from using the Crypto API drivers for non-inline crypto
+ * This mask is passed as the third argument to crypto_alloc_sync_skcipher() to
+ * prevent fscrypt from using the Crypto API drivers for non-inline crypto
* engines. Those drivers have been problematic for fscrypt. fscrypt users
* have reported hangs and even incorrect en/decryption with these drivers.
* Since going to the driver, off CPU, and back again is really slow, such
@@ -361,11 +356,11 @@ void fscrypt_init_hkdf(struct hmac_sha512_key *hkdf, const u8 *master_key,
unsigned int master_key_size);
/*
- * The list of contexts in which fscrypt uses HKDF. These values are used as
- * the first byte of the HKDF application-specific info string to guarantee that
- * info strings are never repeated between contexts. This ensures that all HKDF
- * outputs are unique and cryptographically isolated, i.e. knowledge of one
- * output doesn't reveal another.
+ * The list of contexts in which fscrypt uses HKDF. These values are used right
+ * after the "fscrypt\0" prefix of the HKDF application-specific info string to
+ * guarantee that info strings are never repeated between contexts. This
+ * ensures that all HKDF outputs are unique and cryptographically isolated, i.e.
+ * knowledge of one output doesn't reveal another.
*/
#define HKDF_CONTEXT_KEY_IDENTIFIER_FOR_RAW_KEY 1 /* info=<empty> */
#define HKDF_CONTEXT_PER_FILE_ENC_KEY 2 /* info=file_nonce */
@@ -567,9 +562,10 @@ struct fscrypt_master_key {
/*
* For v1 policy keys: an arbitrary key descriptor which was assigned by
- * userspace (->descriptor).
+ * userspace (->u.descriptor).
*
- * For v2 policy keys: a cryptographic hash of this key (->identifier).
+ * For v2 policy keys: a cryptographic hash of this key
+ * (->u.identifier).
*/
struct fscrypt_key_specifier mk_spec;
@@ -596,7 +592,7 @@ struct fscrypt_master_key {
/*
* A list of 'struct fscrypt_mode_key' for the (hkdf_context, mode_num,
- * data_unit_bits, inlinecrypt) combinations that are in use for this
+ * data_unit_bits, blk_crypto) combinations that are in use for this
* master key, for hkdf_context in [HKDF_CONTEXT_DIRECT_KEY,
* HKDF_CONTEXT_IV_INO_LBLK_32_KEY, HKDF_CONTEXT_IV_INO_LBLK_64_KEY].
*
diff --git a/fs/crypto/hooks.c b/fs/crypto/hooks.c
index 149498bdab94e..6f73cc091786b 100644
--- a/fs/crypto/hooks.c
+++ b/fs/crypto/hooks.c
@@ -1,7 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
- * fs/crypto/hooks.c
- *
* Encryption hooks for higher-level filesystem operations.
*/
diff --git a/fs/crypto/keyring.c b/fs/crypto/keyring.c
index 09364fddcb7a1..37365fa1abf85 100644
--- a/fs/crypto/keyring.c
+++ b/fs/crypto/keyring.c
@@ -669,13 +669,13 @@ static struct key_type key_type_fscrypt_provisioning = {
* it into 'secret'.
*
* The key must be of type "fscrypt-provisioning" and must have the 'type' and
- * 'flags' field of the payload set to the given values, indicating that the key
- * is intended for use for the specified purpose. We don't use the "logon" key
- * type because there's no way to completely restrict the use of such keys; they
- * can be used by any kernel API that accepts "logon" keys and doesn't require a
- * specific service prefix.
+ * 'flags' fields of the payload set to the given values, indicating that the
+ * key is intended for use for the specified purpose. We don't use the "logon"
+ * key type because there's no way to completely restrict the use of such keys;
+ * they can be used by any kernel API that accepts "logon" keys and doesn't
+ * require a specific service prefix.
*
- * The ability to specify the key via Linux keyring key is intended for cases
+ * The ability to specify the key via a Linux keyring key is intended for cases
* where userspace needs to re-add keys after the filesystem is unmounted and
* re-mounted. Most users should just provide the key directly instead.
*/
@@ -869,10 +869,10 @@ int fscrypt_add_test_dummy_key(struct super_block *sb,
* enough for any use cases where encryption policies are being set using keys
* that were chosen ahead of time but aren't available at the moment.
*
- * Note that the key may have already removed by the time this returns, but
- * that's okay; we just care whether the key was there at some point.
+ * Note that the key may have already been removed by the time this returns,
+ * but that's okay; we just care whether the key was there at some point.
*
- * Return: 0 if the key is added, -ENOKEY if it isn't, or another -errno code
+ * Return: 0 if the key is added, or -ENOKEY if it isn't
*/
int fscrypt_verify_key_added(struct super_block *sb,
const u8 identifier[FSCRYPT_KEY_IDENTIFIER_SIZE])
@@ -998,7 +998,7 @@ static int try_to_lock_encrypted_files(struct super_block *sb,
int err2;
/*
- * An inode can't be evicted while it is dirty or has dirty pages.
+ * An inode can't be evicted while it is dirty or has dirty folios.
* Thus, we first have to clean the inodes in ->mk_decrypted_inodes.
*
* Just do it the easy way: call sync_filesystem(). It's overkill, but
@@ -1084,7 +1084,9 @@ static int do_remove_key(struct file *filp, void __user *_uarg, bool all_users)
return -ENOKEY;
down_write(&mk->mk_sem);
- /* If relevant, remove current user's (or all users) claim to the key */
+ /*
+ * If relevant, remove current user's (or all users') claim to the key.
+ */
if (!list_empty(&mk->mk_users)) {
if (all_users) {
clear_mk_users(mk);
diff --git a/fs/crypto/keysetup.c b/fs/crypto/keysetup.c
index 0beec01c04185..1b64eb12ea3e4 100644
--- a/fs/crypto/keysetup.c
+++ b/fs/crypto/keysetup.c
@@ -3,9 +3,6 @@
* Key setup facility for FS encryption support.
*
* Copyright (C) 2015, Google, Inc.
- *
- * Originally written by Michael Halcrow, Ildar Muslukhov, and Uday Savagaonkar.
- * Heavily modified since then.
*/
#include <crypto/skcipher.h>
@@ -146,7 +143,8 @@ fscrypt_allocate_skcipher(struct fscrypt_mode *mode, const u8 *raw_key,
* Prepare the crypto transform object or blk-crypto key in @prep_key, given the
* raw key, encryption mode (@ci->ci_mode), predicate indicating which style of
* key is needed (fscrypt_using_inline_encryption(ci)), IV generation method
- * (@ci->ci_policy.flags), and data unit size (@ci->ci_data_unit_bits).
+ * (fscrypt_policy_flags(&ci->ci_policy)), and data unit size
+ * (@ci->ci_data_unit_bits).
*/
int fscrypt_prepare_key(struct fscrypt_prepared_key *prep_key,
const u8 *raw_key, const struct fscrypt_inode_info *ci)
@@ -174,7 +172,10 @@ void fscrypt_destroy_prepared_key(struct super_block *sb,
memzero_explicit(prep_key, sizeof(*prep_key));
}
-/* Given a per-file encryption key, set up the file's crypto transform object */
+/*
+ * Given a per-file encryption key, set up the file's crypto transform object or
+ * blk-crypto key.
+ */
int fscrypt_set_per_file_enc_key(struct fscrypt_inode_info *ci,
const u8 *raw_key)
{
@@ -184,7 +185,7 @@ int fscrypt_set_per_file_enc_key(struct fscrypt_inode_info *ci,
/*
* Find the fscrypt_prepared_key (if any) for a particular (mk, hkdf_context,
- * mode_num, data_unit_bits, inlinecrypt) combination.
+ * mode_num, data_unit_bits, blk_crypto) combination.
*
* The caller must hold ->mk_sem for reading and ->mk_present must be true,
* ensuring that ->mk_mode_keys is still append-only.
diff --git a/fs/crypto/keysetup_v1.c b/fs/crypto/keysetup_v1.c
index d9ac7c4328f82..4b0d76fa95d05 100644
--- a/fs/crypto/keysetup_v1.c
+++ b/fs/crypto/keysetup_v1.c
@@ -158,7 +158,7 @@ find_or_insert_direct_key(struct fscrypt_direct_key *to_insert,
continue;
/*
* Use an existing prepared key with the same (descriptor, sb,
- * mode, inlinecrypt, raw_key) combination.
+ * mode, blk_crypto, raw_key) combination.
*/
refcount_inc(&dk->dk_refcount);
spin_unlock(&fscrypt_direct_keys_lock);
@@ -178,7 +178,7 @@ fscrypt_get_direct_key(const struct fscrypt_inode_info *ci, const u8 *raw_key)
struct fscrypt_direct_key *dk;
int err;
- /* Is there already a tfm for this key? */
+ /* Is there already a prepared key for this? */
dk = find_or_insert_direct_key(NULL, raw_key, ci);
if (dk)
return dk;
diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
index 86a8254bc3a87..f7536dd851553 100644
--- a/fs/crypto/policy.c
+++ b/fs/crypto/policy.c
@@ -4,10 +4,6 @@
*
* Copyright (C) 2015, Google, Inc.
* Copyright (C) 2015, Motorola Mobility.
- *
- * Originally written by Michael Halcrow, 2015.
- * Modified by Jaegeuk Kim, 2015.
- * Modified by Eric Biggers, 2019 for v2 policy support.
*/
#include <linux/export.h>
@@ -154,10 +150,9 @@ static bool supported_iv_ino_lblk_policy(const struct fscrypt_policy_v2 *policy,
/*
* IV_INO_LBLK_64 and IV_INO_LBLK_32 both require that inode numbers fit
- * in 32 bits. In principle, IV_INO_LBLK_32 could support longer inode
- * numbers because it hashes the inode number; however, currently the
- * inode number is gotten from inode::i_ino which is 'unsigned long'.
- * So for now the implementation limit is 32 bits.
+ * in 32 bits. (In principle, IV_INO_LBLK_32 could support longer inode
+ * numbers because it hashes the inode number. For now, it uses the
+ * same limit as IV_INO_LBLK_64 for simplicity.)
*/
if (!sb->s_cop->has_32bit_inodes) {
fscrypt_warn(inode,
@@ -179,7 +174,7 @@ static bool supported_iv_ino_lblk_policy(const struct fscrypt_policy_v2 *policy,
}
/*
- * IV_INO_LBLK_32 isn't compatible with inline encryption when
+ * IV_INO_LBLK_32 isn't compatible with blk-crypto when
* s_blocksize != PAGE_SIZE. In that case the DUN can wrap around in
* the middle of a page, but sometimes fscrypt_mergeable_bio() is called
* only for the first block per page. Since IV_INO_LBLK_32 exists only
@@ -280,7 +275,7 @@ static bool fscrypt_supported_v2_policy(const struct fscrypt_policy_v2 *policy,
(policy->flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32)) {
/*
* Not safe to enable yet, as we need to ensure that DUN
- * wraparound can only occur on a FS block boundary.
+ * wraparound can only occur on an FS block boundary.
*/
fscrypt_warn(inode,
"Sub-block data units not yet supported with IV_INO_LBLK_32");
@@ -312,9 +307,9 @@ static bool fscrypt_supported_v2_policy(const struct fscrypt_policy_v2 *policy,
* @inode: the inode on which the policy will be used
*
* Given an encryption policy, check whether all its encryption modes and other
- * settings are supported by this kernel on the given inode. (But we don't
- * currently don't check for crypto API support here, so attempting to use an
- * algorithm not configured into the crypto API will still fail later.)
+ * settings are supported by this kernel on the given inode. (But we currently
+ * don't check for crypto API or blk-crypto support here, so attempting to use
+ * an algorithm not configured into the kernel will still fail later.)
*
* Return: %true if supported, else %false
*/
@@ -394,11 +389,11 @@ static int fscrypt_new_context(union fscrypt_context *ctx_u,
*
* Given an fscrypt_context, build the corresponding fscrypt_policy.
*
- * Return: 0 on success, or -EINVAL if the fscrypt_context has an unrecognized
- * version number or size.
- *
* This does *not* validate the settings within the policy itself, e.g. the
* modes, flags, and reserved bits. Use fscrypt_supported_policy() for that.
+ *
+ * Return: 0 on success, or -EINVAL if the fscrypt_context has an unrecognized
+ * version number or size.
*/
int fscrypt_policy_from_context(union fscrypt_policy *policy_u,
const union fscrypt_context *ctx_u,
@@ -646,7 +641,6 @@ EXPORT_SYMBOL_GPL(fscrypt_ioctl_get_nonce);
/**
* fscrypt_has_permitted_context() - is a file's encryption policy permitted
* within its directory?
- *
* @parent: inode for parent directory
* @child: inode for file being looked up, opened, or linked into @parent
*
@@ -690,7 +684,7 @@ int fscrypt_has_permitted_context(struct inode *parent, struct inode *child)
* Performance-wise this is not a big deal because we already don't
* really optimize for file access without the key (to the extent that
* such access is even possible), given that any attempted access
- * already causes a fscrypt_context retrieval and keyring search.
+ * already causes an fscrypt_context retrieval and keyring search.
*
* In any case, if an unexpected error occurs, fall back to "forbidden".
*/
diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h
index beecfd695b559..f6c462e70f01a 100644
--- a/include/linux/fscrypt.h
+++ b/include/linux/fscrypt.h
@@ -1,14 +1,8 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
- * fscrypt.h: declarations for per-file encryption
- *
- * Filesystems that implement per-file encryption must include this header
- * file.
+ * Declarations for per-file encryption
*
* Copyright (C) 2015, Google, Inc.
- *
- * Written by Michael Halcrow, 2015.
- * Modified by Jaegeuk Kim, 2015.
*/
#ifndef _LINUX_FSCRYPT_H
#define _LINUX_FSCRYPT_H
@@ -101,9 +95,9 @@ struct fscrypt_operations {
* size that is less than the filesystem block size. This is done via
* the log2_data_unit_size field of the fscrypt policy. This flag is
* not compatible with filesystems that encrypt variable-length blocks
- * (i.e. blocks that aren't all equal to filesystem's block size), for
- * example as a result of compression. It's also not compatible with
- * the fscrypt_encrypt_block_inplace() and
+ * (i.e. blocks that aren't all equal to the filesystem's block size),
+ * for example as a result of compression. It's also not compatible
+ * with the fscrypt_encrypt_block_inplace() and
* fscrypt_decrypt_block_inplace() functions.
*/
unsigned int supports_subblock_data_units : 1;
@@ -146,7 +140,8 @@ struct fscrypt_operations {
* Otherwise (i.e. when called from
* FS_IOC_SET_ENCRYPTION_POLICY) this will be NULL.
*
- * i_rwsem will be held for write.
+ * When called from FS_IOC_SET_ENCRYPTION_POLICY, i_rwsem will be held
+ * for write.
*
* Return: 0 on success, -errno on failure.
*/
@@ -192,10 +187,10 @@ struct fscrypt_operations {
* This writes the block_device pointers to @devs and returns the count
* (between 1 and FSCRYPT_MAX_DEVICES inclusively).
*
- * If the filesystem can use multiple block devices (other than block
- * devices that aren't used for encrypted file contents, such as
- * external journal devices), and wants to support inline encryption,
- * then it must implement this function. Otherwise it's not needed.
+ * If the filesystem is block-based and can use multiple block devices
+ * (other than block devices that aren't used for encrypted file
+ * contents, such as external journal devices), then it must implement
+ * this function. Otherwise it's not needed.
*/
unsigned int (*get_devices)(
struct super_block *sb,
@@ -250,11 +245,11 @@ fscrypt_get_inode_info(const struct inode *inode)
* contents encryption
* @inode: the inode to check
*
- * Return: %true iff the inode is an encrypted regular file and the kernel was
- * built with fscrypt support.
- *
* If you need to know whether the encrypt bit is set even when the kernel was
* built without fscrypt support, you must use IS_ENCRYPTED() directly instead.
+ *
+ * Return: %true iff the inode is an encrypted regular file and the kernel was
+ * built with fscrypt support.
*/
static inline bool fscrypt_needs_contents_encryption(const struct inode *inode)
{
@@ -323,7 +318,7 @@ static inline void fscrypt_prepare_dentry(struct dentry *dentry,
* This code tries to only take ->d_lock when necessary to write
* to ->d_flags. We shouldn't be peeking on d_flags for
* DCACHE_OP_REVALIDATE unlocked, but in the unlikely case
- * there is a race, the worst it can happen is that we fail to
+ * there is a race, the worst that can happen is that we fail to
* unset DCACHE_OP_REVALIDATE and pay the cost of an extra
* d_revalidate.
*/
@@ -335,8 +330,8 @@ static inline void fscrypt_prepare_dentry(struct dentry *dentry,
dentry->d_op->d_revalidate == fscrypt_d_revalidate) {
/*
* Unencrypted dentries and encrypted dentries where the
- * key is available are always valid from fscrypt
- * perspective. Avoid the cost of calling
+ * key is available are always valid from fscrypt's
+ * perspective. Avoid the cost of calling
* fscrypt_d_revalidate unnecessarily.
*/
spin_lock(&dentry->d_lock);
@@ -654,7 +649,7 @@ static inline int fscrypt_drop_inode(struct inode *inode)
return 0;
}
- /* fname.c */
+/* fname.c */
static inline int fscrypt_setup_filename(struct inode *dir,
const struct qstr *iname,
int lookup, struct fscrypt_name *fname)
@@ -857,10 +852,11 @@ static inline int fscrypt_zeroout_range(const struct inode *inode, loff_t pos,
* fscrypt_has_encryption_key() - check whether an inode has had its key set up
* @inode: the inode to check
*
- * Return: %true if the inode has had its encryption key set up, else %false.
+ * This does not try to set up the key if it isn't already set up; callers
+ * should usually have called an fscrypt_prepare_*() function or
+ * fscrypt_file_open() first.
*
- * Usually this should be preceded by fscrypt_get_encryption_info() to try to
- * set up the key first.
+ * Return: %true if the inode has had its encryption key set up, else %false.
*/
static inline bool fscrypt_has_encryption_key(const struct inode *inode)
{
@@ -929,7 +925,7 @@ static inline int fscrypt_prepare_rename(struct inode *old_dir,
}
/**
- * fscrypt_prepare_lookup() - prepare to lookup a name in a possibly-encrypted
+ * fscrypt_prepare_lookup() - prepare to look up a name in a possibly-encrypted
* directory
* @dir: directory being searched
* @dentry: filename being looked up
@@ -1024,7 +1020,7 @@ static inline int fscrypt_prepare_setattr(struct dentry *dentry,
* If the symlink target needs to be encrypted, then this function encrypts it
* into @disk_link->name. fscrypt_prepare_symlink() must have been called
* previously to compute @disk_link->len. If the filesystem did not allocate a
- * buffer for @disk_link->name after calling fscrypt_prepare_link(), then one
+ * buffer for @disk_link->name after calling fscrypt_prepare_symlink(), then one
* will be kmalloc()'ed and the filesystem will be responsible for freeing it.
*
* Return: 0 on success, -errno on failure
base-commit: 1928c0add8851741d20ad1e7ca41b0426cfb03fc
--
2.56.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-04 8:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-04 8:48 [PATCH] fscrypt: Clean up outdated and incorrect comments Eric Biggers
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.