All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] netlink: fix state reallocation in policy export
@ 2020-08-19 19:52 Johannes Berg
  2020-08-19 22:40 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Johannes Berg @ 2020-08-19 19:52 UTC (permalink / raw)
  To: netdev; +Cc: Johannes Berg

From: Johannes Berg <johannes.berg@intel.com>

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>
---
v2:
 * use flex_array_size()
---
 net/netlink/policy.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/netlink/policy.c b/net/netlink/policy.c
index f6491853c797..2b3e26f7496f 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;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] netlink: fix state reallocation in policy export
  2020-08-19 19:52 [PATCH v2] netlink: fix state reallocation in policy export Johannes Berg
@ 2020-08-19 22:40 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-08-19 22:40 UTC (permalink / raw)
  To: johannes; +Cc: netdev, johannes.berg

From: Johannes Berg <johannes@sipsolutions.net>
Date: Wed, 19 Aug 2020 21:52:38 +0200

> From: Johannes Berg <johannes.berg@intel.com>
> 
> 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>

Applied and queued up for -stable, thanks Johannes.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-08-19 22:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-19 19:52 [PATCH v2] netlink: fix state reallocation in policy export Johannes Berg
2020-08-19 22:40 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.