diff options
author | Cong Wang <[email protected]> | 2017-11-09 16:43:13 -0800 |
---|---|---|
committer | David S. Miller <[email protected]> | 2017-11-11 19:35:32 +0900 |
commit | 052d41c01b3a2e3371d66de569717353af489d63 (patch) | |
tree | 995570b6b32fea4c07ac142f608f40c6b2baa9fa /net/unix/sysctl_net_unix.c | |
parent | 2118df93b5e1742931da358c2b8804c46fd64490 (diff) |
vlan: fix a use-after-free in vlan_device_event()
After refcnt reaches zero, vlan_vid_del() could free
dev->vlan_info via RCU:
RCU_INIT_POINTER(dev->vlan_info, NULL);
call_rcu(&vlan_info->rcu, vlan_info_rcu_free);
However, the pointer 'grp' still points to that memory
since it is set before vlan_vid_del():
vlan_info = rtnl_dereference(dev->vlan_info);
if (!vlan_info)
goto out;
grp = &vlan_info->grp;
Depends on when that RCU callback is scheduled, we could
trigger a use-after-free in vlan_group_for_each_dev()
right following this vlan_vid_del().
Fix it by moving vlan_vid_del() before setting grp. This
is also symmetric to the vlan_vid_add() we call in
vlan_device_event().
Reported-by: Fengguang Wu <[email protected]>
Fixes: efc73f4bbc23 ("net: Fix memory leak - vlan_info struct")
Cc: Alexander Duyck <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Girish Moodalbail <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Reviewed-by: Girish Moodalbail <[email protected]>
Tested-by: Fengguang Wu <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Diffstat (limited to 'net/unix/sysctl_net_unix.c')
0 files changed, 0 insertions, 0 deletions