Skip to contentSkip to conversation

Fix possible oops in ipt_REDIRECT

PATCH New Bart De Schuymer 1 participant 1 message Oct 20, 2003

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

PATCH 1/1 Fix possible oops in ipt_REDIRECT

Hi Harald,

When a device doesn't have an IP address, as in ifconfig eth0 0.0.0.0, then dev->ip_ptr->indev == NULL.
It is possible to craft a packet that oopses the kernel:
Suppose eth0 on box 1 was brought up with ifconfig eth0 0.0.0.0 Suppose the iptabes nat table on box 1 contains one rule: -j REDIRECT Use box 2, connected to box1 via box1's eth0 to oops the kernel:
box2# arp 192.168.123.166 $MAC_OF_ETH0
box2# ping 192.168.123.166
Oops.

By the way, what are your plans with the fix for ip_queue I sent you on this list?

Bart

net/ipv4/netfilter/ipt_REDIRECT.c renamed from net/ipv4/netfilter/ipt_REDIRECT.c.old +1 -1
@@ -83,7 +83,7 @@ redirect_target(struct sk_buff **pskb,
 
 		/* Device might not have an associated in_device. */
 		indev = (struct in_device *)(*pskb)->dev->ip_ptr;
-		if (indev == NULL)
+		if (indev == NULL || indev->ifa_list == NULL)
 			return NF_DROP;
 
 		/* Grab first address on interface. */
net/ipv4/netfilter/ipt_REDIRECT.c renamed from net/ipv4/netfilter/ipt_REDIRECT.c.old +1 -1
@@ -79,7 +79,7 @@ redirect_target(struct sk_buff **pskb,
 
 		/* Device might not have an associated in_device. */
 		indev = (struct in_device *)(*pskb)->dev->ip_ptr;
-		if (indev == NULL)
+		if (indev == NULL || indev->ifa_list == NULL)
 			return NF_DROP;
 
 		/* Grab first address on interface. */