* [PATCH] ipt_recent: fix race between recent_mt_destroy and proc manipulations
@ 2008-07-23 21:29 Pavel Emelyanov
2008-07-30 10:52 ` Patrick McHardy
0 siblings, 1 reply; 2+ messages in thread
From: Pavel Emelyanov @ 2008-07-23 21:29 UTC (permalink / raw)
To: David Miller, Patrick McHardy
Cc: Linux Netdev List, Netfilter Development Mailinglist
The thing is that recent_mt_destroy first flushes the entries
from table with the recent_table_flush and only *after* this
removes the proc file, corresponding to that table.
Thus, if we manage to write to this file the '+XXX' command we
will leak some entries. If we manage to write there a 'clean'
command we'll race in two recent_table_flush flows, since the
recent_mt_destroy calls this outside the recent_lock.
The proper solution as I see it is to remove the proc file first
and then go on with flushing the table. This flushing becomes
safe w/o the lock, since the table is already inaccessible from
the outside.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
diff --git a/net/ipv4/netfilter/ipt_recent.c b/net/ipv4/netfilter/ipt_recent.c
index 21cb053..3974d7c 100644
--- a/net/ipv4/netfilter/ipt_recent.c
+++ b/net/ipv4/netfilter/ipt_recent.c
@@ -305,10 +305,10 @@ static void recent_mt_destroy(const struct xt_match *match, void *matchinfo)
spin_lock_bh(&recent_lock);
list_del(&t->list);
spin_unlock_bh(&recent_lock);
- recent_table_flush(t);
#ifdef CONFIG_PROC_FS
remove_proc_entry(t->name, proc_dir);
#endif
+ recent_table_flush(t);
kfree(t);
}
mutex_unlock(&recent_mutex);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ipt_recent: fix race between recent_mt_destroy and proc manipulations
2008-07-23 21:29 [PATCH] ipt_recent: fix race between recent_mt_destroy and proc manipulations Pavel Emelyanov
@ 2008-07-30 10:52 ` Patrick McHardy
0 siblings, 0 replies; 2+ messages in thread
From: Patrick McHardy @ 2008-07-30 10:52 UTC (permalink / raw)
To: Pavel Emelyanov
Cc: David Miller, Linux Netdev List,
Netfilter Development Mailinglist
Pavel Emelyanov wrote:
> The thing is that recent_mt_destroy first flushes the entries
> from table with the recent_table_flush and only *after* this
> removes the proc file, corresponding to that table.
>
> Thus, if we manage to write to this file the '+XXX' command we
> will leak some entries. If we manage to write there a 'clean'
> command we'll race in two recent_table_flush flows, since the
> recent_mt_destroy calls this outside the recent_lock.
>
> The proper solution as I see it is to remove the proc file first
> and then go on with flushing the table. This flushing becomes
> safe w/o the lock, since the table is already inaccessible from
> the outside.
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-07-30 10:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-23 21:29 [PATCH] ipt_recent: fix race between recent_mt_destroy and proc manipulations Pavel Emelyanov
2008-07-30 10:52 ` Patrick McHardy
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).