]> git.baikalelectronics.ru Git - kernel.git/commit
tun: fix use after free for ptr_ring
authorJason Wang <jasowang@redhat.com>
Fri, 11 May 2018 02:49:25 +0000 (10:49 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 14 May 2018 18:47:08 +0000 (14:47 -0400)
commit04e6a1743d7bfd36bb0f036c0f825943853338c3
treebf4cfa7348baeb70a36b0d7aae5ab02fbe5c5649
parentfa28feff536f0b555cf021c024bebfb7f189d8cb
tun: fix use after free for ptr_ring

We used to initialize ptr_ring during TUNSETIFF, this is because its
size depends on the tx_queue_len of netdevice. And we try to clean it
up when socket were detached from netdevice. A race were spotted when
trying to do uninit during a read which will lead a use after free for
pointer ring. Solving this by always initialize a zero size ptr_ring
in open() and do resizing during TUNSETIFF, and then we can safely do
cleanup during close(). With this, there's no need for the workaround
that was introduced by commit cf6a0809b3ce ("tun: fix a memory leak
for tfile->tx_array").

Reported-by: syzbot+e8b902c3c3fadf0a9dba@syzkaller.appspotmail.com
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Michael S. Tsirkin <mst@redhat.com>
Fixes: 078ba52f13e7 ("tun: switch to use skb array for tx")
Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/tun.c