Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp219591ybl; Mon, 12 Aug 2019 15:01:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5kyVQbOxi1TM7R1nWD+JriNu1JAwAb4mO//mKUce1+o3xHz4J08dJ39ybrzZNueeVK/74 X-Received: by 2002:a17:90a:fe5:: with SMTP id 92mr1275779pjz.35.1565647303258; Mon, 12 Aug 2019 15:01:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565647303; cv=none; d=google.com; s=arc-20160816; b=YnIkcmkMzIbwHAC7wSn+vaA09IABiYdJkb3C2hbkA8730GxXnAzkSENVEnGLJPJJhl s2LYLTP50yf8SmY8UX12SOXGcKut7bf5spkIGA9MYLxp81eRI1p5fzjKlVN6J+c9yzS+ mqtmmO1oL9/NfyuYuh9tKeHR8nz5ZaQ/OGET4amiYtum1xiVSC1vXKSEQL6RikVLTyEq YOekpc83YjGbqhk6uOkRWYC7T1z/wk5bIaKeQYhhRTXzWbg65IxENJqRpMVMk8u32xYs ABdJe07Hyo8QghZ63DqVRYWk2hyP/8OoKl0avA3IjQuk2Vk5odQnqNnSdGuguX9I3BEr MO9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=cSay4L3nuHaNno6WsO1lxu3CAW6HHf04RJuOZk4DGkI=; b=JL/WxEebQeVLXj/CpWlnVKxhLq8dUEugiI9XKPv25pNWdkyabJSZ/1iJbnXJc1IRQQ hMKkkCpzgxXR3MFXCNZEJEAegQKBpiIpyUwW6lqPRpCY+aPUQgLooczEu5F3Pot5rovr YpYAefyHtIRGHxFSrlWkJ7tu65IfggtIdwjTSGoxSjA0k6JBYf7irQVqhfSXBes3YmLx VU5D30wSAmcevR3xOJ3qFyOaLup1ZTxfyJt6dcAdCCSkKhyBuZNIKuYhYu8M2vr9VpYH RU6wPGHmh82FcMt93TQ3SyIubBfPW74R8i69Ex3so/oD/DPgCt/j9l4gR96HxEfOeaWZ u+GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@geanix.com header.s=first header.b=KpwMHLSn; 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=NONE sp=NONE dis=NONE) header.from=geanix.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x22si8091479plr.115.2019.08.12.15.01.27; Mon, 12 Aug 2019 15:01:43 -0700 (PDT) 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=@geanix.com header.s=first header.b=KpwMHLSn; 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=NONE sp=NONE dis=NONE) header.from=geanix.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726881AbfHLVAI (ORCPT + 99 others); Mon, 12 Aug 2019 17:00:08 -0400 Received: from first.geanix.com ([116.203.34.67]:57890 "EHLO first.geanix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726663AbfHLVAH (ORCPT ); Mon, 12 Aug 2019 17:00:07 -0400 Received: from [192.168.8.21] (unknown [85.184.140.241]) by first.geanix.com (Postfix) with ESMTPSA id D641556039; Mon, 12 Aug 2019 20:59:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1565643542; bh=rHjYfc08ShpDPeyiIqfYjLEdvUv9CGrkWeC0Jnjou5M=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=KpwMHLSnTo1bcxaeQceZAuHj9rNyLOh/Dpn7unBeJeT6n46ukfdsOHqoRRX0Y4PP4 OSdh/W0aTGw5hIIHXoVV1hy0TuchwkK6QVeihZTwNpUXEBXeBHnPkHAmgBOZLwFzgg fMVR6bcbkw+BeEF0pWGgq22gVZ3mlHuWzueuDtxQbCNh4krhHkhd54tObGoAKqrSAN i4LEi1F3XFEn5jW7YAOgYhA8liFSX8Fj1Bk/xPFsEcQ6Q+nyd69PHKot3/FZERfalp 0wKJWIkpAuBWtBEzXBx0jQx8JVyX/TlA31J4RJhi5+qXU7pBOK8EPgthWNbv1LYQ0z vzhCKizxRJW+A== Subject: Re: [BUG] n_gsm: possible recursive locking detected To: Greg Kroah-Hartman Cc: linux-kernel , Jiri Slaby , Dirkjan Bussink References: <20190725112651.GA12309@kroah.com> From: =?UTF-8?Q?Martin_Hundeb=c3=b8ll?= Message-ID: <79b38084-8867-0972-ca6c-155e5dbb0d90@geanix.com> Date: Mon, 12 Aug 2019 22:59:36 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190725112651.GA12309@kroah.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US-large Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED autolearn=disabled version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on 1ffa6606a633 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25/07/2019 13.26, Greg Kroah-Hartman wrote: > On Wed, Jul 17, 2019 at 11:40:02AM +0200, Martin Hundebøll wrote: >> Hi, >> >> The GSM0710 line discipline driver triggers a lockdep warning when disabling >> the ldisc while holding a multiplexed virtual tty open: >> >> ============================================ >> WARNING: possible recursive locking detected >> 5.2.0-00114-gdab52e30156b #6 Not tainted >> -------------------------------------------- >> cmux/263 is trying to acquire lock: >> e1e23b18 (&tty->legacy_mutex){+.+.}, at: __tty_hangup.part.0+0x58/0x27c >> >> but task is already holding lock: >> d6eddf48 (&tty->legacy_mutex){+.+.}, at: tty_set_ldisc+0x3c/0x1bc >> >> other info that might help us debug this: >> Possible unsafe locking scenario: >> >> CPU0 >> ---- >> lock(&tty->legacy_mutex); >> lock(&tty->legacy_mutex); >> >> *** DEADLOCK *** >> >> May be due to missing lock nesting notation >> >> 3 locks held by cmux/263: >> #0: d6eddf48 (&tty->legacy_mutex){+.+.}, at: tty_set_ldisc+0x3c/0x1bc >> #1: f28bead9 (&tty->ldisc_sem){++++}, at: tty_ldisc_lock+0x50/0x74 >> #2: e5d20e4f (&gsm->mutex){+.+.}, at: gsm_cleanup_mux+0x9c/0x15c >> >> stack backtrace: >> CPU: 0 PID: 263 Comm: cmux Not tainted 5.2.0-00114-gdab52e30156b #6 >> Hardware name: Freescale i.MX6 Ultralite (Device Tree) >> [] (unwind_backtrace) from [] (show_stack+0x10/0x14) >> [] (show_stack) from [] (dump_stack+0xd4/0x108) >> [] (dump_stack) from [] (__lock_acquire+0x6ec/0x1e84) >> [] (__lock_acquire) from [] (lock_acquire+0xcc/0x204) >> [] (lock_acquire) from [] (__mutex_lock+0x64/0x90c) >> [] (__mutex_lock) from [] (mutex_lock_nested+0x1c/0x24) >> [] (mutex_lock_nested) from [] >> (__tty_hangup.part.0+0x58/0x27c) >> [] (__tty_hangup.part.0) from [] >> (gsm_cleanup_mux+0xe8/0x15c) >> [] (gsm_cleanup_mux) from [] (gsmld_close+0x48/0x90) >> [] (gsmld_close) from [] (tty_set_ldisc+0xb8/0x1bc) >> [] (tty_set_ldisc) from [] (tty_ioctl+0x640/0xcb0) >> [] (tty_ioctl) from [] (do_vfs_ioctl+0x41c/0xa5c) >> [] (do_vfs_ioctl) from [] (ksys_ioctl+0x34/0x60) >> [] (ksys_ioctl) from [] (ret_fast_syscall+0x0/0x28) >> Exception stack(0xc8ce1fa8 to 0xc8ce1ff0) >> 1fa0: 00438000 00000000 00000003 00005423 beb6cc04 >> beb6cc04 >> 1fc0: 00438000 00000000 00000000 00000036 00000000 00000000 00438000 >> beb6ccd4 >> 1fe0: 00438048 beb6cbfc 00427684 b6f58b88 >> >> >> Steps to reproduce using the attached cmux util: >> >> root@iwg26:~# ./cmux & >> [1] 254 >> SERIAL_PORT = /dev/ttymxc0 >> AT+IFC=2: Ie5 +CFUN: 1 +CPIN: READY Call Ready AT+IFC=2,2 OK >> AT+GMM : AT+GMM Quectel_M95 OK >> AT : AT OK >> AT+IPR=1: AT+IPR=115200&w OK >> AT+CMUX=: AT+CMUX=0,0,5,512,10,3,30,10,2 OK >> Line dicipline set >> >> root@iwg26:~# cat /dev/gsmtty1 & >> [2] 262 >> root@iwg26:~# kill %1 >> [ 74.517449] ============================================ >> [ 74.522769] WARNING: possible recursive locking detected >> [ 74.528094] 5.2.0-00114-gdab52e30156b #6 Not tainted >> [ 74.533065] -------------------------------------------- >> <...> >> >> >> This has supposedly been fixed before in 4d9b109060f6 ("tty: Prevent >> deadlock in n_gsm driver"), but the fix was undone in be7065725590 >> ("TTY/n_gsm: Removing the wrong tty_unlock/lock() in gsm_dlci_release()") > > Do you have a patch that can resolve this given you have a test case? No, sorry. I can try to cook a patch, but chances are I will break locking for someone else. Hints are welcome. // Martin