Commit e0e8f1c8 authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

[IPSEC] flow: Fix potential memory leak

When old flow cache entries that are not at the head of their chain
trigger a transient security error they get unlinked along with all
the entries preceding them in the chain.  The preceding entries are
not freed correctly.

This patch fixes this by simply leaving the entry around.  It's based
on a suggestion by Venkat Yekkirala.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 419dd837
...@@ -231,22 +231,16 @@ void *flow_cache_lookup(struct flowi *key, u16 family, u8 dir, ...@@ -231,22 +231,16 @@ void *flow_cache_lookup(struct flowi *key, u16 family, u8 dir,
err = resolver(key, family, dir, &obj, &obj_ref); err = resolver(key, family, dir, &obj, &obj_ref);
if (fle) { if (fle && !err) {
if (err) { fle->genid = atomic_read(&flow_cache_genid);
/* Force security policy check on next lookup */
*head = fle->next; if (fle->object)
flow_entry_kill(cpu, fle); atomic_dec(fle->object_ref);
} else {
fle->genid = atomic_read(&flow_cache_genid); fle->object = obj;
fle->object_ref = obj_ref;
if (fle->object) if (obj)
atomic_dec(fle->object_ref); atomic_inc(fle->object_ref);
fle->object = obj;
fle->object_ref = obj_ref;
if (obj)
atomic_inc(fle->object_ref);
}
} }
local_bh_enable(); local_bh_enable();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment