Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3092367rwb; Mon, 15 Aug 2022 17:56:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR7Wfq0wMSxAN/Qa9ZYNX3r0HbnXMPjgWORaqwzDNqFqwcyykqVramq9GqLrbaSjF4IgPnDp X-Received: by 2002:a05:6402:3485:b0:43d:7fe0:74d1 with SMTP id v5-20020a056402348500b0043d7fe074d1mr16619395edc.413.1660611394372; Mon, 15 Aug 2022 17:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611394; cv=none; d=google.com; s=arc-20160816; b=RFmyf7wmV7OR9AHzZVEUOD9CFq4eNnSoD4JdbcAEgpnKut2BR42255I72hsWafBcPp bKCNw4nxElh0RoC+NOaooaiVW4slwPG9p1fD234fL+162jFxQxwA3htvSLx4bGpM2QxC 2cn0cjuuwEA8Exb7DELMKWEflIzSUiCowQ0JGYByz5jD/YwH31aC6WPDxriJ+6rHLhXx WKwNuYmz2OhhnIHyiIg2XYif0TmRJW5zBCjo59sSjTo8WyYGFE4psEVqnV4wkzPhXq4O EqbIwuuGvpMdinBUhcMpxxPVnHDGClaB6p15dl33vkyAmkjMH9apLeZ0VWK5oSYY2phu e3BA== 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=/FcvAGqfXJwhHDJusIZqfVpbXmGWQZoeMzh8TOMoFkU=; b=Hglpx5uiiJmQe/8pwwYhGcNKHra8T+oJHPlDVHGksu+DrMnTRnYG0Vzc5ew6qW/FD/ kdu/8jh5l+4y0M5BlW89+b9OM5r69Xk0wFinOvURvamoTo3+3RqsuQObqBzzylnyylc9 oi7PZmtnxibOBmGw8huX35Pro7wN20QAGWGq0Q3ryzyUYGee7HY5b/YCQH/rsXEZoeqE jTg5vwfTfNvf5N7ZSzZ3TxS3tfQFeMaEHPYnEYkfHLZi1JZW0xEUezCrSmXfWO/C9Y7V fCPctGvYA9OcQuP+qkF4CwoJtQb3/PUVCE3mTqCVosI93qzY3jAHHgvk+LpyXMs7my9Q GJEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QBxbO2Wc; 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 dt20-20020a170907729400b00734bc2f6bb1si9971200ejc.801.2022.08.15.17.56.07; Mon, 15 Aug 2022 17:56:34 -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=QBxbO2Wc; 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 S1346069AbiHPApJ (ORCPT + 99 others); Mon, 15 Aug 2022 20:45:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345397AbiHPAnI (ORCPT ); Mon, 15 Aug 2022 20:43:08 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 595D7D4191; Mon, 15 Aug 2022 13:40:13 -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 2B3B161185; Mon, 15 Aug 2022 20:40:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F9B8C433D6; Mon, 15 Aug 2022 20:40:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596012; bh=uf6JlCQdeeCLNZvukkCqj/rwF7nUjJfD3aadEgWPqrs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QBxbO2WcWe9+BSqojLCwlkGXkeXaQ2au3WCp7g+OXgCfMNJbDD4i1T9xfya6Bo8c9 lMKAms6a+SSOCOn/xVFTPWXbLgRJabo/VAx5SIjDwROisHAYJU2YVtjc/rtN+eB+yC /fgcPPlNYcx2K7tT5gF9JNLEacCwfsYRliRhnZxA= 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.19 0946/1157] tty: n_gsm: fix missing corner cases in gsmld_poll() Date: Mon, 15 Aug 2022 20:05:02 +0200 Message-Id: <20220815180517.396806660@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 51447ccccbab..caa5c14ed57f 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -3053,12 +3053,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