From: Florian Westphal <fw@strlen.de>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Florian Westphal <fw@strlen.de>,
David Miller <davem@davemloft.net>,
cscnull@gmail.com, kadlec@blackhole.kfki.hu,
johannes.berg@intel.com, Jason@zx2c4.com, ktkhai@virtuozzo.com,
lucien.xin@gmail.com, xiyou.wangcong@gmail.com,
dsahern@gmail.com, netfilter-devel@vger.kernel.org,
tom@quantonium.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] netlink: fix memory leak of dump
Date: Mon, 23 Jul 2018 12:51:59 +0200 [thread overview]
Message-ID: <20180723105159.vpknxgam3fqeicvv@breakpoint.cc> (raw)
In-Reply-To: <20180723094742.gg6e73l6aknghal7@salvia>
Pablo Neira Ayuso <pablo@netfilter.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.
next prev parent reply other threads:[~2018-07-23 11:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-22 14:33 [PATCH] netlink: fix memory leak of dump Shaochun Chen
2018-07-22 16:39 ` Florian Westphal
2018-07-22 17:07 ` David Miller
2018-07-22 18:09 ` Florian Westphal
2018-07-23 2:05 ` shaochun chen
2018-07-23 9:15 ` Pablo Neira Ayuso
2018-07-23 9:28 ` Florian Westphal
2018-07-23 9:38 ` Pablo Neira Ayuso
2018-07-23 9:42 ` Florian Westphal
2018-07-23 9:47 ` Pablo Neira Ayuso
2018-07-23 10:51 ` Florian Westphal [this message]
2018-07-23 9:52 ` shaochun chen
2018-07-23 10:34 ` shaochun chen
2018-07-23 10:43 ` Pablo Neira Ayuso
2018-07-23 10:59 ` Florian Westphal
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=20180723105159.vpknxgam3fqeicvv@breakpoint.cc \
--to=fw@strlen.de \
--cc=Jason@zx2c4.com \
--cc=cscnull@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=johannes.berg@intel.com \
--cc=kadlec@blackhole.kfki.hu \
--cc=ktkhai@virtuozzo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lucien.xin@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=tom@quantonium.net \
--cc=xiyou.wangcong@gmail.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 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).