Skip to contentSkip to conversation

https://bugzilla.kernel.org/show_bug.cgi?id=207773

DISCUSSION Reindl Harald 2 participants 6 messages Jan 27, 2021

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

Hi,

Quoted 2 lines · Reindl Harald

for the sake of god may someone look at this?
https://bugzilla.kernel.org/show_bug.cgi?id=207773

Could you send your iptables rules and at least the set definitions without the set contents? I need to reproduce the issue.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : https://wigner.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics

          H-1525 Budapest 114, POB. 49, Hungary
#2 lore raw

Am 27.01.21 um 14:38 schrieb Jozsef Kadlecsik:

Quoted 9 lines

Hi,

Quoted 2 lines · Reindl Harald

for the sake of god may someone look at this?
https://bugzilla.kernel.org/show_bug.cgi?id=207773

Could you send your iptables rules and at least the set definitions without the set contents? I need to reproduce the issue.

is offlist OK?
that's the companies "datacenter firewall"

#3 lore raw
Quoted 11 lines · Reindl Harald

Am 27.01.21 um 14:38 schrieb Jozsef Kadlecsik:

Quoted 8 lines · Reindl Harald
Quoted 3 lines

for the sake of god may someone look at this?
https://bugzilla.kernel.org/show_bug.cgi?id=207773

Could you send your iptables rules and at least the set definitions without the set contents? I need to reproduce the issue.

is offlist OK? that's the companies "datacenter firewall"

That's OK and private data remains private.

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : https://wigner.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics

          H-1525 Budapest 114, POB. 49, Hungary
#4 lore raw
In reply to Jozsef Kadlecsik

Hi,

Quoted 7 lines · Jozsef Kadlecsik
Quoted 2 lines · Reindl Harald

for the sake of god may someone look at this?
https://bugzilla.kernel.org/show_bug.cgi?id=207773

Could you send your iptables rules and at least the set definitions without the set contents? I need to reproduce the issue.

Checking your rules, you have got a recent match in which you use both the --reap and --update flags. However, as far as I see the code leaves the possibility open that the recent entry to be updated is reaped, which then leads to the crash.

The following patch should fix the issue - however, I could not test it:

net/netfilter/xt_recent.c +10 -2
index 606411869698..0446307516cd 100644
@@ -152,7 +152,8 @@ static void recent_entry_remove(struct recent_table *t, struct recent_entry *e)
 /*
  * Drop entries with timestamps older then 'time'.
  */
-static void recent_entry_reap(struct recent_table *t, unsigned long time)
+static void recent_entry_reap(struct recent_table *t, unsigned long time,
+			      struct recent_entry *working, bool update)
 {
 	struct recent_entry *e;
 
@@ -161,6 +162,12 @@ static void recent_entry_reap(struct recent_table *t, unsigned long time)
 	 */
 	e = list_entry(t->lru_list.next, struct recent_entry, lru_list);
 
+	/*
+	 * Do not reap the entry which are going to be updated.
+	 */
+	if (e == working && update)
+		return;
+
 	/*
 	 * The last time stamp is the most recent.
 	 */
@@ -303,7 +310,8 @@ recent_mt(const struct sk_buff *skb, struct xt_action_param *par)
 
 		/* info->seconds must be non-zero */
 		if (info->check_set & XT_RECENT_REAP)
-			recent_entry_reap(t, time);
+			recent_entry_reap(t, time, e,
+				info->check_set & XT_RECENT_UPDATE && ret);
 	}
 
 	if (info->check_set & XT_RECENT_SET ||

Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : https://wigner.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics

          H-1525 Budapest 114, POB. 49, Hungary
#5 lore raw

Am 28.01.21 um 00:13 schrieb Jozsef Kadlecsik:

Quoted 6 lines

Hi,

Quoted 2 lines · Jozsef Kadlecsik

On Wed, 27 Jan 2021, Reindl Harald wrote:

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

for the sake of god may someone look at this?
https://bugzilla.kernel.org/show_bug.cgi?id=207773

Could you send your iptables rules and at least the set definitions without the set contents? I need to reproduce the issue.

Checking your rules, you have got a recent match in which you use both the --reap and --update flags.

which makes sense

Quoted 3 lines

However, as far as I see the code leaves the
possibility open that the recent entry to be updated is reaped, which then leads to the crash.

thanks for checking

Quoted 1 line

The following patch should fix the issue - however, I could not test it

hopefully this makes it into a near future kernel update, i rely on distribution packages and Fedora is pretty quick