@@ -65,16 +65,16 @@ static int process_request_key_err(long err_code)
6565}
6666
6767/**
68- * parse_packet_length
68+ * ecryptfs_parse_packet_length
6969 * @data: Pointer to memory containing length at offset
7070 * @size: This function writes the decoded size to this memory
7171 * address; zero on error
7272 * @length_size: The number of bytes occupied by the encoded length
7373 *
7474 * Returns zero on success; non-zero on error
7575 */
76- static int parse_packet_length (unsigned char * data , size_t * size ,
77- size_t * length_size )
76+ int ecryptfs_parse_packet_length (unsigned char * data , size_t * size ,
77+ size_t * length_size )
7878{
7979 int rc = 0 ;
8080
@@ -105,7 +105,7 @@ static int parse_packet_length(unsigned char *data, size_t *size,
105105}
106106
107107/**
108- * write_packet_length
108+ * ecryptfs_write_packet_length
109109 * @dest: The byte array target into which to write the length. Must
110110 * have at least 5 bytes allocated.
111111 * @size: The length to write.
@@ -114,8 +114,8 @@ static int parse_packet_length(unsigned char *data, size_t *size,
114114 *
115115 * Returns zero on success; non-zero on error.
116116 */
117- static int write_packet_length (char * dest , size_t size ,
118- size_t * packet_size_length )
117+ int ecryptfs_write_packet_length (char * dest , size_t size ,
118+ size_t * packet_size_length )
119119{
120120 int rc = 0 ;
121121
@@ -162,8 +162,8 @@ write_tag_64_packet(char *signature, struct ecryptfs_session_key *session_key,
162162 goto out ;
163163 }
164164 message [i ++ ] = ECRYPTFS_TAG_64_PACKET_TYPE ;
165- rc = write_packet_length (& message [i ], ECRYPTFS_SIG_SIZE_HEX ,
166- & packet_size_len );
165+ rc = ecryptfs_write_packet_length (& message [i ], ECRYPTFS_SIG_SIZE_HEX ,
166+ & packet_size_len );
167167 if (rc ) {
168168 ecryptfs_printk (KERN_ERR , "Error generating tag 64 packet "
169169 "header; cannot generate packet length\n" );
@@ -172,8 +172,9 @@ write_tag_64_packet(char *signature, struct ecryptfs_session_key *session_key,
172172 i += packet_size_len ;
173173 memcpy (& message [i ], signature , ECRYPTFS_SIG_SIZE_HEX );
174174 i += ECRYPTFS_SIG_SIZE_HEX ;
175- rc = write_packet_length (& message [i ], session_key -> encrypted_key_size ,
176- & packet_size_len );
175+ rc = ecryptfs_write_packet_length (& message [i ],
176+ session_key -> encrypted_key_size ,
177+ & packet_size_len );
177178 if (rc ) {
178179 ecryptfs_printk (KERN_ERR , "Error generating tag 64 packet "
179180 "header; cannot generate packet length\n" );
@@ -225,7 +226,7 @@ parse_tag_65_packet(struct ecryptfs_session_key *session_key, u8 *cipher_code,
225226 rc = - EIO ;
226227 goto out ;
227228 }
228- rc = parse_packet_length (& data [i ], & m_size , & data_len );
229+ rc = ecryptfs_parse_packet_length (& data [i ], & m_size , & data_len );
229230 if (rc ) {
230231 ecryptfs_printk (KERN_WARNING , "Error parsing packet length; "
231232 "rc = [%d]\n" , rc );
@@ -304,8 +305,8 @@ write_tag_66_packet(char *signature, u8 cipher_code,
304305 goto out ;
305306 }
306307 message [i ++ ] = ECRYPTFS_TAG_66_PACKET_TYPE ;
307- rc = write_packet_length (& message [i ], ECRYPTFS_SIG_SIZE_HEX ,
308- & packet_size_len );
308+ rc = ecryptfs_write_packet_length (& message [i ], ECRYPTFS_SIG_SIZE_HEX ,
309+ & packet_size_len );
309310 if (rc ) {
310311 ecryptfs_printk (KERN_ERR , "Error generating tag 66 packet "
311312 "header; cannot generate packet length\n" );
@@ -315,8 +316,8 @@ write_tag_66_packet(char *signature, u8 cipher_code,
315316 memcpy (& message [i ], signature , ECRYPTFS_SIG_SIZE_HEX );
316317 i += ECRYPTFS_SIG_SIZE_HEX ;
317318 /* The encrypted key includes 1 byte cipher code and 2 byte checksum */
318- rc = write_packet_length (& message [i ], crypt_stat -> key_size + 3 ,
319- & packet_size_len );
319+ rc = ecryptfs_write_packet_length (& message [i ], crypt_stat -> key_size + 3 ,
320+ & packet_size_len );
320321 if (rc ) {
321322 ecryptfs_printk (KERN_ERR , "Error generating tag 66 packet "
322323 "header; cannot generate packet length\n" );
@@ -357,38 +358,43 @@ parse_tag_67_packet(struct ecryptfs_key_record *key_rec,
357358 /* verify that everything through the encrypted FEK size is present */
358359 if (message_len < 4 ) {
359360 rc = - EIO ;
361+ printk (KERN_ERR "%s: message_len is [%Zd]; minimum acceptable "
362+ "message length is [%d]\n" , __func__ , message_len , 4 );
360363 goto out ;
361364 }
362365 if (data [i ++ ] != ECRYPTFS_TAG_67_PACKET_TYPE ) {
363- ecryptfs_printk (KERN_ERR , "Type should be ECRYPTFS_TAG_67\n" );
364366 rc = - EIO ;
367+ printk (KERN_ERR "%s: Type should be ECRYPTFS_TAG_67\n" ,
368+ __func__ );
365369 goto out ;
366370 }
367371 if (data [i ++ ]) {
368- ecryptfs_printk (KERN_ERR , "Status indicator has non zero value"
369- " [%d]\n" , data [i - 1 ]);
370372 rc = - EIO ;
373+ printk (KERN_ERR "%s: Status indicator has non zero "
374+ "value [%d]\n" , __func__ , data [i - 1 ]);
375+
371376 goto out ;
372377 }
373- rc = parse_packet_length (& data [i ], & key_rec -> enc_key_size , & data_len );
378+ rc = ecryptfs_parse_packet_length (& data [i ], & key_rec -> enc_key_size ,
379+ & data_len );
374380 if (rc ) {
375381 ecryptfs_printk (KERN_WARNING , "Error parsing packet length; "
376382 "rc = [%d]\n" , rc );
377383 goto out ;
378384 }
379385 i += data_len ;
380386 if (message_len < (i + key_rec -> enc_key_size )) {
381- ecryptfs_printk (KERN_ERR , "message_len [%d]; max len is [%d]\n" ,
382- message_len , (i + key_rec -> enc_key_size ));
383387 rc = - EIO ;
388+ printk (KERN_ERR "%s: message_len [%Zd]; max len is [%Zd]\n" ,
389+ __func__ , message_len , (i + key_rec -> enc_key_size ));
384390 goto out ;
385391 }
386392 if (key_rec -> enc_key_size > ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES ) {
387- ecryptfs_printk (KERN_ERR , "Encrypted key_size [%d] larger than "
388- "the maximum key size [%d]\n" ,
389- key_rec -> enc_key_size ,
390- ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES );
391393 rc = - EIO ;
394+ printk (KERN_ERR "%s: Encrypted key_size [%Zd] larger than "
395+ "the maximum key size [%d]\n" , __func__ ,
396+ key_rec -> enc_key_size ,
397+ ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES );
392398 goto out ;
393399 }
394400 memcpy (key_rec -> enc_key , & data [i ], key_rec -> enc_key_size );
@@ -445,7 +451,7 @@ decrypt_pki_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok,
445451 rc = write_tag_64_packet (auth_tok_sig , & (auth_tok -> session_key ),
446452 & netlink_message , & netlink_message_length );
447453 if (rc ) {
448- ecryptfs_printk (KERN_ERR , "Failed to write tag 64 packet" );
454+ ecryptfs_printk (KERN_ERR , "Failed to write tag 64 packet\n " );
449455 goto out ;
450456 }
451457 rc = ecryptfs_send_message (ecryptfs_transport , netlink_message ,
@@ -570,8 +576,8 @@ parse_tag_1_packet(struct ecryptfs_crypt_stat *crypt_stat,
570576 goto out ;
571577 }
572578 (* new_auth_tok ) = & auth_tok_list_item -> auth_tok ;
573- rc = parse_packet_length (& data [(* packet_size )], & body_size ,
574- & length_size );
579+ rc = ecryptfs_parse_packet_length (& data [(* packet_size )], & body_size ,
580+ & length_size );
575581 if (rc ) {
576582 printk (KERN_WARNING "Error parsing packet length; "
577583 "rc = [%d]\n" , rc );
@@ -704,8 +710,8 @@ parse_tag_3_packet(struct ecryptfs_crypt_stat *crypt_stat,
704710 goto out ;
705711 }
706712 (* new_auth_tok ) = & auth_tok_list_item -> auth_tok ;
707- rc = parse_packet_length (& data [(* packet_size )], & body_size ,
708- & length_size );
713+ rc = ecryptfs_parse_packet_length (& data [(* packet_size )], & body_size ,
714+ & length_size );
709715 if (rc ) {
710716 printk (KERN_WARNING "Error parsing packet length; rc = [%d]\n" ,
711717 rc );
@@ -852,8 +858,8 @@ parse_tag_11_packet(unsigned char *data, unsigned char *contents,
852858 rc = - EINVAL ;
853859 goto out ;
854860 }
855- rc = parse_packet_length (& data [(* packet_size )], & body_size ,
856- & length_size );
861+ rc = ecryptfs_parse_packet_length (& data [(* packet_size )], & body_size ,
862+ & length_size );
857863 if (rc ) {
858864 printk (KERN_WARNING "Invalid tag 11 packet format\n" );
859865 goto out ;
@@ -1405,8 +1411,8 @@ write_tag_1_packet(char *dest, size_t *remaining_bytes,
14051411 auth_tok -> token .private_key .key_size ;
14061412 rc = pki_encrypt_session_key (auth_tok , crypt_stat , key_rec );
14071413 if (rc ) {
1408- ecryptfs_printk (KERN_ERR , "Failed to encrypt session key "
1409- "via a pki" );
1414+ printk (KERN_ERR "Failed to encrypt session key via a key "
1415+ "module; rc = [%d]\n" , rc );
14101416 goto out ;
14111417 }
14121418 if (ecryptfs_verbosity > 0 ) {
@@ -1430,8 +1436,9 @@ write_tag_1_packet(char *dest, size_t *remaining_bytes,
14301436 goto out ;
14311437 }
14321438 dest [(* packet_size )++ ] = ECRYPTFS_TAG_1_PACKET_TYPE ;
1433- rc = write_packet_length (& dest [(* packet_size )], (max_packet_size - 4 ),
1434- & packet_size_length );
1439+ rc = ecryptfs_write_packet_length (& dest [(* packet_size )],
1440+ (max_packet_size - 4 ),
1441+ & packet_size_length );
14351442 if (rc ) {
14361443 ecryptfs_printk (KERN_ERR , "Error generating tag 1 packet "
14371444 "header; cannot generate packet length\n" );
@@ -1489,8 +1496,9 @@ write_tag_11_packet(char *dest, size_t *remaining_bytes, char *contents,
14891496 goto out ;
14901497 }
14911498 dest [(* packet_length )++ ] = ECRYPTFS_TAG_11_PACKET_TYPE ;
1492- rc = write_packet_length (& dest [(* packet_length )],
1493- (max_packet_size - 4 ), & packet_size_length );
1499+ rc = ecryptfs_write_packet_length (& dest [(* packet_length )],
1500+ (max_packet_size - 4 ),
1501+ & packet_size_length );
14941502 if (rc ) {
14951503 printk (KERN_ERR "Error generating tag 11 packet header; cannot "
14961504 "generate packet length. rc = [%d]\n" , rc );
@@ -1682,8 +1690,9 @@ write_tag_3_packet(char *dest, size_t *remaining_bytes,
16821690 dest [(* packet_size )++ ] = ECRYPTFS_TAG_3_PACKET_TYPE ;
16831691 /* Chop off the Tag 3 identifier(1) and Tag 3 packet size(3)
16841692 * to get the number of octets in the actual Tag 3 packet */
1685- rc = write_packet_length (& dest [(* packet_size )], (max_packet_size - 4 ),
1686- & packet_size_length );
1693+ rc = ecryptfs_write_packet_length (& dest [(* packet_size )],
1694+ (max_packet_size - 4 ),
1695+ & packet_size_length );
16871696 if (rc ) {
16881697 printk (KERN_ERR "Error generating tag 3 packet header; cannot "
16891698 "generate packet length. rc = [%d]\n" , rc );
0 commit comments