]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
tun: add mutex_unlock() call and napi.skb clearing in tun_get_user()
authorEric Dumazet <edumazet@google.com>
Wed, 22 Jan 2020 17:07:35 +0000 (09:07 -0800)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 6 Mar 2020 07:13:20 +0000 (02:13 -0500)
commitbf6567d784e52fab21e4490740145c169452f5d9
tree89e66fc998faa089b95ab0d3faad11fba17a79bf
parent4e8a57dd4ef0b5596676821d98f1d5e69e849430
tun: add mutex_unlock() call and napi.skb clearing in tun_get_user()

BugLink: https://bugs.launchpad.net/bugs/1864261
[ Upstream commit 1efba987c48629c0c64703bb4ea76ca1a3771d17 ]

If both IFF_NAPI_FRAGS mode and XDP are enabled, and the XDP program
consumes the skb, we need to clear the napi.skb (or risk
a use-after-free) and release the mutex (or risk a deadlock)

WARNING: lock held when returning to user space!
5.5.0-rc6-syzkaller #0 Not tainted
------------------------------------------------
syz-executor.0/455 is leaving the kernel with locks still held!
1 lock held by syz-executor.0/455:
 #0: ffff888098f6e748 (&tfile->napi_mutex){+.+.}, at: tun_get_user+0x1604/0x3fc0 drivers/net/tun.c:1835

Fixes: 90e33d459407 ("tun: enable napi_gro_frags() for TUN/TAP driver")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot <syzkaller@googlegroups.com>
Cc: Petar Penkov <ppenkov@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/net/tun.c