Fix possible oops in ipt_REDIRECT
Subsystems (2)
PATCH 1/1 Fix possible oops in ipt_REDIRECT
Hi Dave,
When a device doesn't have an IP address, as in ifconfig eth0 0.0.0.0, then dev->ip_ptr->ifa_list == NULL.
It is then 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:
box1# iptables -t nat -A PREROUTING -j REDIRECT
Use box 2, connected to box1 via box1's eth0 to oops the kernel:
box2# arp -s 192.168.123.166 $MAC_OF_ETH0_OF_BOX1 box2# ping 192.168.123.166
Oops on box 1.
(Change 192.168.123.166 into an IP address of the local network)
cheers,
Bart
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. */
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. */
David S. Miller
AppliedQuoted 2 lines · On Sat, 25 Oct 2003 17:28:56 +0200 Bart De Schuymer <[email protected]> wrote:
When a device doesn't have an IP address, as in ifconfig eth0 0.0.0.0, then
dev->ip_ptr->ifa_list== NULL.
Indeed, fix looks good to me.
Applied, thanks Bart.