mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-06 11:54:14 -04:00
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: 1da177e4c3 ("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>
This commit is contained in:
parent
f522229c55
commit
ab45c0ee54
1 changed files with 4 additions and 4 deletions
|
|
@ -2809,12 +2809,12 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
|
|||
case IP_VS_SO_GET_SERVICES:
|
||||
{
|
||||
struct ip_vs_get_services *get;
|
||||
int size;
|
||||
size_t size;
|
||||
|
||||
get = (struct ip_vs_get_services *)arg;
|
||||
size = struct_size(get, entrytable, get->num_services);
|
||||
if (*len != size) {
|
||||
pr_err("length: %u != %u\n", *len, size);
|
||||
pr_err("length: %u != %zu\n", *len, size);
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -2850,12 +2850,12 @@ do_ip_vs_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
|
|||
case IP_VS_SO_GET_DESTS:
|
||||
{
|
||||
struct ip_vs_get_dests *get;
|
||||
int size;
|
||||
size_t size;
|
||||
|
||||
get = (struct ip_vs_get_dests *)arg;
|
||||
size = struct_size(get, entrytable, get->num_dests);
|
||||
if (*len != size) {
|
||||
pr_err("length: %u != %u\n", *len, size);
|
||||
pr_err("length: %u != %zu\n", *len, size);
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue