Skip to contentSkip to conversation

fix 'icmp-type all' problem in iptables

PATCH Applied Harald Welte 3 participants 3 messages Feb 26, 2003 – Mar 3, 2003

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

PATCH 1/1 fix 'icmp-type all' problem in iptables

Hi Dave!

Here is the first of yet another set of iptables bugfixes for 2.4.x and 2.5.x:

Up to now the problem was:

	'-p icmp ' matches all icmp packets
	'-p icmp -m icmp' matches _only_ ICMP type 0 :(

This is now fixed by initializing the field in userspace to the bogus icmp type 0xFF. Old kernels (prior to this patch) would then match packets with icmp-type 255 [which should never happen since it is undefined). New kernels with this patch have an explicit check for the 'magic value' 0xFF.

See also: https://bugzilla.netfilter.org/cgi-bin/bugzilla/show_bug.cgi?id=37

Credits go to Filip Sneppe (Cronos)" <[email protected]>

Please apply, thanks.

net/ipv4/netfilter/ip_tables.c Sun Feb 23 12:58:32 2003 renamed from net/ipv4/netfilter/ip_tables.c Fri Nov 29 00:53:15 2002 +1 -1
diff -urN linux-2.4.20/net/ipv4/netfilter/ip_tables.c linux-2.4.20-icmp/net/ipv4/netfilter/ip_tables.c
@@ -1630,7 +1630,7 @@
                     u_int8_t type, u_int8_t code,
                     int invert)
 {
-       return (type == test_type && code >= min_code && code <= max_code)
+       return ((test_type == 0xFF) || (type == test_type && code >= min_code && code <= max_code))
                ^ invert;
 }
 
Signature · 5 lines
- Harald Welte <[email protected]>             http://www.netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie