Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3114581pxm; Mon, 28 Feb 2022 12:19:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJyb2eLnQB4FNdkrIBbjazHfxhqp5sPk0CC/wBzxARh8NDUeNq2AmFxHZKUi/C7mEj+brOjl X-Received: by 2002:a17:902:6b04:b0:14f:2cc0:fa98 with SMTP id o4-20020a1709026b0400b0014f2cc0fa98mr22320918plk.44.1646079542172; Mon, 28 Feb 2022 12:19:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646079542; cv=none; d=google.com; s=arc-20160816; b=eqLH1EzOGBES5wJ6XkYca/F5OrtS6i/2Kda2hjvWjcY52jOnEIAOG52+6dv/9IYJZ7 kwf9hsZqjcEsU4sua6+eEkvb78LmjaEAwjENiOjmeMuqDXFQUUTCwtTtJwW6YOGtNmhB IV2vS65G2gXfNePkZrVCavUFfvIy41wJIaQqrurpsBc/JphBPrhy9BX4x9Vl0HORmbmd ajAKjHwVk8XeNyuQvG8PPuSkKxcy10zXsNsvScVqkcVrMvHhZP6Dnuk9U5iDWyaL+JRr Tzp1b95ksoVePjpfcwTD91dnPEVyND9SKNKGA0DEzZqfcloWdmMOO8xYX3J4eF8OBjux fIqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xJReZkdFKaP8x+jL6B7soz5WKB9oXDS+XrPn29ixmeo=; b=vO2q3F656RAuxOSEyaHQA//YGJDv3c1YZZBDKtdCwDrF46fZlPOUEBeS3s0W2uIguj RZJFE9156dfvrjw85avi6ftJ1QV+M9s8RpJq7OYVZhdC/netCcxiWw2eXoSH9zK+6ZhS IPe1KzZQ55Yc6CclY2kiQ1ugJH+0T6QicVdIx6w4yj2TlYnK5I5wTAz6kMAFYVA0ME4I 0e6KreG17YpA2RGwXe06TY+0Z1Tbe/yoDWvDUg+DC7bHxoGFWfZHTdSUDa/nVyVl+qPq o1d8jLTHp1YhFEG5pLFX8L4TPklABXJPm7jPepvJP+stE7Q+pqp7zFZT3V9NCqKQznUy U2PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="QUfY/H/7"; 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=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b15-20020a056a000a8f00b004e1c22a053fsi11079979pfl.8.2022.02.28.12.19.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 12:19:02 -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=@linuxfoundation.org header.s=korg header.b="QUfY/H/7"; 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=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D387393981; Mon, 28 Feb 2022 11:39:34 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231769AbiB1SAA (ORCPT + 99 others); Mon, 28 Feb 2022 13:00:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240599AbiB1RyZ (ORCPT ); Mon, 28 Feb 2022 12:54:25 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E03998F46; Mon, 28 Feb 2022 09:42:34 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id ABD18B815B3; Mon, 28 Feb 2022 17:42:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EE97C340E7; Mon, 28 Feb 2022 17:42:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646070151; bh=leDzcSYyD19gQUJdRqvf6Ehk5Ueop+kOP2W9my9OZK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QUfY/H/7WBlVfGbjZM4Q1Nx7BZa9TkyFoOhP3fGswn5McrtE3kWYnLIvXLoow9P+p Hkqw56HZGD8Zi8iX5NdWOzUsqDiTLjLQA3k+NYUGRFjhfZXmzk+exkET9ZPEahmAoG gdSISfAkw5XZj81HMLHsERJ5HK7p/YjRq6UuwrNA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Starke Subject: [PATCH 5.15 133/139] tty: n_gsm: fix deadlock in gsmtty_open() Date: Mon, 28 Feb 2022 18:25:07 +0100 Message-Id: <20220228172401.655465894@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172347.614588246@linuxfoundation.org> References: <20220228172347.614588246@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, 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=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 From: daniel.starke@siemens.com commit a2ab75b8e76e455af7867e3835fd9cdf386b508f upstream. 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 Link: https://lore.kernel.org/r/20220218073123.2121-7-daniel.starke@siemens.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/n_gsm.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -1431,6 +1431,9 @@ static void gsm_dlci_close(struct gsm_dl 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; wake_up(&dlci->gsm->event);