Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3110432pxm; Mon, 28 Feb 2022 12:13:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCsBos8p4lMXp9uDTJfrN+7azSSSZCCw2wu/7OZ4w7SZHOP4xhBCL6/O0ZnudHqjULckRJ X-Received: by 2002:a17:903:404a:b0:14f:944f:22eb with SMTP id n10-20020a170903404a00b0014f944f22ebmr22266295pla.21.1646079196824; Mon, 28 Feb 2022 12:13:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646079196; cv=none; d=google.com; s=arc-20160816; b=lg5ax3roFVPL/v3MceCTOxBYhseabyxYocMIVnYRkfh8bEtV1NOVjCaLwkI+ZOnYDp iALRGxBcjGdrJ94kWeb50QbG1P4sfOmLP1W73uZ4ThK9MzeOySHkRvyIe5suc1cjGoJX FcUQ4J8APIuIXxXeHV/wnQEeGb/4jcmuVBX00y1FNiI7LKcxkYnjh9oj4xC8K4BMhNmB zRdKNu0nqJueivkvppCRi9Q9+bHmeaY7Y1SSrg4Il0VWkT64E7Ac6oU1lz0mpu8E+ejK KRgzLTSC2mndnEI5wwLSjDgrwzjA8SnN5akoFCWF6zdfY7YU09GOR/yIWQmLndor18US m1wg== 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=6vF+oE3hskD4YPnq12z+vRCRmFHySvNduhsYBerLZNM=; b=FB1Q2lg5zJrEEQjyufJeb3NvKgW6f/oRwDWT1nx6q690yDg3mBwnSy0N7jQ0F7XXLb XnTcnxYraYDM1FaUTbwwviVBAFcPK7GUNDaKk+jg/AvrVhktjX+gD3CD58FlM1HzFrSf EPZAEuycm+/wYt5WysVlWsjSVjiM9ZD5qISwD/3KOclEpy307oon1kAyfmcc+Bq+gsK8 eOC6/9buynzFcXrDP6+UXSVDa9G3GvxSHQO//dPWN9Z70rNq/ru97KdvzuYEFTBr6nfK eAmDMwe5hxyCm4aIVaNlFtwomAXJyCy6Q1dUkTeDQsR2C4jh66eYiUxva7vfu1uGaCJa uEsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Nmb1yClZ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id o4-20020a170902d4c400b0014fcd282241si11416207plg.176.2022.02.28.12.13.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 12:13:16 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Nmb1yClZ; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 4707D15C9EE; Mon, 28 Feb 2022 11:36:04 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234868AbiB1SOz (ORCPT + 99 others); Mon, 28 Feb 2022 13:14:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241196AbiB1SJk (ORCPT ); Mon, 28 Feb 2022 13:09:40 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53F8F8EB41; Mon, 28 Feb 2022 09:49:39 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 1BBFE6090B; Mon, 28 Feb 2022 17:49:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3499EC340E7; Mon, 28 Feb 2022 17:49:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646070576; bh=ZhlsJBgsgqqqktWComnv4in6sxpT76BhJVk+xI/dCBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Nmb1yClZHfhGfP1ZWXs4MBMmt4JHO1zmthZPu39WlLBPrlYB8N5tsdtitqrdj28BV 9+tDw91PMSgEi3L7gB2uKKQxHAMYKm2VSsq1jnyxGnGHK1uLPNjuAqOFzdwoK23Ha7 6Xqz3GIoq3FKJCK1MEAUUrJ2+t5COrEnLss0rMrI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Starke Subject: [PATCH 5.16 160/164] tty: n_gsm: fix deadlock in gsmtty_open() Date: Mon, 28 Feb 2022 18:25:22 +0100 Message-Id: <20220228172414.176137635@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172359.567256961@linuxfoundation.org> References: <20220228172359.567256961@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 @@ -1457,6 +1457,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; /* Unregister gsmtty driver,report gsmtty dev remove uevent for user */