All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rafael Soares <rafaelmendsr@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@google.com,
	pabeni@redhat.com, johannes.berg@intel.com,
	syzbot+dc54d9ba8153b216cae0@syzkaller.appspotmail.com
Subject: Re: [PATCH net] net: genl: fix error path memory leak in policy dumping
Date: Mon, 15 Aug 2022 18:08:58 -0300	[thread overview]
Message-ID: <Yvq16sC3Pytaf04k@macondo> (raw)
In-Reply-To: <20220815182021.48925-1-kuba@kernel.org>

On Mon, Aug 15, 2022 at 11:20:21AM -0700, Jakub Kicinski wrote:
> If construction of the array of policies fails when recording
> non-first policy we need to unwind.
> 
> Reported-by: syzbot+dc54d9ba8153b216cae0@syzkaller.appspotmail.com
> Fixes: 50a896cf2d6f ("genetlink: properly support per-op policy dumping")
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> ---
>  net/netlink/genetlink.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
> index 1afca2a6c2ac..57010927e20a 100644
> --- a/net/netlink/genetlink.c
> +++ b/net/netlink/genetlink.c
> @@ -1174,13 +1174,17 @@ static int ctrl_dumppolicy_start(struct netlink_callback *cb)
>  							     op.policy,
>  							     op.maxattr);
>  			if (err)
> -				return err;
> +				goto err_free_state;

There's another call to netlink_policy_dump_add_policy() right above
this one. The patch I posted to syzkaller frees the memory inside
netlink_policy_dump_add_policy() and the result was OK.

>  		}
>  	}
>  
>  	if (!ctx->state)
>  		return -ENODATA;
>  	return 0;
> +
> +err_free_state:
> +	netlink_policy_dump_free(ctx->state);
> +	return err;
>  }
>  
>  static void *ctrl_dumppolicy_prep(struct sk_buff *skb,
> -- 
> 2.37.2
> 

  reply	other threads:[~2022-08-16  5:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 18:20 [PATCH net] net: genl: fix error path memory leak in policy dumping Jakub Kicinski
2022-08-15 21:08 ` Rafael Soares [this message]
2022-08-16  1:51   ` Jakub Kicinski
2022-08-16  1:23 ` Jakub Kicinski

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=Yvq16sC3Pytaf04k@macondo \
    --to=rafaelmendsr@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=johannes.berg@intel.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=syzbot+dc54d9ba8153b216cae0@syzkaller.appspotmail.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.