@@ -233,26 +233,15 @@ static int rxkad_prime_packet_security(struct rxrpc_connection *conn,
233233static struct skcipher_request * rxkad_get_call_crypto (struct rxrpc_call * call )
234234{
235235 struct crypto_skcipher * tfm = & call -> conn -> rxkad .cipher -> base ;
236- struct skcipher_request * cipher_req = call -> cipher_req ;
237236
238- if (!cipher_req ) {
239- cipher_req = skcipher_request_alloc (tfm , GFP_NOFS );
240- if (!cipher_req )
241- return NULL ;
242- call -> cipher_req = cipher_req ;
243- }
244-
245- return cipher_req ;
237+ return skcipher_request_alloc (tfm , GFP_NOFS );
246238}
247239
248240/*
249241 * Clean up the crypto on a call.
250242 */
251243static void rxkad_free_call_crypto (struct rxrpc_call * call )
252244{
253- if (call -> cipher_req )
254- skcipher_request_free (call -> cipher_req );
255- call -> cipher_req = NULL ;
256245}
257246
258247/*
@@ -348,6 +337,9 @@ static int rxkad_secure_packet(struct rxrpc_call *call, struct rxrpc_txbuf *txb)
348337 struct skcipher_request * req ;
349338 struct rxrpc_crypt iv ;
350339 struct scatterlist sg ;
340+ union {
341+ __be32 buf [2 ];
342+ } crypto __aligned (8 );
351343 u32 x , y ;
352344 int ret ;
353345
@@ -372,17 +364,17 @@ static int rxkad_secure_packet(struct rxrpc_call *call, struct rxrpc_txbuf *txb)
372364 /* calculate the security checksum */
373365 x = (ntohl (txb -> wire .cid ) & RXRPC_CHANNELMASK ) << (32 - RXRPC_CIDSHIFT );
374366 x |= txb -> seq & 0x3fffffff ;
375- call -> crypto_buf [0 ] = txb -> wire .callNumber ;
376- call -> crypto_buf [1 ] = htonl (x );
367+ crypto . buf [0 ] = txb -> wire .callNumber ;
368+ crypto . buf [1 ] = htonl (x );
377369
378- sg_init_one (& sg , call -> crypto_buf , 8 );
370+ sg_init_one (& sg , crypto . buf , 8 );
379371 skcipher_request_set_sync_tfm (req , call -> conn -> rxkad .cipher );
380372 skcipher_request_set_callback (req , 0 , NULL , NULL );
381373 skcipher_request_set_crypt (req , & sg , & sg , 8 , iv .x );
382374 crypto_skcipher_encrypt (req );
383375 skcipher_request_zero (req );
384376
385- y = ntohl (call -> crypto_buf [1 ]);
377+ y = ntohl (crypto . buf [1 ]);
386378 y = (y >> 16 ) & 0xffff ;
387379 if (y == 0 )
388380 y = 1 ; /* zero checksums are not permitted */
@@ -403,6 +395,7 @@ static int rxkad_secure_packet(struct rxrpc_call *call, struct rxrpc_txbuf *txb)
403395 break ;
404396 }
405397
398+ skcipher_request_free (req );
406399 _leave (" = %d [set %x]" , ret , y );
407400 return ret ;
408401}
@@ -593,8 +586,12 @@ static int rxkad_verify_packet(struct rxrpc_call *call, struct sk_buff *skb)
593586 struct skcipher_request * req ;
594587 struct rxrpc_crypt iv ;
595588 struct scatterlist sg ;
589+ union {
590+ __be32 buf [2 ];
591+ } crypto __aligned (8 );
596592 rxrpc_seq_t seq = sp -> hdr .seq ;
597593 bool aborted ;
594+ int ret ;
598595 u16 cksum ;
599596 u32 x , y ;
600597
@@ -614,17 +611,17 @@ static int rxkad_verify_packet(struct rxrpc_call *call, struct sk_buff *skb)
614611 /* validate the security checksum */
615612 x = (call -> cid & RXRPC_CHANNELMASK ) << (32 - RXRPC_CIDSHIFT );
616613 x |= seq & 0x3fffffff ;
617- call -> crypto_buf [0 ] = htonl (call -> call_id );
618- call -> crypto_buf [1 ] = htonl (x );
614+ crypto . buf [0 ] = htonl (call -> call_id );
615+ crypto . buf [1 ] = htonl (x );
619616
620- sg_init_one (& sg , call -> crypto_buf , 8 );
617+ sg_init_one (& sg , crypto . buf , 8 );
621618 skcipher_request_set_sync_tfm (req , call -> conn -> rxkad .cipher );
622619 skcipher_request_set_callback (req , 0 , NULL , NULL );
623620 skcipher_request_set_crypt (req , & sg , & sg , 8 , iv .x );
624621 crypto_skcipher_encrypt (req );
625622 skcipher_request_zero (req );
626623
627- y = ntohl (call -> crypto_buf [1 ]);
624+ y = ntohl (crypto . buf [1 ]);
628625 cksum = (y >> 16 ) & 0xffff ;
629626 if (cksum == 0 )
630627 cksum = 1 ; /* zero checksums are not permitted */
@@ -637,15 +634,22 @@ static int rxkad_verify_packet(struct rxrpc_call *call, struct sk_buff *skb)
637634
638635 switch (call -> conn -> params .security_level ) {
639636 case RXRPC_SECURITY_PLAIN :
640- return 0 ;
637+ ret = 0 ;
638+ break ;
641639 case RXRPC_SECURITY_AUTH :
642- return rxkad_verify_packet_1 (call , skb , seq , req );
640+ ret = rxkad_verify_packet_1 (call , skb , seq , req );
641+ break ;
643642 case RXRPC_SECURITY_ENCRYPT :
644- return rxkad_verify_packet_2 (call , skb , seq , req );
643+ ret = rxkad_verify_packet_2 (call , skb , seq , req );
644+ break ;
645645 default :
646- return - ENOANO ;
646+ ret = - ENOANO ;
647+ break ;
647648 }
648649
650+ skcipher_request_free (req );
651+ return ret ;
652+
649653protocol_error :
650654 if (aborted )
651655 rxrpc_send_abort_packet (call );
0 commit comments