Skip to content

Commit b1bdde3

Browse files
Jozsef Kadlecsikummakynes
authored andcommitted
netfilter: xt_recent: Fix attempt to update deleted entry
When both --reap and --update flag are specified, there's a code path at which the entry to be updated is reaped beforehand, which then leads to kernel crash. Reap only entries which won't be updated. Fixes kernel bugzilla #207773. Link: https://bugzilla.kernel.org/show_bug.cgi?id=207773 Reported-by: Reindl Harald <h.reindl@thelounge.net> Fixes: 0079c5a ("netfilter: xt_recent: add an entry reaper") Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 44a674d commit b1bdde3

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

net/netfilter/xt_recent.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ static void recent_entry_remove(struct recent_table *t, struct recent_entry *e)
152152
/*
153153
* Drop entries with timestamps older then 'time'.
154154
*/
155-
static void recent_entry_reap(struct recent_table *t, unsigned long time)
155+
static void recent_entry_reap(struct recent_table *t, unsigned long time,
156+
struct recent_entry *working, bool update)
156157
{
157158
struct recent_entry *e;
158159

@@ -161,6 +162,12 @@ static void recent_entry_reap(struct recent_table *t, unsigned long time)
161162
*/
162163
e = list_entry(t->lru_list.next, struct recent_entry, lru_list);
163164

165+
/*
166+
* Do not reap the entry which are going to be updated.
167+
*/
168+
if (e == working && update)
169+
return;
170+
164171
/*
165172
* The last time stamp is the most recent.
166173
*/
@@ -303,7 +310,8 @@ recent_mt(const struct sk_buff *skb, struct xt_action_param *par)
303310

304311
/* info->seconds must be non-zero */
305312
if (info->check_set & XT_RECENT_REAP)
306-
recent_entry_reap(t, time);
313+
recent_entry_reap(t, time, e,
314+
info->check_set & XT_RECENT_UPDATE && ret);
307315
}
308316

309317
if (info->check_set & XT_RECENT_SET ||

0 commit comments

Comments
 (0)