tipc: Use size_add() in calls to struct_size()
authorGustavo A. R. Silva <gustavoars@kernel.org>
Fri, 15 Sep 2023 19:16:26 +0000 (13:16 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 10:58:57 +0000 (11:58 +0100)
commit85572d9debe90b6f7ae6e55da7373134a45adf94
tree7170f29de4a00900382b1b401eb3806897ccacae
parent4c7f066b7b7c127626d428ad18289f912ac42f93
tipc: Use size_add() in calls to struct_size()

[ Upstream commit 2506a91734754de690869824fb0d1ac592ec1266 ]

If, for any reason, the open-coded arithmetic causes a wraparound,
the protection that `struct_size()` adds against potential integer
overflows is defeated. Fix this by hardening call to `struct_size()`
with `size_add()`.

Fixes: e034c6d23bc4 ("tipc: Use struct_size() helper")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/tipc/link.c