Skip to content

Commit

Permalink
mpls: fix possible use after free of device
Browse files Browse the repository at this point in the history
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: 03c5774 ("mpls: Per-device MPLS state")
Signed-off-by: Robert Shearman <[email protected]>
Acked-by: "Eric W. Biederman" <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
rshearman authored and davem330 committed Jun 8, 2015
1 parent e51000d commit 25cc8f0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion net/mpls/af_mpls.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ static void mpls_ifdown(struct net_device *dev)

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,
Expand Down
1 change: 1 addition & 0 deletions net/mpls/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct mpls_dev {
int input_enabled;

struct ctl_table_header *sysctl;
struct rcu_head rcu;
};

struct sk_buff;
Expand Down

0 comments on commit 25cc8f0

Please sign in to comment.