lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20190912.121833.160552401560653311.davem@davemloft.net>
Date:   Thu, 12 Sep 2019 12:18:33 +0200 (CEST)
From:   David Miller <davem@...emloft.net>
To:     yangyingliang@...wei.com
Cc:     netdev@...r.kernel.org, jasowang@...hat.com,
        eric.dumazet@...il.com, xiyou.wangcong@...il.com,
        weiyongjun1@...wei.com
Subject: Re: [PATCH v4] tun: fix use-after-free when register netdev failed

From: Yang Yingliang <yangyingliang@...wei.com>
Date: Tue, 10 Sep 2019 18:56:57 +0800

> I got a UAF repport in tun driver when doing fuzzy test:
 ...
> tun_chr_read_iter() accessed the memory which freed by free_netdev()
> called by tun_set_iff():
> 
>         CPUA                                           CPUB
>   tun_set_iff()
>     alloc_netdev_mqs()
>     tun_attach()
>                                                   tun_chr_read_iter()
>                                                     tun_get()
>                                                     tun_do_read()
>                                                       tun_ring_recv()
>     register_netdevice() <-- inject error
>     goto err_detach
>     tun_detach_all() <-- set RCV_SHUTDOWN
>     free_netdev() <-- called from
>                      err_free_dev path
>       netdev_freemem() <-- free the memory
>                         without check refcount
>       (In this path, the refcount cannot prevent
>        freeing the memory of dev, and the memory
>        will be used by dev_put() called by
>        tun_chr_read_iter() on CPUB.)
>                                                      (Break from tun_ring_recv(),
>                                                      because RCV_SHUTDOWN is set)
>                                                    tun_put()
>                                                      dev_put() <-- use the memory
>                                                                    freed by netdev_freemem()
> 
> Put the publishing of tfile->tun after register_netdevice(),
> so tun_get() won't get the tun pointer that freed by
> err_detach path if register_netdevice() failed.
> 
> Fixes: eb0fb363f920 ("tuntap: attach queue 0 before registering netdevice")
> Reported-by: Hulk Robot <hulkci@...wei.com>
> Suggested-by: Jason Wang <jasowang@...hat.com>
> Signed-off-by: Yang Yingliang <yangyingliang@...wei.com>

Applied, thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ