[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180723105159.vpknxgam3fqeicvv@breakpoint.cc>
Date: Mon, 23 Jul 2018 12:51:59 +0200
From: Florian Westphal <fw@...len.de>
To: Pablo Neira Ayuso <pablo@...filter.org>
Cc: Florian Westphal <fw@...len.de>,
David Miller <davem@...emloft.net>, cscnull@...il.com,
kadlec@...ckhole.kfki.hu, johannes.berg@...el.com, Jason@...c4.com,
ktkhai@...tuozzo.com, lucien.xin@...il.com,
xiyou.wangcong@...il.com, dsahern@...il.com,
netfilter-devel@...r.kernel.org, tom@...ntonium.net,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] netlink: fix memory leak of dump
Pablo Neira Ayuso <pablo@...filter.org> wrote:
> On Mon, Jul 23, 2018 at 11:42:28AM +0200, Florian Westphal wrote:
> We can also add another scratchpad area, similar to the ->cb[x] area
> that can be initialized before netlink_dump_start()? So we don't need
> the data pointer.
>
> By passing the array of attributes, we'll need to do attribute parsing
> over and over again from each netlink_dump() call.
Its still done once, parsing is only delayed/moved to ->start().
Now:
nla_parse
control->data = kmalloc() + init
netlink_dump_start()
->start() /* if it returns 0, done() will be called eventually
netlink_dump()
->done()
free(cb->data);
Proposed fix:
control->data = &on_stack;
netlink_dump_start()
->start()
nla_parse
cb->data = kmalloc() + init
netlink_dump()
->done()
free(cb->data);
I've submitted a patch for nf_tables, let me know if you have a better
idea or see a problem with it.
Powered by blists - more mailing lists