Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2874014rwb; Mon, 15 Aug 2022 13:04:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR5CQfq+Qi5IuwDFTVzRw+L5dRtApAZBKuhjqQHGOlG15+1/SXreXOLnRubGw4/z4fExR3Sx X-Received: by 2002:a17:903:493:b0:170:d825:f8d3 with SMTP id jj19-20020a170903049300b00170d825f8d3mr18572725plb.34.1660593880517; Mon, 15 Aug 2022 13:04:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660593880; cv=none; d=google.com; s=arc-20160816; b=IK0+Dt5veFwakti4+8YUIRTK7Fp3mvIiI77lL5pS6dwZp4BbH4DAw0mKZiU8ZyiTbB +Ziyi6R68cOSK3ECVS4PoDjHGLdt8fMl7s+OUsgELamdZc8FZFH+spTs81h6W1GhTfgU Q56tQxVOzdkpDMRxBi9JVnjqIK5mlNozSi+FjDbS6mZqnO8yAHg1L+LaCuAqCTWycIEj uS3PFihHHQftZwKq/JCfz4bGPw4hnY9xewWa0ujnKFrizn9br9PsLkWPFvOSEDa4HFuo quKY5yB7bcT4a2QOU3EHHcAJCcTjZoyo+tvsFqb2UgHke2dSjRmzpFaUeHkqKvNudWu/ RUUg== 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=iVwPLc37hDGXqRahqxbQu8hwSDzqyVRH6MMMO7Ebrys=; b=zC4tL8xC29s8QpvEOEEPctNBLZ/oIN1TGY8Ka6XYVPKyKwxkderXkhtTEQOoddiL3+ DzNTDoVjsXq0WtAY/5ul6nX+s8T2WcJixcUu0J6jR4V/Yxla46aJZVPC++4tbkcGISwW AgbJZ2uTGE9538BcrqCgOZsVtj0ey7vPHEus8woQotp5/gQUkQnoE4qekCFofloam8f/ /WN1d9sKUjXPKoSa4evGxahAzZz4dS3WV8Td6M7pnSwstXDIxVMfIunEVPodNz+fK6JI fK1cvLUBcxcrONNAwjvfpskxbAqCmlaVRqSvUiWOpFuxNYUof1Tw6urJj70+lhuoxnI9 3Y2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=y76iTdc9; 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 i62-20020a638741000000b0041de4749f80si11951808pge.277.2022.08.15.13.04.29; Mon, 15 Aug 2022 13:04:40 -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=y76iTdc9; 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 S1343500AbiHOTjV (ORCPT + 99 others); Mon, 15 Aug 2022 15:39:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344295AbiHOTg3 (ORCPT ); Mon, 15 Aug 2022 15:36:29 -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 091AC30544; Mon, 15 Aug 2022 11:45:53 -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 52779611C1; Mon, 15 Aug 2022 18:45:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22483C433D6; Mon, 15 Aug 2022 18:45:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589151; bh=7NiuDdZp+VFXZf96F2eqTvZlHVtKr2r82h+BlquUbbE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y76iTdc9trS6YJjX2GuHS4DngfoQ8q/5hnV5RaeK5xlSz+qaMZH9swm5iu+YCGEZJ u5rI40gRqd1sncZU6yEZl10myNdythdzvnV+lF0i3tDlyrhireNmqEXYN7zlQvPI7Q Umrr+Msdfh1KvkRwAMmGSApZfoiWK2883cIzzic4= 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.15 598/779] tty: n_gsm: fix missing corner cases in gsmld_poll() Date: Mon, 15 Aug 2022 20:04:02 +0200 Message-Id: <20220815180402.919621462@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 7a82fff7f5fe..b89655f585f1 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c @@ -2954,12 +2954,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