Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp800942pxb; Thu, 17 Feb 2022 15:16:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8eR8KrppDQEKoOmy9EdMW228pDV4FLipyMp2rz3TTOvhobeef+RRLkNSOvp19cvFmVnV3 X-Received: by 2002:a17:902:c789:b0:14d:ae35:1ac3 with SMTP id w9-20020a170902c78900b0014dae351ac3mr4943945pla.64.1645139781114; Thu, 17 Feb 2022 15:16:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645139781; cv=none; d=google.com; s=arc-20160816; b=tMgDLhfvsZJMAySZREqzdbJfUjZlUrytcoKhqpcDE05dSJ2hf6DV1/NJzAIGg6KXW9 RcPwmLRRb8Lvn1+4cm1goOwqnOteIraPAE1z3FzWGMmcPgpook3+QQXjSEo4TQaxJsK4 i/w/VHbPZZnpHsmnikO5plkrCmSv6h/5yKnuVCQuRZ8KQ1O03vH201Y+ixGbm2KFK275 PZoYVrJoTsHF8bU+6OusiPMlZYi/ViLKNkvheEiCfiBIUB4+WbcDNxlaV8dUqtjK3yRb Oc6vmrLXA2d6Jns1SAR/0YVQlVADIRidlAvT4q1jUbW+q0IUSDw3XdkFyqJ+6W86xvjf oB7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=b4XQwcsAcfoBdhr0FTblO5I+qrC5OxsrZ4b1kwFO1ds=; b=uq0sxYLH7icDkI2KAFMf+1wd7katOfogNNyFVsWc/uE1YMoUBeol/eL+LijsaSCzSQ rQImXH7IJR3pgiQqZNIFCHuTqfujUEjTtYuaWQjnJspyjj+HZThNl1djonghwtCVVwLJ xyVM0cpjVxG6Q7KyK254PDfJoumRcSLOn2VMu138cvjH9Q3ZWBC0PWHdkw6ON0c8YnKc UTYl6QumHicM2lz8OjtI4YoyepjihfaGin5AbPw587a/1FOvGHJClS/v+ZERxdEKtx4w VAxtKcm1pF69ojH/cywMEUAyA8KlsDQuvqNu0OqbsbgjoJmqLOCtlcrYgkcZsmTZYuN7 InbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=Vm7L1uvf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y9si1944568pjp.69.2022.02.17.15.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 15:16:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=Vm7L1uvf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7F14E2BE805; Thu, 17 Feb 2022 15:06:22 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237250AbiBQIHr (ORCPT + 99 others); Thu, 17 Feb 2022 03:07:47 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:46142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236654AbiBQIH2 (ORCPT ); Thu, 17 Feb 2022 03:07:28 -0500 X-Greylist: delayed 62 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 17 Feb 2022 00:07:09 PST Received: from mta-64-227.siemens.flowmailer.net (mta-64-227.siemens.flowmailer.net [185.136.64.227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51EDD27F284 for ; Thu, 17 Feb 2022 00:07:09 -0800 (PST) Received: by mta-64-227.siemens.flowmailer.net with ESMTPSA id 202202170806016044ca43e6dfafbea2 for ; Thu, 17 Feb 2022 09:06:01 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=fm1; d=siemens.com; i=daniel.starke@siemens.com; h=Date:From:Subject:To:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Cc:References:In-Reply-To; bh=b4XQwcsAcfoBdhr0FTblO5I+qrC5OxsrZ4b1kwFO1ds=; b=Vm7L1uvfzBWOywg+1xfnqErDAnxpaT8I6HRkth8NIwLZl9HWNGJjPi++sFQq8vZ9pnxywv nZrVAgXtCYtBWO+m9iIqe0wtmiRKObZplqqrNkKoS2POJ6Skf9b46ITJrCrrZn1Cjs/Dh015 WwHsQTlBnSzrOU0KSmb3eanrXZL5I=; From: daniel.starke@siemens.com To: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux-kernel@vger.kernel.org, Daniel Starke Subject: [PATCH 1/1] tty: n_gsm: fix deadlock in gsmtty_open() Date: Thu, 17 Feb 2022 00:05:55 -0800 Message-Id: <20220217080555.5387-7-daniel.starke@siemens.com> In-Reply-To: <20220217080555.5387-1-daniel.starke@siemens.com> References: <20220217080555.5387-1-daniel.starke@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-7517:519-21489:flowmailer X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the current implementation the user may open a virtual tty which then could fail to establish the underlying DLCI. The function gsmtty_open() gets stuck in tty_port_block_til_ready() while waiting for a carrier rise. This happens if the remote side fails to acknowledge the link establishment request in time or completely. At some point gsm_dlci_close() is called to abort the link establishment attempt. The function tries to inform the associated virtual tty by performing a hangup. But the blocking loop within tty_port_block_til_ready() is not informed about this event. The patch proposed here fixes this by resetting the initialization state of the virtual tty to ensure the loop exits and triggering it to make tty_port_block_til_ready() return. Fixes: e1eaea46bb40 ("tty: n_gsm line discipline") Cc: stable@vger.kernel.org Signed-off-by: Daniel Starke --- drivers/tty/n_gsm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 0b1808e3a912..e61a47c349e3 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1451,6 +1451,9 @@ static void gsm_dlci_close(struct gsm_dlci *dlci) if (dlci->addr != 0) { tty_port_tty_hangup(&dlci->port, false); kfifo_reset(&dlci->fifo); + /* Ensure that gsmtty_open() can return. */ + tty_port_set_initialized(&dlci->port, 0); + wake_up_interruptible(&dlci->port.open_wait); } else dlci->gsm->dead = true; /* Unregister gsmtty driver,report gsmtty dev remove uevent for user */ -- 2.25.1