[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yvq16sC3Pytaf04k@macondo>
Date: Mon, 15 Aug 2022 18:08:58 -0300
From: Rafael Soares <rafaelmendsr@...il.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: davem@...emloft.net, netdev@...r.kernel.org, edumazet@...gle.com,
pabeni@...hat.com, johannes.berg@...el.com,
syzbot+dc54d9ba8153b216cae0@...kaller.appspotmail.com
Subject: Re: [PATCH net] net: genl: fix error path memory leak in policy
dumping
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@...kaller.appspotmail.com
> Fixes: 50a896cf2d6f ("genetlink: properly support per-op policy dumping")
> Signed-off-by: Jakub Kicinski <kuba@...nel.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
>
Powered by blists - more mailing lists