netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [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

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).