summaryrefslogtreecommitdiff
path: root/net/tipc
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@linaro.org>2025-01-17 12:36:14 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-17 11:36:05 +0100
commit05f2f789b0cfa8ea382e6d607a83d6349236de85 (patch)
tree9cec4552613329f00d45bce923685f4776399319 /net/tipc
parentd990eefcbae0b9bec2b7f566ce862702045f6a6d (diff)
downloadlinux-05f2f789b0cfa8ea382e6d607a83d6349236de85.tar.gz
linux-05f2f789b0cfa8ea382e6d607a83d6349236de85.tar.bz2
linux-05f2f789b0cfa8ea382e6d607a83d6349236de85.zip
tipc: re-order conditions in tipc_crypto_key_rcv()
[ Upstream commit 5fe71fda89745fc3cd95f70d06e9162b595c3702 ] 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> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/crypto.c4
1 files 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;
}