lkml.org 
[lkml]   [2021]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH net v2] net: vlan: fix a UAF in vlan_dev_real_dev()
From
Date
> On Thu, 18 Nov 2021 09:46:24 +0800 Ziyang Xuan (William) wrote:
>>>> I think we should move the dev_hold() to ndo_init(), otherwise
>>>> it's hard to reason if destructor was invoked or not if
>>>> register_netdevice() errors out.
>>>
>>> Ziyang Xuan, do you intend to take care of this?
>>> .
>>
>> I am reading the related processes according to the problem scenario.
>> And I will give a more clear sequence and root cause as soon as possible
>> by some necessary tests.
>
> Okay, I still don't see the fix.
>
> Petr would you mind submitting since you have a repro handy?
> .
The sequence for the problem maybe as following:

=============================================================
# create vlan device
vlan_newlink [assume real_dev refcnt == 2 just referenced by itself]
register_vlan_dev
register_netdevice(vlan_dev) [success]
netdev_upper_dev_link [failed]
unregister_netdevice(vlan_dev) [failure process]
...
netdev_run_todo [vlan_dev]
vlan_dev_free(vlan_dev) [priv_destructor cb]
dev_put(real_dev) [real_dev refcnt == 1]

# delete real device
unregister_netdevice(real_dev) [real_dev refcnt == 1]
unregister_netdevice_many
dev_put(real_dev) [real_dev refcnt == 0]
net_set_todo(real_dev)
...
netdev_run_todo [real_dev]
netdev_wait_allrefs(real_dev) [real_dev refcnt == 0]
pr_emerg("unregister_netdevice: ...", ...)

I am thinking about how to fix the problem. priv_destructor() of the
net_device referenced not only by net_set_todo() but also failure process
in register_netdevice().

I need some time to test my some ideas. And anyone has good ideas, please
do not be stingy.

Thank you!


\
 
 \ /
  Last update: 2021-11-19 04:29    [W:0.092 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site