Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3472629rwa; Tue, 23 Aug 2022 05:27:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR6rJmiM5/5PT0UIdg2CvpdAHXRuuzSHrLOIX4DKX4Z1rIY7wdeYHcnfGArGpHeVtjQteTww X-Received: by 2002:a05:6402:150e:b0:447:217c:2c65 with SMTP id f14-20020a056402150e00b00447217c2c65mr2133884edw.187.1661257636577; Tue, 23 Aug 2022 05:27:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661257636; cv=none; d=google.com; s=arc-20160816; b=AaS142jjlp1urdkoD+D2VbK/PYrgnyZNy9OvQ3xTx57ndOt81R7ve6MrjNNPeAa3/V TAFNtJq3MQyR19+oPHeY+215695tIgGCo4A15RE9apLUgx932yIk7X04xYpPKgPV7OAt feHU+K8y4E2x3cf8sVc3zTUPvxms+YAYR7WWgt7QA/2nokObutKWSuTtCKY3EcxfTEjQ 18t22VZaYPBn2wthQUb7u+gSp3CvzYXw35RIH0QmUmvcnY3j4s43mkf17W0+YX62OEHK MfxFH0xG7jRwyA9tL07nCCq//scMG0vRjoH26kuBGw0wOycvkTWfZFhJNGVbX88OrsX4 rdNA== 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=FJr21jLqMyDdPfogAFFfnQeUp6Oq4Nh76jK9pLEtB5Q=; b=rKACkYvlW9UtQlmaR9fxFhUnt0XloC+n/PRnZN/EqiCDvNy6qnE0rqtWluKQQzOoSW SJFEfeM1lU3Rg/nrPGNelX600iWLFmNwJCn6NX87xic63y/loY8VqnxalHgZm2WWhVfC GjL9e7PS0s1L83uKMWb1jaKZ/ZCmTs1zVV/08VxUaDq/Ph62IF9/wTx4i+lk5pWnvzqI iLB3oefEvsIBwSy0EJsaVpLavMpHD+3TjhHUxfAh+To9RNsVFRZ3IWQqD96smOQkWRpE nBk9UTGLMBqVKucOzpqDAakj/JA6PbPg7DL9+1MOrm3A4t2/WuYj3EFbSwZeDwNPUE8M 99eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ebh/g8kg"; 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 qf18-20020a1709077f1200b0073d865138fesi4848849ejc.645.2022.08.23.05.26.50; Tue, 23 Aug 2022 05:27:16 -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="ebh/g8kg"; 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 S1356204AbiHWKqq (ORCPT + 99 others); Tue, 23 Aug 2022 06:46:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355658AbiHWKkX (ORCPT ); Tue, 23 Aug 2022 06:40:23 -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 C622BDB0; Tue, 23 Aug 2022 02:08:14 -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 3CEE761598; Tue, 23 Aug 2022 09:08:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30B62C433C1; Tue, 23 Aug 2022 09:08:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245693; bh=pn7Xkki/c1OBI4ZWFGs7oupIMGY204Tf9wIvyQ/9v5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ebh/g8kgOm7RdRDWfQogw3W455WYbH6uRDc5QB6iw8u5NIk3Bkhzpb2BoW2awtLSC jvZlhUt3lxwceiQxu27EcEJ7RYqkRu1X4tUTMWVz+1iPGKzi3I6Tb7DEvw6iARbNu+ rBoE9gqnk0RANAacPOm+aauF0zo8y6Zjlyp4YDwI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Starke , Sasha Levin Subject: [PATCH 4.19 159/287] tty: n_gsm: fix missing corner cases in gsmld_poll() Date: Tue, 23 Aug 2022 10:25:28 +0200 Message-Id: <20220823080106.053513743@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@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 727707e02551..f6d2be13b32e 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -2561,12 +2561,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