Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3077387rwb; Mon, 15 Aug 2022 17:33:58 -0700 (PDT) X-Google-Smtp-Source: AA6agR5RVRzalgFIle74M8NnvHrqOYXM9/ow1qodIjF1ovB0tXb+9+NonZbq08PdMYuFWNAmJoVr X-Received: by 2002:a17:907:628a:b0:72f:678d:6047 with SMTP id nd10-20020a170907628a00b0072f678d6047mr11703533ejc.456.1660610038296; Mon, 15 Aug 2022 17:33:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610038; cv=none; d=google.com; s=arc-20160816; b=xQmFse8bmU7cez3r0/gtUDs/YViMDCdWDSDLpPWXkB2gMEuEQhfq+UZwLgwqshGYdz EC6c6Go3dO0Q09oFvnEX2q2IOxuq9WUC9ijv5XRVBY0g8iHHVIHxUPRVxi2kZj9c9ObT FFttIOS3V2TI53AC/fpyr/qEFJAQwY+0rfxJASEDaaUhgkZXNsGJY0YTG17Jx/FWs70d 8RH6cDtIGOcNSzjdlzD8VLcgGcq9yoT86/SchfV60qF3fo5C0Epb9BFlO5jinH6y5oG0 HFBDN1BblencVqm1NNAeJr5rs+KktOCfc3WC9jUKKfWyjkMv+9yJgQkp6oQcupPmOaBZ wgMg== 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=Ak9YvF4fA/2Crw4taeMDH5FemHEXFUCk2rduNq0Cndc=; b=kY8Fmq3BG4AusEFL3GAWBZn+4ZWfSjYPmS4Sgbf2hn3/EsQrEAEDXj6juPHiA4gvQC d+vJVg1jZpllxz3QXmmtJhcZx4f2NNbEOK/M5WDJ8SHuCBU6BzDsVt9ig8oWvAQlr+7N WsN8KwRPEwMPXgTSjrFV37aRIBO2ah+U8FfdSRXkMGMJ/yKr54a4VeImhsVCKuxMDcry Ukq2hFVjMX1zg03KzhwxD9WOa2Gd9oh6sOS5154tNXcWbuti3Kxe1lj2WPBlvPAQ9iY/ G3RsBw6VDGc539nex+HvmTHoZszR15DHJENy7JZ26ImcIqJ00jPCM+fc7vCCbWN4aIwF ckSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iUQ12fr9; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p2-20020a17090635c200b0072f664f368asi8909181ejb.199.2022.08.15.17.33.33; Mon, 15 Aug 2022 17:33:58 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=iUQ12fr9; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350616AbiHOWkE (ORCPT + 99 others); Mon, 15 Aug 2022 18:40:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348953AbiHOWeM (ORCPT ); Mon, 15 Aug 2022 18:34:12 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9EB470E72; Mon, 15 Aug 2022 12:49:34 -0700 (PDT) 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 C89D06122B; Mon, 15 Aug 2022 19:49:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5E5FC433D6; Mon, 15 Aug 2022 19:49:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592974; bh=HAgF+QZyq7BwwqLqpaRvWir0GnzA1N0v4RZ9HqRJ7ko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iUQ12fr9DzSratNurm9taG/M/U0q9bOQfTY85XxK36BP0zjCwNOqF5zXW/0LboxlD svvGirAcT/W6erj3IQppyzID8ckua+vf6Fi38ESASVAGTw3EawZUrCa88VSxY8ZRa5 uTo3/l84A8yHrY76Bn9C2qDQDLv8UY2ccktlWF5c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Starke , Sasha Levin Subject: [PATCH 5.18 0874/1095] tty: n_gsm: fix missing corner cases in gsmld_poll() Date: Mon, 15 Aug 2022 20:04:33 +0200 Message-Id: <20220815180505.522422313@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 [ Upstream commit 7e5b4322cde067e1d0f1bf8f490e93f664a7c843 ] gsmld_poll() currently fails to handle the following corner cases correctly: - remote party closed the associated tty Add the missing checks and map those to EPOLLHUP. Reorder the checks to group them by their reaction. Fixes: e1eaea46bb40 ("tty: n_gsm line discipline") Signed-off-by: Daniel Starke Link: https://lore.kernel.org/r/20220707113223.3685-4-daniel.starke@siemens.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/n_gsm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 7749de4f269a..3dd71ede4cd4 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -3057,12 +3057,15 @@ static __poll_t gsmld_poll(struct tty_struct *tty, struct file *file, poll_wait(file, &tty->read_wait, wait); poll_wait(file, &tty->write_wait, wait); + + if (gsm->dead) + mask |= EPOLLHUP; if (tty_hung_up_p(file)) mask |= EPOLLHUP; + if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) + mask |= EPOLLHUP; if (!tty_is_writelocked(tty) && tty_write_room(tty) > 0) mask |= EPOLLOUT | EPOLLWRNORM; - if (gsm->dead) - mask |= EPOLLHUP; return mask; } -- 2.35.1