mpls: fix possible use after free of device
The mpls device is used in an RCU read context without a lock being
held. As the memory is freed without waiting for the RCU grace period
to elapse, the freed memory could still be in use.
Address this by using kfree_rcu to free the memory for the mpls device
after the RCU grace period has elapsed.
Fixes: 03c57747a7
("mpls: Per-device MPLS state")
Signed-off-by: Robert Shearman <rshearma@brocade.com>
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e51000db4c
commit
25cc8f0763
@ -541,7 +541,7 @@ static void mpls_ifdown(struct net_device *dev)
|
|||||||
|
|
||||||
RCU_INIT_POINTER(dev->mpls_ptr, NULL);
|
RCU_INIT_POINTER(dev->mpls_ptr, NULL);
|
||||||
|
|
||||||
kfree(mdev);
|
kfree_rcu(mdev, rcu);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mpls_dev_notify(struct notifier_block *this, unsigned long event,
|
static int mpls_dev_notify(struct notifier_block *this, unsigned long event,
|
||||||
|
@ -16,6 +16,7 @@ struct mpls_dev {
|
|||||||
int input_enabled;
|
int input_enabled;
|
||||||
|
|
||||||
struct ctl_table_header *sysctl;
|
struct ctl_table_header *sysctl;
|
||||||
|
struct rcu_head rcu;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sk_buff;
|
struct sk_buff;
|
||||||
|
Loading…
Reference in New Issue
Block a user