Commit f2868da9 authored by Herbert Xu's avatar Herbert Xu Committed by James Morris

[IPV4]: Fix race in inetdev RCU handling.

parent 1bffa251
...@@ -158,16 +158,10 @@ __in_dev_get(const struct net_device *dev) ...@@ -158,16 +158,10 @@ __in_dev_get(const struct net_device *dev)
extern void in_dev_finish_destroy(struct in_device *idev); extern void in_dev_finish_destroy(struct in_device *idev);
static inline void in_dev_rcu_destroy(struct rcu_head *head)
{
struct in_device *idev = container_of(head, struct in_device, rcu_head);
in_dev_finish_destroy(idev);
}
static inline void in_dev_put(struct in_device *idev) static inline void in_dev_put(struct in_device *idev)
{ {
if (atomic_dec_and_test(&idev->refcnt)) if (atomic_dec_and_test(&idev->refcnt))
call_rcu(&idev->rcu_head, in_dev_rcu_destroy); in_dev_finish_destroy(idev);
} }
#define __in_dev_put(idev) atomic_dec(&(idev)->refcnt) #define __in_dev_put(idev) atomic_dec(&(idev)->refcnt)
......
...@@ -177,6 +177,12 @@ struct in_device *inetdev_init(struct net_device *dev) ...@@ -177,6 +177,12 @@ struct in_device *inetdev_init(struct net_device *dev)
goto out; goto out;
} }
static void in_dev_rcu_put(struct rcu_head *head)
{
struct in_device *idev = container_of(head, struct in_device, rcu_head);
in_dev_put(idev);
}
static void inetdev_destroy(struct in_device *in_dev) static void inetdev_destroy(struct in_device *in_dev)
{ {
struct in_ifaddr *ifa; struct in_ifaddr *ifa;
...@@ -204,7 +210,7 @@ static void inetdev_destroy(struct in_device *in_dev) ...@@ -204,7 +210,7 @@ static void inetdev_destroy(struct in_device *in_dev)
neigh_sysctl_unregister(in_dev->arp_parms); neigh_sysctl_unregister(in_dev->arp_parms);
#endif #endif
neigh_parms_release(&arp_tbl, in_dev->arp_parms); neigh_parms_release(&arp_tbl, in_dev->arp_parms);
in_dev_put(in_dev); call_rcu(&in_dev->rcu_head, in_dev_rcu_put);
} }
int inet_addr_onlink(struct in_device *in_dev, u32 a, u32 b) int inet_addr_onlink(struct in_device *in_dev, u32 a, u32 b)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment