Re: [PATCH] fix mem-leak in netfilter
From: Stephen Frost
Date: Wed May 17 2006 - 09:15:45 EST
* Patrick McHardy (kaber@xxxxxxxxx) wrote:
> OK, updated patch attached. The TTL is now always kept up-to-date.
Yup, that looks good. Unfortunately, it looks like the lru_list isn't
being kept track of correctly now. Perhaps I'm reading it wrong but it
*looks* like recent_entry_init() is only initializing the lru_list for
the local entry but doesn't ever add it to the main table lru_list. My
guess is you were expecting that to be done by recent_entry_update() but
it's never the case that recent_entry_update() is called directly after
recent_entry_init() due to the 'goto out' (my line 199). Therefore I'm
afraid that a new entry is never added to the lru_list with the current
setup and if nothing is ever updated you'll end up in a bad situation.
I think you can just drop lines 198 & 199 and modify recent_entry_init()
to not put the initial stamp in. This way, for a new entry to the list,
recent_entry_init() is called still on 195, the return value is updated
just like it would be for an existing entry, and recent_entry_update()
is called to handle adding the latest stamp and updating the lru_list.
Looking at list.h, I *think* that will work (wasn't sure if
list_move_tail() would be upset about the state of the e->lru_list
coming from INIT_LIST_HEAD but I think the __list_del will effectively
be a no-op and so it'll be fine).
Description: Digital signature