netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] tipc: re-order conditions in tipc_crypto_key_rcv()
@ 2025-01-17  9:36 Dan Carpenter
  2025-01-17 18:02 ` Simon Horman
  2025-01-20 12:20 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-01-17  9:36 UTC (permalink / raw)
  To: Jon Maloy
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, netdev, tipc-discussion, linux-kernel,
	kernel-janitors

On a 32bit system the "keylen + sizeof(struct tipc_aead_key)" math could
have an integer wrapping issue.  It doesn't matter because the "keylen"
is checked on the next line, but just to make life easier for static
analysis tools, let's re-order these conditions and avoid the integer
overflow.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 net/tipc/crypto.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c
index 43c3f1c971b8..c524421ec652 100644
--- a/net/tipc/crypto.c
+++ b/net/tipc/crypto.c
@@ -2293,8 +2293,8 @@ static bool tipc_crypto_key_rcv(struct tipc_crypto *rx, struct tipc_msg *hdr)
 	keylen = ntohl(*((__be32 *)(data + TIPC_AEAD_ALG_NAME)));
 
 	/* Verify the supplied size values */
-	if (unlikely(size != keylen + sizeof(struct tipc_aead_key) ||
-		     keylen > TIPC_AEAD_KEY_SIZE_MAX)) {
+	if (unlikely(keylen > TIPC_AEAD_KEY_SIZE_MAX ||
+		     size != keylen + sizeof(struct tipc_aead_key))) {
 		pr_debug("%s: invalid MSG_CRYPTO key size\n", rx->name);
 		goto exit;
 	}
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] tipc: re-order conditions in tipc_crypto_key_rcv()
  2025-01-17  9:36 [PATCH net-next] tipc: re-order conditions in tipc_crypto_key_rcv() Dan Carpenter
@ 2025-01-17 18:02 ` Simon Horman
  2025-01-20 12:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2025-01-17 18:02 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jon Maloy, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, netdev, tipc-discussion, linux-kernel,
	kernel-janitors

On Fri, Jan 17, 2025 at 12:36:14PM +0300, Dan Carpenter wrote:
> On a 32bit system the "keylen + sizeof(struct tipc_aead_key)" math could
> have an integer wrapping issue.  It doesn't matter because the "keylen"
> is checked on the next line, but just to make life easier for static
> analysis tools, let's re-order these conditions and avoid the integer
> overflow.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] tipc: re-order conditions in tipc_crypto_key_rcv()
  2025-01-17  9:36 [PATCH net-next] tipc: re-order conditions in tipc_crypto_key_rcv() Dan Carpenter
  2025-01-17 18:02 ` Simon Horman
@ 2025-01-20 12:20 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-01-20 12:20 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: jmaloy, davem, edumazet, kuba, pabeni, horms, netdev,
	tipc-discussion, linux-kernel, kernel-janitors

Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Fri, 17 Jan 2025 12:36:14 +0300 you wrote:
> On a 32bit system the "keylen + sizeof(struct tipc_aead_key)" math could
> have an integer wrapping issue.  It doesn't matter because the "keylen"
> is checked on the next line, but just to make life easier for static
> analysis tools, let's re-order these conditions and avoid the integer
> overflow.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> 
> [...]

Here is the summary with links:
  - [net-next] tipc: re-order conditions in tipc_crypto_key_rcv()
    https://git.kernel.org/netdev/net-next/c/5fe71fda8974

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] 3+ messages in thread

end of thread, other threads:[~2025-01-20 12:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-17  9:36 [PATCH net-next] tipc: re-order conditions in tipc_crypto_key_rcv() Dan Carpenter
2025-01-17 18:02 ` Simon Horman
2025-01-20 12:20 ` 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).