Commit 22e78faf authored by Michael Halcrow's avatar Michael Halcrow Committed by Linus Torvalds

eCryptfs: kerneldoc fixes for crypto.c and keystore.c

Andrew Morton wrote:
From: mhalcrow@us.ibm.com <mhalcrow@halcrow.austin.ibm.com>
> > +/**
> > + * decrypt_passphrase_encrypted_session_key - Decrypt the session key
> > + * with the given auth_tok.
> >   *
> >   * Returns Zero on success; non-zero error otherwise.
> >   */
>
> That comment purports to be a kerneldoc-style comment.  But
>
> - kerneldoc doesn't support multiple lines on the introductory line
>   which identifies the name of the function (alas).  So you'll need to
>   overflow 80 cols here.
>
> - the function args weren't documented
>
> But the return value is!  People regularly forget to do that.  And
> they frequently forget to document the locking prerequisites and the
> permissible calling contexts (process/might_sleep/hardirq, etc)
>
> (please check all ecryptfs kerneldoc for this stuff sometime)

This patch cleans up some of the existing comments and makes a couple
of line break tweaks. There is more work to do to bring eCryptfs into
full kerneldoc-compliance.
Signed-off-by: default avatarMichael Halcrow <mhalcrow@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6c6f57f3
...@@ -722,6 +722,11 @@ int ecryptfs_decrypt_page(struct file *file, struct page *page) ...@@ -722,6 +722,11 @@ int ecryptfs_decrypt_page(struct file *file, struct page *page)
/** /**
* decrypt_scatterlist * decrypt_scatterlist
* @crypt_stat: Cryptographic context
* @dest_sg: The destination scatterlist to decrypt into
* @src_sg: The source scatterlist to decrypt from
* @size: The number of bytes to decrypt
* @iv: The initialization vector to use for the decryption
* *
* Returns the number of bytes decrypted; negative value on error * Returns the number of bytes decrypted; negative value on error
*/ */
...@@ -763,6 +768,13 @@ static int decrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat, ...@@ -763,6 +768,13 @@ static int decrypt_scatterlist(struct ecryptfs_crypt_stat *crypt_stat,
/** /**
* ecryptfs_encrypt_page_offset * ecryptfs_encrypt_page_offset
* @crypt_stat: The cryptographic context
* @dst_page: The page to encrypt into
* @dst_offset: The offset in the page to encrypt into
* @src_page: The page to encrypt from
* @src_offset: The offset in the page to encrypt from
* @size: The number of bytes to encrypt
* @iv: The initialization vector to use for the encryption
* *
* Returns the number of bytes encrypted * Returns the number of bytes encrypted
*/ */
...@@ -785,6 +797,13 @@ ecryptfs_encrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat, ...@@ -785,6 +797,13 @@ ecryptfs_encrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat,
/** /**
* ecryptfs_decrypt_page_offset * ecryptfs_decrypt_page_offset
* @crypt_stat: The cryptographic context
* @dst_page: The page to decrypt into
* @dst_offset: The offset in the page to decrypt into
* @src_page: The page to decrypt from
* @src_offset: The offset in the page to decrypt from
* @size: The number of bytes to decrypt
* @iv: The initialization vector to use for the decryption
* *
* Returns the number of bytes decrypted * Returns the number of bytes decrypted
*/ */
...@@ -940,6 +959,8 @@ static void ecryptfs_generate_new_key(struct ecryptfs_crypt_stat *crypt_stat) ...@@ -940,6 +959,8 @@ static void ecryptfs_generate_new_key(struct ecryptfs_crypt_stat *crypt_stat)
/** /**
* ecryptfs_copy_mount_wide_flags_to_inode_flags * ecryptfs_copy_mount_wide_flags_to_inode_flags
* @crypt_stat: The inode's cryptographic context
* @mount_crypt_stat: The mount point's cryptographic context
* *
* This function propagates the mount-wide flags to individual inode * This function propagates the mount-wide flags to individual inode
* flags. * flags.
...@@ -980,7 +1001,8 @@ static int ecryptfs_copy_mount_wide_sigs_to_inode_sigs( ...@@ -980,7 +1001,8 @@ static int ecryptfs_copy_mount_wide_sigs_to_inode_sigs(
/** /**
* ecryptfs_set_default_crypt_stat_vals * ecryptfs_set_default_crypt_stat_vals
* @crypt_stat * @crypt_stat: The inode's cryptographic context
* @mount_crypt_stat: The mount point's cryptographic context
* *
* Default values in the event that policy does not override them. * Default values in the event that policy does not override them.
*/ */
...@@ -1000,7 +1022,7 @@ static void ecryptfs_set_default_crypt_stat_vals( ...@@ -1000,7 +1022,7 @@ static void ecryptfs_set_default_crypt_stat_vals(
/** /**
* ecryptfs_new_file_context * ecryptfs_new_file_context
* @ecryptfs_dentry * @ecryptfs_dentry: The eCryptfs dentry
* *
* If the crypto context for the file has not yet been established, * If the crypto context for the file has not yet been established,
* this is where we do that. Establishing a new crypto context * this is where we do that. Establishing a new crypto context
...@@ -1017,7 +1039,6 @@ static void ecryptfs_set_default_crypt_stat_vals( ...@@ -1017,7 +1039,6 @@ static void ecryptfs_set_default_crypt_stat_vals(
* *
* Returns zero on success; non-zero otherwise * Returns zero on success; non-zero otherwise
*/ */
/* Associate an authentication token(s) with the file */
int ecryptfs_new_file_context(struct dentry *ecryptfs_dentry) int ecryptfs_new_file_context(struct dentry *ecryptfs_dentry)
{ {
struct ecryptfs_crypt_stat *crypt_stat = struct ecryptfs_crypt_stat *crypt_stat =
...@@ -1095,7 +1116,7 @@ static struct ecryptfs_flag_map_elem ecryptfs_flag_map[] = { ...@@ -1095,7 +1116,7 @@ static struct ecryptfs_flag_map_elem ecryptfs_flag_map[] = {
/** /**
* ecryptfs_process_flags * ecryptfs_process_flags
* @crypt_stat * @crypt_stat: The cryptographic context
* @page_virt: Source data to be parsed * @page_virt: Source data to be parsed
* @bytes_read: Updated with the number of bytes read * @bytes_read: Updated with the number of bytes read
* *
...@@ -1183,7 +1204,7 @@ ecryptfs_cipher_code_str_map[] = { ...@@ -1183,7 +1204,7 @@ ecryptfs_cipher_code_str_map[] = {
/** /**
* ecryptfs_code_for_cipher_string * ecryptfs_code_for_cipher_string
* @str: The string representing the cipher name * @crypt_stat: The cryptographic context
* *
* Returns zero on no match, or the cipher code on match * Returns zero on no match, or the cipher code on match
*/ */
...@@ -1241,9 +1262,9 @@ int ecryptfs_cipher_code_to_string(char *str, u16 cipher_code) ...@@ -1241,9 +1262,9 @@ int ecryptfs_cipher_code_to_string(char *str, u16 cipher_code)
/** /**
* ecryptfs_read_header_region * ecryptfs_read_header_region
* @data * @data: The virtual address to write header region data into
* @dentry * @dentry: The lower dentry
* @nd * @mnt: The lower VFS mount
* *
* Returns zero on success; non-zero otherwise * Returns zero on success; non-zero otherwise
*/ */
...@@ -1315,9 +1336,10 @@ struct kmem_cache *ecryptfs_header_cache_2; ...@@ -1315,9 +1336,10 @@ struct kmem_cache *ecryptfs_header_cache_2;
/** /**
* ecryptfs_write_headers_virt * ecryptfs_write_headers_virt
* @page_virt * @page_virt: The virtual address to write the headers to
* @crypt_stat * @size: Set to the number of bytes written by this function
* @ecryptfs_dentry * @crypt_stat: The cryptographic context
* @ecryptfs_dentry: The eCryptfs dentry
* *
* Format version: 1 * Format version: 1
* *
...@@ -1371,9 +1393,9 @@ static int ecryptfs_write_headers_virt(char *page_virt, size_t *size, ...@@ -1371,9 +1393,9 @@ static int ecryptfs_write_headers_virt(char *page_virt, size_t *size,
return rc; return rc;
} }
static int ecryptfs_write_metadata_to_contents(struct ecryptfs_crypt_stat *crypt_stat, static int
struct file *lower_file, ecryptfs_write_metadata_to_contents(struct ecryptfs_crypt_stat *crypt_stat,
char *page_virt) struct file *lower_file, char *page_virt)
{ {
mm_segment_t oldfs; mm_segment_t oldfs;
int current_header_page; int current_header_page;
...@@ -1415,9 +1437,10 @@ static int ecryptfs_write_metadata_to_contents(struct ecryptfs_crypt_stat *crypt ...@@ -1415,9 +1437,10 @@ static int ecryptfs_write_metadata_to_contents(struct ecryptfs_crypt_stat *crypt
return rc; return rc;
} }
static int ecryptfs_write_metadata_to_xattr(struct dentry *ecryptfs_dentry, static int
struct ecryptfs_crypt_stat *crypt_stat, ecryptfs_write_metadata_to_xattr(struct dentry *ecryptfs_dentry,
char *page_virt, size_t size) struct ecryptfs_crypt_stat *crypt_stat,
char *page_virt, size_t size)
{ {
int rc; int rc;
...@@ -1428,6 +1451,7 @@ static int ecryptfs_write_metadata_to_xattr(struct dentry *ecryptfs_dentry, ...@@ -1428,6 +1451,7 @@ static int ecryptfs_write_metadata_to_xattr(struct dentry *ecryptfs_dentry,
/** /**
* ecryptfs_write_metadata * ecryptfs_write_metadata
* @ecryptfs_dentry: The eCryptfs dentry
* @lower_file: The lower file struct, which was returned from dentry_open * @lower_file: The lower file struct, which was returned from dentry_open
* *
* Write the file headers out. This will likely involve a userspace * Write the file headers out. This will likely involve a userspace
...@@ -1525,6 +1549,7 @@ static int parse_header_metadata(struct ecryptfs_crypt_stat *crypt_stat, ...@@ -1525,6 +1549,7 @@ static int parse_header_metadata(struct ecryptfs_crypt_stat *crypt_stat,
/** /**
* set_default_header_data * set_default_header_data
* @crypt_stat: The cryptographic context
* *
* For version 0 file format; this function is only for backwards * For version 0 file format; this function is only for backwards
* compatibility for files created with the prior versions of * compatibility for files created with the prior versions of
...@@ -1538,6 +1563,10 @@ static void set_default_header_data(struct ecryptfs_crypt_stat *crypt_stat) ...@@ -1538,6 +1563,10 @@ static void set_default_header_data(struct ecryptfs_crypt_stat *crypt_stat)
/** /**
* ecryptfs_read_headers_virt * ecryptfs_read_headers_virt
* @page_virt: The virtual address into which to read the headers
* @crypt_stat: The cryptographic context
* @ecryptfs_dentry: The eCryptfs dentry
* @validate_header_size: Whether to validate the header size while reading
* *
* Read/parse the header data. The header format is detailed in the * Read/parse the header data. The header format is detailed in the
* comment block for the ecryptfs_write_headers_virt() function. * comment block for the ecryptfs_write_headers_virt() function.
...@@ -1597,9 +1626,13 @@ static int ecryptfs_read_headers_virt(char *page_virt, ...@@ -1597,9 +1626,13 @@ static int ecryptfs_read_headers_virt(char *page_virt,
/** /**
* ecryptfs_read_xattr_region * ecryptfs_read_xattr_region
* @page_virt: The vitual address into which to read the xattr data
* @ecryptfs_dentry: The eCryptfs dentry
* *
* Attempts to read the crypto metadata from the extended attribute * Attempts to read the crypto metadata from the extended attribute
* region of the lower file. * region of the lower file.
*
* Returns zero on success; non-zero on error
*/ */
int ecryptfs_read_xattr_region(char *page_virt, struct dentry *ecryptfs_dentry) int ecryptfs_read_xattr_region(char *page_virt, struct dentry *ecryptfs_dentry)
{ {
...@@ -1638,6 +1671,8 @@ int ecryptfs_read_and_validate_xattr_region(char *page_virt, ...@@ -1638,6 +1671,8 @@ int ecryptfs_read_and_validate_xattr_region(char *page_virt,
/** /**
* ecryptfs_read_metadata * ecryptfs_read_metadata
* @ecryptfs_dentry: The eCryptfs dentry
* @lower_file: The lower file from which to read the metadata
* *
* Common entry point for reading file metadata. From here, we could * Common entry point for reading file metadata. From here, we could
* retrieve the header information from the header region of the file, * retrieve the header information from the header region of the file,
......
...@@ -71,7 +71,7 @@ int process_request_key_err(long err_code) ...@@ -71,7 +71,7 @@ int process_request_key_err(long err_code)
* address; zero on error * address; zero on error
* @length_size: The number of bytes occupied by the encoded length * @length_size: The number of bytes occupied by the encoded length
* *
* Returns Zero on success * Returns zero on success; non-zero on error
*/ */
static int parse_packet_length(unsigned char *data, size_t *size, static int parse_packet_length(unsigned char *data, size_t *size,
size_t *length_size) size_t *length_size)
...@@ -106,11 +106,11 @@ static int parse_packet_length(unsigned char *data, size_t *size, ...@@ -106,11 +106,11 @@ static int parse_packet_length(unsigned char *data, size_t *size,
/** /**
* write_packet_length * write_packet_length
* @dest: The byte array target into which to write the * @dest: The byte array target into which to write the length. Must
* length. Must have at least 5 bytes allocated. * have at least 5 bytes allocated.
* @size: The length to write. * @size: The length to write.
* @packet_size_length: The number of bytes used to encode the * @packet_size_length: The number of bytes used to encode the packet
* packet length is written to this address. * length is written to this address.
* *
* Returns zero on success; non-zero on error. * Returns zero on success; non-zero on error.
*/ */
...@@ -397,10 +397,11 @@ parse_tag_67_packet(struct ecryptfs_key_record *key_rec, ...@@ -397,10 +397,11 @@ parse_tag_67_packet(struct ecryptfs_key_record *key_rec,
} }
/** /**
* decrypt_pki_encrypted_session_key - Decrypt the session key with * decrypt_pki_encrypted_session_key - Decrypt the session key with the given auth_tok.
* the given auth_tok. * @auth_tok: The key authentication token used to decrypt the session key
* @crypt_stat: The cryptographic context
* *
* Returns Zero on success; non-zero error otherwise. * Returns zero on success; non-zero error otherwise.
*/ */
static int static int
decrypt_pki_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok, decrypt_pki_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
...@@ -484,18 +485,18 @@ struct kmem_cache *ecryptfs_auth_tok_list_item_cache; ...@@ -484,18 +485,18 @@ struct kmem_cache *ecryptfs_auth_tok_list_item_cache;
/** /**
* parse_tag_1_packet * parse_tag_1_packet
* @crypt_stat: The cryptographic context to modify based on packet * @crypt_stat: The cryptographic context to modify based on packet contents
* contents.
* @data: The raw bytes of the packet. * @data: The raw bytes of the packet.
* @auth_tok_list: eCryptfs parses packets into authentication tokens; * @auth_tok_list: eCryptfs parses packets into authentication tokens;
* a new authentication token will be placed at the end * a new authentication token will be placed at the
* of this list for this packet. * end of this list for this packet.
* @new_auth_tok: Pointer to a pointer to memory that this function * @new_auth_tok: Pointer to a pointer to memory that this function
* allocates; sets the memory address of the pointer to * allocates; sets the memory address of the pointer to
* NULL on error. This object is added to the * NULL on error. This object is added to the
* auth_tok_list. * auth_tok_list.
* @packet_size: This function writes the size of the parsed packet * @packet_size: This function writes the size of the parsed packet
* into this memory location; zero on error. * into this memory location; zero on error.
* @max_packet_size: The maximum allowable packet size
* *
* Returns zero on success; non-zero on error. * Returns zero on success; non-zero on error.
*/ */
...@@ -996,10 +997,11 @@ ecryptfs_find_auth_tok_for_sig( ...@@ -996,10 +997,11 @@ ecryptfs_find_auth_tok_for_sig(
} }
/** /**
* decrypt_passphrase_encrypted_session_key - Decrypt the session key * decrypt_passphrase_encrypted_session_key - Decrypt the session key with the given auth_tok.
* with the given auth_tok. * @auth_tok: The passphrase authentication token to use to encrypt the FEK
* @crypt_stat: The cryptographic context
* *
* Returns Zero on success; non-zero error otherwise. * Returns zero on success; non-zero error otherwise
*/ */
static int static int
decrypt_passphrase_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok, decrypt_passphrase_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
...@@ -1102,8 +1104,9 @@ int ecryptfs_get_auth_tok_sig(char **sig, struct ecryptfs_auth_tok *auth_tok) ...@@ -1102,8 +1104,9 @@ int ecryptfs_get_auth_tok_sig(char **sig, struct ecryptfs_auth_tok *auth_tok)
/** /**
* ecryptfs_parse_packet_set * ecryptfs_parse_packet_set
* @dest: The header page in memory * @crypt_stat: The cryptographic context
* @version: Version of file format, to guide parsing behavior * @src: Virtual address of region of memory containing the packets
* @ecryptfs_dentry: The eCryptfs dentry associated with the packet set
* *
* Get crypt_stat to have the file's session key if the requisite key * Get crypt_stat to have the file's session key if the requisite key
* is available to decrypt the session key. * is available to decrypt the session key.
...@@ -1354,7 +1357,10 @@ pki_encrypt_session_key(struct ecryptfs_auth_tok *auth_tok, ...@@ -1354,7 +1357,10 @@ pki_encrypt_session_key(struct ecryptfs_auth_tok *auth_tok,
/** /**
* write_tag_1_packet - Write an RFC2440-compatible tag 1 (public key) packet * write_tag_1_packet - Write an RFC2440-compatible tag 1 (public key) packet
* @dest: Buffer into which to write the packet * @dest: Buffer into which to write the packet
* @max: Maximum number of bytes that can be writtn * @remaining_bytes: Maximum number of bytes that can be writtn
* @auth_tok: The authentication token used for generating the tag 1 packet
* @crypt_stat: The cryptographic context
* @key_rec: The key record struct for the tag 1 packet
* @packet_size: This function will write the number of bytes that end * @packet_size: This function will write the number of bytes that end
* up constituting the packet; set to zero on error * up constituting the packet; set to zero on error
* *
...@@ -1441,7 +1447,7 @@ write_tag_1_packet(char *dest, size_t *remaining_bytes, ...@@ -1441,7 +1447,7 @@ write_tag_1_packet(char *dest, size_t *remaining_bytes,
/** /**
* write_tag_11_packet * write_tag_11_packet
* @dest: Target into which Tag 11 packet is to be written * @dest: Target into which Tag 11 packet is to be written
* @max: Maximum packet length * @remaining_bytes: Maximum packet length
* @contents: Byte array of contents to copy in * @contents: Byte array of contents to copy in
* @contents_length: Number of bytes in contents * @contents_length: Number of bytes in contents
* @packet_length: Length of the Tag 11 packet written; zero on error * @packet_length: Length of the Tag 11 packet written; zero on error
...@@ -1501,7 +1507,7 @@ write_tag_11_packet(char *dest, size_t *remaining_bytes, char *contents, ...@@ -1501,7 +1507,7 @@ write_tag_11_packet(char *dest, size_t *remaining_bytes, char *contents,
/** /**
* write_tag_3_packet * write_tag_3_packet
* @dest: Buffer into which to write the packet * @dest: Buffer into which to write the packet
* @max: Maximum number of bytes that can be written * @remaining_bytes: Maximum number of bytes that can be written
* @auth_tok: Authentication token * @auth_tok: Authentication token
* @crypt_stat: The cryptographic context * @crypt_stat: The cryptographic context
* @key_rec: encrypted key * @key_rec: encrypted key
...@@ -1707,7 +1713,7 @@ struct kmem_cache *ecryptfs_key_record_cache; ...@@ -1707,7 +1713,7 @@ struct kmem_cache *ecryptfs_key_record_cache;
/** /**
* ecryptfs_generate_key_packet_set * ecryptfs_generate_key_packet_set
* @dest: Virtual address from which to write the key record set * @dest_base: Virtual address from which to write the key record set
* @crypt_stat: The cryptographic context from which the * @crypt_stat: The cryptographic context from which the
* authentication tokens will be retrieved * authentication tokens will be retrieved
* @ecryptfs_dentry: The dentry, used to retrieve the mount crypt stat * @ecryptfs_dentry: The dentry, used to retrieve the mount crypt stat
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment