tun: add mutex_unlock() call and napi.skb clearing in tun_get_user()
Subsystems (3)
PATCH 1/1 tun: add mutex_unlock() call and napi.skb clearing in tun_get_user()
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
--- drivers/net/tun.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/tun.c +4 -0
@@ -1936,6 +1936,10 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,if (ret !=XDP_PASS ) {rcu_read_unlock ();local_bh_enable (); +if (frags) { + tfile->napi.skb =NULL ; +mutex_unlock (&tfile->napi_mutex); + }return total_len; } }
Signature · 1 line
2.25.0.341.g760bfbb309-goog
David Miller
maintainerFrom: Eric Dumazet <[email protected]>
Date: Wed, 22 Jan 2020 09:07:35 -0800
Quoted 11 lines
If both
IFF_NAPI_FRAGSmode 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/0x3fc0drivers/net/tun.c:1835
Quoted 3 lines
Fixes 90e33d459407 ("tun: enable napi_gro_frags() for TUN/TAP driver")Signed-off-by Eric Dumazet <[email protected]>Reported-by syzbot <[email protected]>
Applied and queued up for -stable, thanks Eric.