From: Johannes Berg Date: Wed, 19 Aug 2020 19:52:38 +0000 (+0200) Subject: netlink: fix state reallocation in policy export X-Git-Tag: v5.8.5~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3f4be7a7db9fa51929ea22f0cdcfa0abdbf1573f;p=thirdparty%2Fkernel%2Fstable.git netlink: fix state reallocation in policy export [ Upstream commit d1fb55592909ea249af70170c7a52e637009564d ] 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 Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/netlink/policy.c b/net/netlink/policy.c index f6491853c7971..2b3e26f7496f5 100644 --- a/net/netlink/policy.c +++ b/net/netlink/policy.c @@ -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;