Re: [PATCH] netlink: fix memory leak of dump

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> 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.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux