Received: by 10.223.185.116 with SMTP id b49csp1191057wrg; Fri, 16 Feb 2018 14:13:27 -0800 (PST) X-Google-Smtp-Source: AH8x224NK2N+7scf5Ha0oWOB5+L0AD5FfDEJyBkp3JjNZhVBf8e0bDvKsFj5wnFBCNcLgBzl5w6F X-Received: by 2002:a17:902:bd09:: with SMTP id p9-v6mr6533896pls.355.1518819207113; Fri, 16 Feb 2018 14:13:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518819207; cv=none; d=google.com; s=arc-20160816; b=YvuQ+UkozOWPs9VbJgXI3W6pumb09VSN+0T/9j5TW3q/08HNSHDqX2Ht9cb7ZLGuQT Z5BF9Ki0d4ctbFf+KDMepWKCzqLT9lAd6QHxxLx0l8ZNA5eHea2UvUOtRLJti4EOMwkS W6VKQonBReUIdQs4xYDAOFp6qNLNDjhl1L5lQXjuGhrbzaGVcSqFdmnUKN6LNAomExYS 01fQupAazLR8VvSdTrKy0uIRkpevRly+aWOjlXCC3/Ii4Ej6Z2K5NT5sBx9t3YZW0T99 IDMPV1CT6ho3OsP0jcvWkS2Sn7xae244tuMcRZm2An0PfKboVovwNOi4OgprLCTQGD0a 9i0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Spq91JYBbUROhCmvD1w2CxzYhgEwKVUFKVtoCL2z+L4=; b=v4JornHDDPLrEIZNHzADnYiU0H7iB4or+1/ivmOf+msy86Rz3joj9RCZsZVAcUczCz saNnkT7RxeYEKS0fMHoHYlWkB61YZBVq+HtO/m8+nvRqRRLkj8OP355A18LPSlAr3EDb U6+O4D8GEOL/hhLqYDJgwAjt1qK+7thHQooS6SjPJumWYMQLYRr6rOUssYZV22EaHm9i lEsnlhjh82HpSWLznGKyBCPotyAHh0W1z+76AeU9L+U0r4P6S934bNFUBtlUxh6PVv5Y ZR55Y5VcNzYCaATATNDEPh0s8S20hqgvjn3gyOLGUM35dXP9g3l4TRXnsAywY1Wg7Qz0 lv1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1-v6si1821159pld.236.2018.02.16.14.13.13; Fri, 16 Feb 2018 14:13:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751091AbeBPWMJ (ORCPT + 99 others); Fri, 16 Feb 2018 17:12:09 -0500 Received: from mail.ispras.ru ([83.149.199.45]:52606 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750727AbeBPWMI (ORCPT ); Fri, 16 Feb 2018 17:12:08 -0500 Received: from localhost.localdomain (ppp85-140-187-103.pppoe.mtu-net.ru [85.140.187.103]) by mail.ispras.ru (Postfix) with ESMTPSA id EB860540089; Sat, 17 Feb 2018 01:12:05 +0300 (MSK) From: Alexey Khoroshilov To: "David S. Miller" Cc: Alexey Khoroshilov , Jason Wang , Eric Dumazet , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] tun: fix mismatch in mutex lock-unlock in tun_get_user() Date: Sat, 17 Feb 2018 01:11:55 +0300 Message-Id: <1518819115-13507-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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