* [PATCH net] rxrpc: Fix untrusted unsigned subtract
@ 2025-09-11 23:06 David Howells
2025-09-12 18:48 ` Simon Horman
2025-09-14 20:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 5+ messages in thread
From: David Howells @ 2025-09-11 23:06 UTC (permalink / raw)
To: Dan Carpenter, netdev
Cc: dhowells, Marc Dionne, Jakub Kicinski, David S. Miller,
Eric Dumazet, Paolo Abeni, Simon Horman, linux-afs, linux-kernel
Fix the following Smatch Smatch static checker warning:
net/rxrpc/rxgk_app.c:65 rxgk_yfs_decode_ticket()
warn: untrusted unsigned subtract. 'ticket_len - 10 * 4'
by prechecking the length of what we're trying to extract in two places in
the token and decoding for a response packet.
Also use sizeof() on the struct we're extracting rather specifying the size
numerically to be consistent with the other related statements.
Fixes: 9d1d2b59341f ("rxrpc: rxgk: Implement the yfs-rxgk security class (GSSAPI)")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lists.infradead.org/pipermail/linux-afs/2025-September/010135.html
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Jakub Kicinski <kuba@kernel.org>
cc: "David S. Miller" <davem@davemloft.net>
cc: Eric Dumazet <edumazet@google.com>
cc: Paolo Abeni <pabeni@redhat.com>
cc: Simon Horman <horms@kernel.org>
cc: linux-afs@lists.infradead.org
cc: netdev@vger.kernel.org
---
net/rxrpc/rxgk_app.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/net/rxrpc/rxgk_app.c b/net/rxrpc/rxgk_app.c
index df684b5a8531..30275cb5ba3e 100644
--- a/net/rxrpc/rxgk_app.c
+++ b/net/rxrpc/rxgk_app.c
@@ -54,6 +54,10 @@ int rxgk_yfs_decode_ticket(struct rxrpc_connection *conn, struct sk_buff *skb,
_enter("");
+ if (ticket_len < 10 * sizeof(__be32))
+ return rxrpc_abort_conn(conn, skb, RXGK_INCONSISTENCY, -EPROTO,
+ rxgk_abort_resp_short_yfs_tkt);
+
/* Get the session key length */
ret = skb_copy_bits(skb, ticket_offset, tmp, sizeof(tmp));
if (ret < 0)
@@ -195,22 +199,23 @@ int rxgk_extract_token(struct rxrpc_connection *conn, struct sk_buff *skb,
__be32 token_len;
} container;
+ if (token_len < sizeof(container))
+ goto short_packet;
+
/* Decode the RXGK_TokenContainer object. This tells us which server
* key we should be using. We can then fetch the key, get the secret
* and set up the crypto to extract the token.
*/
if (skb_copy_bits(skb, token_offset, &container, sizeof(container)) < 0)
- return rxrpc_abort_conn(conn, skb, RXGK_PACKETSHORT, -EPROTO,
- rxgk_abort_resp_tok_short);
+ goto short_packet;
kvno = ntohl(container.kvno);
enctype = ntohl(container.enctype);
ticket_len = ntohl(container.token_len);
ticket_offset = token_offset + sizeof(container);
- if (xdr_round_up(ticket_len) > token_len - 3 * 4)
- return rxrpc_abort_conn(conn, skb, RXGK_PACKETSHORT, -EPROTO,
- rxgk_abort_resp_tok_short);
+ if (xdr_round_up(ticket_len) > token_len - sizeof(container))
+ goto short_packet;
_debug("KVNO %u", kvno);
_debug("ENC %u", enctype);
@@ -285,4 +290,8 @@ int rxgk_extract_token(struct rxrpc_connection *conn, struct sk_buff *skb,
* also come out this way if the ticket decryption fails.
*/
return ret;
+
+short_packet:
+ return rxrpc_abort_conn(conn, skb, RXGK_PACKETSHORT, -EPROTO,
+ rxgk_abort_resp_tok_short);
}
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net] rxrpc: Fix untrusted unsigned subtract
2025-09-11 23:06 [PATCH net] rxrpc: Fix untrusted unsigned subtract David Howells
@ 2025-09-12 18:48 ` Simon Horman
2025-09-12 19:43 ` David Howells
2025-09-14 20:10 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 5+ messages in thread
From: Simon Horman @ 2025-09-12 18:48 UTC (permalink / raw)
To: David Howells
Cc: Dan Carpenter, netdev, Marc Dionne, Jakub Kicinski,
David S. Miller, Eric Dumazet, Paolo Abeni, linux-afs,
linux-kernel
On Fri, Sep 12, 2025 at 12:06:17AM +0100, David Howells wrote:
> Fix the following Smatch Smatch static checker warning:
nit: Smatch Smatch -> Smatch
>
> net/rxrpc/rxgk_app.c:65 rxgk_yfs_decode_ticket()
> warn: untrusted unsigned subtract. 'ticket_len - 10 * 4'
>
> by prechecking the length of what we're trying to extract in two places in
> the token and decoding for a response packet.
>
> Also use sizeof() on the struct we're extracting rather specifying the size
> numerically to be consistent with the other related statements.
>
> Fixes: 9d1d2b59341f ("rxrpc: rxgk: Implement the yfs-rxgk security class (GSSAPI)")
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lists.infradead.org/pipermail/linux-afs/2025-September/010135.html
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Marc Dionne <marc.dionne@auristor.com>
> cc: Jakub Kicinski <kuba@kernel.org>
> cc: "David S. Miller" <davem@davemloft.net>
> cc: Eric Dumazet <edumazet@google.com>
> cc: Paolo Abeni <pabeni@redhat.com>
> cc: Simon Horman <horms@kernel.org>
> cc: linux-afs@lists.infradead.org
> cc: netdev@vger.kernel.org
> ---
> net/rxrpc/rxgk_app.c | 19 ++++++++++++++-----
> 1 file changed, 14 insertions(+), 5 deletions(-)
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] rxrpc: Fix untrusted unsigned subtract
2025-09-12 18:48 ` Simon Horman
@ 2025-09-12 19:43 ` David Howells
2025-09-14 20:04 ` Jakub Kicinski
0 siblings, 1 reply; 5+ messages in thread
From: David Howells @ 2025-09-12 19:43 UTC (permalink / raw)
To: Simon Horman
Cc: dhowells, Dan Carpenter, netdev, Marc Dionne, Jakub Kicinski,
David S. Miller, Eric Dumazet, Paolo Abeni, linux-afs,
linux-kernel
Simon Horman <horms@kernel.org> wrote:
> > Fix the following Smatch Smatch static checker warning:
>
> nit: Smatch Smatch -> Smatch
Yeah. Can that be fixed up at time of application?
David
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] rxrpc: Fix untrusted unsigned subtract
2025-09-12 19:43 ` David Howells
@ 2025-09-14 20:04 ` Jakub Kicinski
0 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2025-09-14 20:04 UTC (permalink / raw)
To: David Howells
Cc: Simon Horman, Dan Carpenter, netdev, Marc Dionne, David S. Miller,
Eric Dumazet, Paolo Abeni, linux-afs, linux-kernel
On Fri, 12 Sep 2025 20:43:58 +0100 David Howells wrote:
> Simon Horman <horms@kernel.org> wrote:
>
> > > Fix the following Smatch Smatch static checker warning:
> >
> > nit: Smatch Smatch -> Smatch
>
> Yeah. Can that be fixed up at time of application?
Done!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] rxrpc: Fix untrusted unsigned subtract
2025-09-11 23:06 [PATCH net] rxrpc: Fix untrusted unsigned subtract David Howells
2025-09-12 18:48 ` Simon Horman
@ 2025-09-14 20:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-14 20:10 UTC (permalink / raw)
To: David Howells
Cc: dan.carpenter, netdev, marc.dionne, kuba, davem, edumazet, pabeni,
horms, linux-afs, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 12 Sep 2025 00:06:17 +0100 you wrote:
> Fix the following Smatch Smatch static checker warning:
>
> net/rxrpc/rxgk_app.c:65 rxgk_yfs_decode_ticket()
> warn: untrusted unsigned subtract. 'ticket_len - 10 * 4'
>
> by prechecking the length of what we're trying to extract in two places in
> the token and decoding for a response packet.
>
> [...]
Here is the summary with links:
- [net] rxrpc: Fix untrusted unsigned subtract
https://git.kernel.org/netdev/net/c/2429a1976481
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-09-14 20:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-11 23:06 [PATCH net] rxrpc: Fix untrusted unsigned subtract David Howells
2025-09-12 18:48 ` Simon Horman
2025-09-12 19:43 ` David Howells
2025-09-14 20:04 ` Jakub Kicinski
2025-09-14 20:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).