Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp1118635pxb; Fri, 18 Feb 2022 00:46:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJyRWVaSjP12cWP+otqUKuJhnpMwAV7RRzFSDHEbINqR4NwG9C1HXYu5CECgFlwdbnQowd6O X-Received: by 2002:a17:906:aad7:b0:6cc:c9aa:d9ad with SMTP id kt23-20020a170906aad700b006ccc9aad9admr5638284ejb.726.1645173997630; Fri, 18 Feb 2022 00:46:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645173997; cv=none; d=google.com; s=arc-20160816; b=uwkhUTy8/8Ra/Tum8UaCBbuM6FZ5k+MCyIMzlCpVggvSfTgUsAA/bD1J7KQ3UAzKqX oiBUzNBj7a79GGuIBs+O+JSVZwOENhV0VxmFTEGvNU5UIMs9Vp+wwgk7JV1hFQ/D+H5Q 3YnTZ0fbk4JCP6M7z5R7wne886K+ikUOben3C8gkJv9bF/TmCCui30+0A2z8uCQ6n53N b7RYuooK40WI9T9hS/vcBkJWlCQPEdOOCahCwOIvV6KhGLSO9GktqduUeLsQr3lqvUwx sLkNSAuEj7O5pLMbXMMw7CkeqWNP+aYXRomzyHd6iOo82RPlP2B9LwJG0wb40v9dkBHn u1AQ== 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=b3an4T6G6qHEJNm38MmcXCoPPrgdpc1EoX1xAXcbs3bwOSR6Ei1cd/SgtAwWCKBoph kQ5kfrb0whuagmKqbbOX23d8VOoDHjAszdxt8ofjvyfnfjFWhoKqp4G4JVLfgewHqSWC Gh3DBFvDnbWtcdVn5fnM9quvcTDiM+jSe3Jh6z9uleyDNUTzbYhjbu4xxefCyX83iCUS uXOtPr40UkwHjsKJo2V8iddtROsQ69AYdlXN+n1zVe47m9UEW4xEb00uXE8b9tg3d49q vaFEjRYOtb9reD3bDgfAGjB4wH1Atd98g5p9oLg2SCeE1NnWhky/wpyGm9DsKn4h6EE/ oZpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=fkq5D1vJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m16si3403552edd.432.2022.02.18.00.46.14; Fri, 18 Feb 2022 00:46:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@siemens.com header.s=fm1 header.b=fkq5D1vJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232130AbiBRHdI (ORCPT + 99 others); Fri, 18 Feb 2022 02:33:08 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:40280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232125AbiBRHdA (ORCPT ); Fri, 18 Feb 2022 02:33:00 -0500 X-Greylist: delayed 65 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 17 Feb 2022 23:32:40 PST Received: from mta-64-228.siemens.flowmailer.net (mta-64-228.siemens.flowmailer.net [185.136.64.228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A073829926F for ; Thu, 17 Feb 2022 23:32:40 -0800 (PST) Received: by mta-64-228.siemens.flowmailer.net with ESMTPSA id 20220218073132164d77a6506553f2ac for ; Fri, 18 Feb 2022 08:31:32 +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=fkq5D1vJPkd1ubQGmu1oLGiWupCi97eeA4mr7CCWtXO/BKDj8dXd+rp9Je33yKswia7nlE VnPGIVTvxGjm2XH/4yrUzE7xO0B4piS8gDi5Mc740CipaFXMnt/Onp7aelILH+1Bb4rOtsnK iALymK33Tp2Buev0Dt8pJH8F4jxE0=; 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 7/7] tty: n_gsm: fix deadlock in gsmtty_open() Date: Thu, 17 Feb 2022 23:31:23 -0800 Message-Id: <20220218073123.2121-7-daniel.starke@siemens.com> In-Reply-To: <20220218073123.2121-1-daniel.starke@siemens.com> References: <20220218073123.2121-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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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