Skip to content

Commit 6929350

Browse files
dhowellskuba-moo
authored andcommitted
rxgk: Fix potential integer overflow in length check
Fix potential integer overflow in rxgk_extract_token() when checking the length of the ticket. Rather than rounding up the value to be tested (which might overflow), round down the size of the available data. Fixes: 2429a19 ("rxrpc: Fix untrusted unsigned subtract") Closes: https://sashiko.dev/#/patchset/20260408121252.2249051-1-dhowells%40redhat.com Signed-off-by: David Howells <[email protected]> cc: Marc Dionne <[email protected]> cc: Jeffrey Altman <[email protected]> cc: Simon Horman <[email protected]> cc: [email protected] cc: [email protected] Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 24481a7 commit 6929350

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

net/rxrpc/rxgk_app.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ int rxgk_extract_token(struct rxrpc_connection *conn, struct sk_buff *skb,
214214
ticket_len = ntohl(container.token_len);
215215
ticket_offset = token_offset + sizeof(container);
216216

217-
if (xdr_round_up(ticket_len) > token_len - sizeof(container))
217+
if (ticket_len > xdr_round_down(token_len - sizeof(container)))
218218
goto short_packet;
219219

220220
_debug("KVNO %u", kvno);

net/rxrpc/rxgk_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ struct rxgk_context {
3434
};
3535

3636
#define xdr_round_up(x) (round_up((x), sizeof(__be32)))
37+
#define xdr_round_down(x) (round_down((x), sizeof(__be32)))
3738
#define xdr_object_len(x) (4 + xdr_round_up(x))
3839

3940
/*

0 commit comments

Comments
 (0)