* [PATCH net] tun: add mutex_unlock() call and napi.skb clearing in tun_get_user()
@ 2020-01-22 17:07 Eric Dumazet
2020-01-23 10:44 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2020-01-22 17:07 UTC (permalink / raw)
To: David S . Miller
Cc: netdev, Eric Dumazet, Eric Dumazet, syzbot, Petar Penkov,
Willem de Bruijn
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>
---
drivers/net/tun.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 683d371e6e82063bec7ade102a3b40aa38b1b6af..35e884a8242d95a4e866ad740a234face2fa0ac0 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -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;
}
}
--
2.25.0.341.g760bfbb309-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] tun: add mutex_unlock() call and napi.skb clearing in tun_get_user()
2020-01-22 17:07 [PATCH net] tun: add mutex_unlock() call and napi.skb clearing in tun_get_user() Eric Dumazet
@ 2020-01-23 10:44 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-01-23 10:44 UTC (permalink / raw)
To: edumazet; +Cc: netdev, eric.dumazet, syzkaller, ppenkov, willemb
From: Eric Dumazet <edumazet@google.com>
Date: Wed, 22 Jan 2020 09:07:35 -0800
> 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>
Applied and queued up for -stable, thanks Eric.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-01-23 10:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-22 17:07 [PATCH net] tun: add mutex_unlock() call and napi.skb clearing in tun_get_user() Eric Dumazet
2020-01-23 10:44 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).