Received: by 10.223.185.116 with SMTP id b49csp1215001wrg; Fri, 16 Feb 2018 14:45:27 -0800 (PST) X-Google-Smtp-Source: AH8x224IQ0JvATV8WSNQ2Setsk9QrTWrXeYNcHhne5lEWwtwxOycQIwIAjM4bpHPMiuxSrL5pws5 X-Received: by 10.98.98.194 with SMTP id w185mr7495077pfb.9.1518821127853; Fri, 16 Feb 2018 14:45:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518821127; cv=none; d=google.com; s=arc-20160816; b=uwruHKzpGtivz6ZIZtPagdCNhV30IpQY0X/R15D7wMZO3bMW0gMhJcTND0Xwue4VB+ XGtEwiNzzQPtXlk3PpJRIDB5uOLOkwMcdinLp8USSC+j1J04OCfTFcmw20vZSAe0jRsl cwromUkTJqSWwvO9SnPGHIhvGwk/y8DUGMWp+79DEfq9oe8cJMRpLTm7hbpkkSa8zPyA uGPs2gBLrazq/XYSP4xoSVriTFdrMkeUfgTPtjo5BHeh1Jibpw7NmLzmnHvfVWecy90y RSwy8VzwjsOv6oO8C6n/1xSLqhhMAsjp1R+AH+pUzsY1CAXjuc+zHxHJ8iwT2/fu3oJt QYJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=W4RYeuAERdEO+/mH7jHpZ+QHSQqtukJBuyPq+0ih0io=; b=oEyRyZJgX9gh6Vgx+axadf0+fUWeRxLFqZDQS0ooYOu9wrJVXG2NhRVrPubfcb4FGM 0/hcQMHUsC+xd9NfK7dX2B95IUiei5O/saboaK8awgwejUrlEXrpFWOFPDxt7OH3qvV2 fSEXjwOE2GJP6p4I0WZvPXVkFEz3cubWoPypd6QR0XJRE4vR6FXftmEk5xnPOcUU93GK bTKN0J9c4ljd4l89qjOgnnKQ3eg6xKIk5JCiqgzsQ54uysRp52aMz+mVv917sv9XT0O0 vUzZgH1JYo1UZuPIaeGiThS0Z/rBfUf8RL+fdfDcLMSIR/Cnb+uaHXd4orY/c7yiZwvw xeNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=keKCeXNb; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r3-v6si194607plb.232.2018.02.16.14.45.13; Fri, 16 Feb 2018 14:45: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; dkim=pass header.i=@google.com header.s=20161025 header.b=keKCeXNb; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750923AbeBPWoc (ORCPT + 99 others); Fri, 16 Feb 2018 17:44:32 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:46544 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750734AbeBPWoa (ORCPT ); Fri, 16 Feb 2018 17:44:30 -0500 Received: by mail-wr0-f194.google.com with SMTP id 34so4299570wre.13 for ; Fri, 16 Feb 2018 14:44:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=W4RYeuAERdEO+/mH7jHpZ+QHSQqtukJBuyPq+0ih0io=; b=keKCeXNbM5LTEcRNFvTjoyFo4rwY9gRH/paTMHaqxrOa7E9ReTL52zS46SO7tTJNHV ZdMHvLZQRUWrnK0MSusmPur1Okus0uNZOAhaH9/Pv0+QTfYOHbD1W6APvGJJC0+l6YiJ BHOiPGynQs+Vm3KKvAYIP2G5AmLZPjW5DrXjVj4MeoUsV6zUTCRTocXFPTRFm6WU9GRI 2VSLTKgLDstBYn8vtr6y+Y6UPIsmMay+ovHhoylzMadTc7KCax7OZDoDijvdJ/4UCQgD rg8fnXBI9ZesxNxRyq9GoYQnOsYr4mjenYFHE1gcLiusbqg+7KhuLe5f/Fa/dfQOLfwu 0KJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=W4RYeuAERdEO+/mH7jHpZ+QHSQqtukJBuyPq+0ih0io=; b=KvRrK/5WAeIY9E7pEPbkXhqoPe02tuiAY7UvjRALR3XP1zYfVhRl5bxegIsYimtZ98 YuEiuCHWr4EUDJS39braga+qoJ2zH7iAWPgmUhIM5a4EMprz+1M9c0X5pba6SyaDiq14 wxaKp/xy9RejR3EC2wxv/Efp3cGL1sdtam5Y3nQKTexSXnlH9PDf1urp+xxDdojI1r5g nreVm4v1WQX3Jr6AVfM1oyPluJt9Bt7wmr/mf2z3CuxrXu7sqv9i0Zq3YxZO0jt+83pJ OcBN/3zwVINPbrs0VMyTVWTZUvo+MMRITlrseJhQil1trIO51HcaWvNsizAOe9dnQnlH C5RQ== X-Gm-Message-State: APf1xPAWEXdVEDDySgeKsEe8PD1zmza1RS7k/2gOBoeF2wfgS/NMQKa5 3gtZazy6x8L5IMUHlJinV9K+44d5XBol6z6r8U4anJQdKgg= X-Received: by 10.223.150.65 with SMTP id c1mr7090632wra.167.1518821068552; Fri, 16 Feb 2018 14:44:28 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.147.15 with HTTP; Fri, 16 Feb 2018 14:44:27 -0800 (PST) In-Reply-To: <1518819115-13507-1-git-send-email-khoroshilov@ispras.ru> References: <1518819115-13507-1-git-send-email-khoroshilov@ispras.ru> From: Eric Dumazet Date: Fri, 16 Feb 2018 14:44:27 -0800 Message-ID: Subject: Re: [PATCH] tun: fix mismatch in mutex lock-unlock in tun_get_user() To: Alexey Khoroshilov Cc: "David S. Miller" , Jason Wang , netdev , LKML , ldv-project@linuxtesting.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 16, 2018 at 2:11 PM, Alexey Khoroshilov 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 > --- > 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