Skip to content

Commit def304a

Browse files
dhowellskuba-moo
authored andcommitted
rxrpc: Fix rxkad crypto unalignment handling
Fix handling of a packet with a misaligned crypto length. Also handle non-ENOMEM errors from decryption by aborting. Further, remove the WARN_ON_ONCE() so that it can't be remotely triggered (a trace line can still be emitted). Fixes: f93af41 ("rxrpc: Fix missing error checks for rxkad encryption/decryption failure") Closes: https://sashiko.dev/#/patchset/20260408121252.2249051-1-dhowells%40redhat.com Signed-off-by: David Howells <dhowells@redhat.com> cc: Marc Dionne <marc.dionne@auristor.com> cc: Jeffrey Altman <jaltman@auristor.com> cc: Simon Horman <horms@kernel.org> cc: linux-afs@lists.infradead.org cc: stable@kernel.org Link: https://patch.msgid.link/20260422161438.2593376-3-dhowells@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 34f61a0 commit def304a

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

include/trace/events/rxrpc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
EM(rxkad_abort_1_short_encdata, "rxkad1-short-encdata") \
3838
EM(rxkad_abort_1_short_header, "rxkad1-short-hdr") \
3939
EM(rxkad_abort_2_short_check, "rxkad2-short-check") \
40+
EM(rxkad_abort_2_crypto_unaligned, "rxkad2-crypto-unaligned") \
4041
EM(rxkad_abort_2_short_data, "rxkad2-short-data") \
4142
EM(rxkad_abort_2_short_header, "rxkad2-short-hdr") \
4243
EM(rxkad_abort_2_short_len, "rxkad2-short-len") \

net/rxrpc/rxkad.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,9 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb,
510510
return rxrpc_abort_eproto(call, skb, RXKADSEALEDINCON,
511511
rxkad_abort_2_short_header);
512512

513+
/* Don't let the crypto algo see a misaligned length. */
514+
sp->len = round_down(sp->len, 8);
515+
513516
/* Decrypt the skbuff in-place. TODO: We really want to decrypt
514517
* directly into the target buffer.
515518
*/
@@ -543,8 +546,10 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb,
543546
if (sg != _sg)
544547
kfree(sg);
545548
if (ret < 0) {
546-
WARN_ON_ONCE(ret != -ENOMEM);
547-
return ret;
549+
if (ret == -ENOMEM)
550+
return ret;
551+
return rxrpc_abort_eproto(call, skb, RXKADSEALEDINCON,
552+
rxkad_abort_2_crypto_unaligned);
548553
}
549554

550555
/* Extract the decrypted packet length */

0 commit comments

Comments
 (0)