Skip to content

Commit d470ccc

Browse files
author
Xin Long
committed
tipc: re-order conditions in tipc_crypto_key_rcv()
JIRA: https://issues.redhat.com/browse/RHEL-115652 Tested: compile only commit 5fe71fd Author: Dan Carpenter <dan.carpenter@linaro.org> Date: Fri Jan 17 12:36:14 2025 +0300 tipc: re-order conditions in tipc_crypto_key_rcv() 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: Xin Long <lxin@redhat.com>
1 parent 392aea0 commit d470ccc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/tipc/crypto.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2302,8 +2302,8 @@ static bool tipc_crypto_key_rcv(struct tipc_crypto *rx, struct tipc_msg *hdr)
23022302
keylen = ntohl(*((__be32 *)(data + TIPC_AEAD_ALG_NAME)));
23032303

23042304
/* Verify the supplied size values */
2305-
if (unlikely(size != keylen + sizeof(struct tipc_aead_key) ||
2306-
keylen > TIPC_AEAD_KEY_SIZE_MAX)) {
2305+
if (unlikely(keylen > TIPC_AEAD_KEY_SIZE_MAX ||
2306+
size != keylen + sizeof(struct tipc_aead_key))) {
23072307
pr_debug("%s: invalid MSG_CRYPTO key size\n", rx->name);
23082308
goto exit;
23092309
}

0 commit comments

Comments
 (0)