aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2005-09-13 13:48:58 -0700
committerDavid S. Miller <davem@davemloft.net>2005-09-13 13:48:58 -0700
commitcd0bf2d796ebb51c346b1ed4208cdbfd86e98a61 (patch)
tree2ea4c92974433cbb0ebb088749d88e80380ee7cd /net
parente7fa1bd93f977c03050bd6b3d13846aa43310fef (diff)
downloadkernel_samsung_smdk4412-cd0bf2d796ebb51c346b1ed4208cdbfd86e98a61.zip
kernel_samsung_smdk4412-cd0bf2d796ebb51c346b1ed4208cdbfd86e98a61.tar.gz
kernel_samsung_smdk4412-cd0bf2d796ebb51c346b1ed4208cdbfd86e98a61.tar.bz2
[NETFILTER]: Fix rcu race in ipt_REDIRECT
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/netfilter/ipt_REDIRECT.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/net/ipv4/netfilter/ipt_REDIRECT.c b/net/ipv4/netfilter/ipt_REDIRECT.c
index d2e1344..715cb61 100644
--- a/net/ipv4/netfilter/ipt_REDIRECT.c
+++ b/net/ipv4/netfilter/ipt_REDIRECT.c
@@ -88,14 +88,18 @@ redirect_target(struct sk_buff **pskb,
newdst = htonl(0x7F000001);
else {
struct in_device *indev;
+ struct in_ifaddr *ifa;
- /* Device might not have an associated in_device. */
- indev = (struct in_device *)(*pskb)->dev->ip_ptr;
- if (indev == NULL || indev->ifa_list == NULL)
- return NF_DROP;
+ newdst = 0;
+
+ rcu_read_lock();
+ indev = __in_dev_get((*pskb)->dev);
+ if (indev && (ifa = indev->ifa_list))
+ newdst = ifa->ifa_local;
+ rcu_read_unlock();
- /* Grab first address on interface. */
- newdst = indev->ifa_list->ifa_local;
+ if (!newdst)
+ return NF_DROP;
}
/* Transfer from original range. */