Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: netdev@vger.kernel.org, Johannes Berg <johannes.berg@intel.com>
Subject: Re: [PATCH] netlink: fix state reallocation in policy export
Date: Wed, 19 Aug 2020 12:10:06 -0700	[thread overview]
Message-ID: <20200819121006.7f6615e4@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <20200819122255.6b32aa54d205.I316de8a67c79a393ae1826a1b2dcc08f31b1856e@changeid>

On Wed, 19 Aug 2020 12:22:55 +0200 Johannes Berg wrote:
> 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>
> ---
>  net/netlink/policy.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/net/netlink/policy.c b/net/netlink/policy.c
> index f6491853c797..3f3b421fd70c 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,
> +	       sizeof(state->policies[0]) * (n_alloc - state->n_alloc));


[flex_]array_size() ? To avoid the inevitable follow up from a bot..

  reply	other threads:[~2020-08-19 19:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-19 10:22 Johannes Berg
2020-08-19 19:10 ` Jakub Kicinski [this message]
2020-08-19 19:52   ` Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200819121006.7f6615e4@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
    --to=kuba@kernel.org \
    --cc=johannes.berg@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=netdev@vger.kernel.org \
    --subject='Re: [PATCH] netlink: fix state reallocation in policy export' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).