]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ipvs: prevent integer overflow in do_ip_vs_get_ctl()
authorDan Carpenter <dan.carpenter@linaro.org>
Mon, 10 Mar 2025 07:45:53 +0000 (10:45 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 Mar 2025 19:54:13 +0000 (12:54 -0700)
commite6cb63fac7fd872ed53cd8694e8b76711a0e9b98
tree3770bc9a9e9e0bded189d1b0edb7d4f63cf2a4be
parentdb1e0c0856821c59a32ea3af79476bf20a6beeb2
ipvs: prevent integer overflow in do_ip_vs_get_ctl()

[ Upstream commit 80b78c39eb86e6b55f56363b709eb817527da5aa ]

The get->num_services variable is an unsigned int which is controlled by
the user.  The struct_size() function ensures that the size calculation
does not overflow an unsigned long, however, we are saving the result to
an int so the calculation can overflow.

Both "len" and "get->num_services" come from the user.  This check is
just a sanity check to help the user and ensure they are using the API
correctly.  An integer overflow here is not a big deal.  This has no
security impact.

Save the result from struct_size() type size_t to fix this integer
overflow bug.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netfilter/ipvs/ip_vs_ctl.c