]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
netlink: fix state reallocation in policy export
authorJohannes Berg <johannes.berg@intel.com>
Wed, 19 Aug 2020 19:52:38 +0000 (21:52 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 19 Aug 2020 22:39:36 +0000 (15:39 -0700)
Evidently, when I did this previously, we didn't have more than
10 policies and didn't run into the reallocation path, because
it's missing a memset() for the unused policies. Fix that.

Fixes: d07dcf9aadd6 ("netlink: add infrastructure to expose policies to userspace")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/netlink/policy.c

index f6491853c797155cb564f3d075eb372d333c4bd9..2b3e26f7496f5f8a7e3880379907f4656219704a 100644 (file)
@@ -51,6 +51,9 @@ static int add_policy(struct nl_policy_dump **statep,
        if (!state)
                return -ENOMEM;
 
+       memset(&state->policies[state->n_alloc], 0,
+              flex_array_size(state, policies, n_alloc - state->n_alloc));
+
        state->policies[state->n_alloc].policy = policy;
        state->policies[state->n_alloc].maxtype = maxtype;
        state->n_alloc = n_alloc;