Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1876303rwb; Fri, 19 Aug 2022 10:53:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR49cPG07q6IZMJz6OpR77olOk+MDRzFjAoF9r1nidmjc+2RLlgz9l8hQ8kDL9ehymvzm4KN X-Received: by 2002:a05:6402:430e:b0:43d:1cf6:61ec with SMTP id m14-20020a056402430e00b0043d1cf661ecmr6879393edc.194.1660931621494; Fri, 19 Aug 2022 10:53:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660931621; cv=none; d=google.com; s=arc-20160816; b=id+jri4KhKSurOhOsGZNjql+2gYhBvVPoJtZhjgZG9T6Nv3GFEsltLfHOpb8jrnyJz LCGRJ8GQFJhTAaBhWuQSkqk/4XxKR7Kz/ZhVDDxDrUWV3AxDYG4YmSH2Hx9qwboijSOP D5pTLgpL6Dfbmf8Ak8794aqE8ihY4It80wVx0+rZtvAq2gi1sH85rVLNQjpiiOQyfFk7 XsUsS4SFzTHVEOx29D5BdeVfsQygmECQePgCtOru2mCaGX6sMleMJQqOXE83FomLhX8M loPWOud4qXCoClEymB1C7L68XP+HxY9bgjUyHRNhygNTtGkpyNNKscU7PgxpP0PWUh86 HKwQ== 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=gAIFZqTByXU9+lpAKVhLl9UBAetmrWFcT0J2VUSGuZQ=; b=KRoIHzvzPX9CUbQHURyVSjSfMZ3prD2roaGG1JgHjPdFufL1bx7NOzRTlXR1i3wzzd M+CQSl2Xdu0SMh8DA2mml2m/dBkyda7Meo9+H1tMgPhp/QI0g6daIdehT8BWz8Nh8EPY PHkb8WkJaXbNDxbsm1CCrL4E+UJaSxN6XiOEo2m8IqTkuiy4V66m9H9KD/HPrNb81hnd eXH/aaed69nTxq4Dkh/58QAi+ddNfdZez1DziKRuFWMrZbdnBsPYRJA6P92STf9A/ecN f3LquTr4c2S0VyLyg0qm3DCdw1yudqxbs3lrWmC6OdgB4wR1KfJ9dLdDIyHdCdnx5zPZ UMEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ann5xach; 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 fg4-20020a1709069c4400b00738795d6591si2772866ejc.434.2022.08.19.10.53.15; Fri, 19 Aug 2022 10:53:41 -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=ann5xach; 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 S1353263AbiHSQec (ORCPT + 99 others); Fri, 19 Aug 2022 12:34:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353362AbiHSQb0 (ORCPT ); Fri, 19 Aug 2022 12:31:26 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9013411E903; Fri, 19 Aug 2022 09:05:49 -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 ams.source.kernel.org (Postfix) with ESMTPS id 82207B8281A; Fri, 19 Aug 2022 16:05:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E07FDC433D6; Fri, 19 Aug 2022 16:05:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660925140; bh=qpFce+Tb+zJ1EIH4VJ8KyblvgOQHtWdFvmTVlDgV8G0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ann5xachG5rs11jdoj1cAN0cbkm2gcH5H6+0UWnhQJA0TNvSBQP4JeCpJCiEqqESs X3OJ0f4S1AE8DU5m6G21cnX5yiv4tZ2PfvY9OJV6ezTQV6Sh0LgYGCakNcRZPkjQQ8 l909ppyRO0tciiLz+/yB37+/THNrAoGHH72+BRnU= 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.10 396/545] tty: n_gsm: fix missing corner cases in gsmld_poll() Date: Fri, 19 Aug 2022 17:42:46 +0200 Message-Id: <20220819153847.134824715@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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 a6c0a1b76ddb..cb5ed4155a8d 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -2747,12 +2747,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