* [PATCH] tun: fix mismatch in mutex lock-unlock in tun_get_user()
@ 2018-02-16 22:11 Alexey Khoroshilov
2018-02-16 22:44 ` Eric Dumazet
2018-02-19 16:15 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Alexey Khoroshilov @ 2018-02-16 22:11 UTC (permalink / raw)
To: David S. Miller
Cc: Alexey Khoroshilov, Jason Wang, Eric Dumazet, netdev,
linux-kernel, ldv-project
There is a single error path where tfile->napi_mutex is left unlocked.
It can lead to a deadlock.
Found by Linux Driver Verification project (linuxtesting.org).
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
drivers/net/tun.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 81e6cc951e7f..0072a9832532 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1879,6 +1879,10 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
default:
this_cpu_inc(tun->pcpu_stats->rx_dropped);
kfree_skb(skb);
+ if (frags) {
+ tfile->napi.skb = NULL;
+ mutex_unlock(&tfile->napi_mutex);
+ }
return -EINVAL;
}
}
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tun: fix mismatch in mutex lock-unlock in tun_get_user()
2018-02-16 22:11 [PATCH] tun: fix mismatch in mutex lock-unlock in tun_get_user() Alexey Khoroshilov
@ 2018-02-16 22:44 ` Eric Dumazet
2018-02-19 16:15 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2018-02-16 22:44 UTC (permalink / raw)
To: Alexey Khoroshilov; +Cc: David S. Miller, Jason Wang, netdev, LKML, ldv-project
On Fri, Feb 16, 2018 at 2:11 PM, Alexey Khoroshilov
<khoroshilov@ispras.ru> wrote:
> There is a single error path where tfile->napi_mutex is left unlocked.
> It can lead to a deadlock.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
> ---
> drivers/net/tun.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 81e6cc951e7f..0072a9832532 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1879,6 +1879,10 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
> default:
> this_cpu_inc(tun->pcpu_stats->rx_dropped);
> kfree_skb(skb);
> + if (frags) {
> + tfile->napi.skb = NULL;
> + mutex_unlock(&tfile->napi_mutex);
> + }
> return -EINVAL;
I do not believe this can happen for IFF_TUN
IFF_NAPI_FRAGS can only be set for IFF_TAP
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tun: fix mismatch in mutex lock-unlock in tun_get_user()
2018-02-16 22:11 [PATCH] tun: fix mismatch in mutex lock-unlock in tun_get_user() Alexey Khoroshilov
2018-02-16 22:44 ` Eric Dumazet
@ 2018-02-19 16:15 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-02-19 16:15 UTC (permalink / raw)
To: khoroshilov; +Cc: jasowang, edumazet, netdev, linux-kernel, ldv-project
From: Alexey Khoroshilov <khoroshilov@ispras.ru>
Date: Sat, 17 Feb 2018 01:11:55 +0300
> There is a single error path where tfile->napi_mutex is left unlocked.
> It can lead to a deadlock.
>
> Found by Linux Driver Verification project (linuxtesting.org).
>
> Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
As Eric explained, tun_napi_frags_enabled() (and therefore 'frags')
will never be true for TUN devices, which is the type handled by this
code path.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-19 16:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-16 22:11 [PATCH] tun: fix mismatch in mutex lock-unlock in tun_get_user() Alexey Khoroshilov
2018-02-16 22:44 ` Eric Dumazet
2018-02-19 16:15 ` 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).