Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5984452pxb; Mon, 14 Feb 2022 12:21:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRuAAKEHD8bXsDAzMyYFV7ZPuTW5vHQ0SReuEJ60wLn0oOef7EU5Si47UqAQqJQGP2brf0 X-Received: by 2002:a17:90b:1c0f:b0:1b8:89a2:5d3c with SMTP id oc15-20020a17090b1c0f00b001b889a25d3cmr392457pjb.15.1644870100690; Mon, 14 Feb 2022 12:21:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644870100; cv=none; d=google.com; s=arc-20160816; b=eytRguGTihMPcPy/HsHe252Pz7b7bemtGtyZ1uZYpYoNsPpPH88YrIlVLLBrmNJqgU VKo9D/kmJpQl2QJtR0FCe1CV1KBVLKdkGhbWx9m2SZS39YKBlhEJAy0A8vNqZ5kHdPvY YR42dHWyWlmTF5eSJ+Z0wUvztCWZOBGOGzKa8PAHeXF/C3Zt9KjDncW/lNsG6ybl6CPm Jn9lKQffch4qhz5uT7T8hyY6L+eTwLmPq70gQPOvBgQJ2n9Wa875QVPLMemqJIkAr0F/ /PZJ11NyvnvCkdxdO8o1njZCFe/H9u/RBWaJ2Gs69OsJH09VD7KV1PyA77DnhbR7Iw4G j4zQ== 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=rMG1ou7sw0lmwfVmu94gO8TmG6G8B7CUrzp4hTSFYyU=; b=SxJNHe/tY/GP/TxilsUdwvU8t2QxxwARFgSBn01OXbaK36nrwiY+NRvnHOgt2FRlb7 qpnwpoCQwDmEz4M8rpMq/KUud2YFQ3uzBfJpXh5mHLUFHX/U2Hx9YHlCHFrwlC7LeGQs 2afckqkm2FnNJcSaYFzTasQpN1rVZVEqS9Km0fz38XFghh4P9cQ8Ldwg4k+2yv0s8VY2 h3lvgzanFQgECx3qh6Y5LTEyrTFZCgbb8m0fArUJ5IfeD2A5j5qLZJBt8aVLCN2LMVa4 QUcPO4n/k6mBDdgPltn+B34U4YRB8qHW56xNJYdFHQiGsuL7IiTaiEb1ohuUt77NT+K7 QOsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uYnhzYfq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n2si663852pgl.713.2022.02.14.12.21.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 12:21:40 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uYnhzYfq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 83E3213E28; Mon, 14 Feb 2022 11:55:13 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343876AbiBNJyz (ORCPT + 99 others); Mon, 14 Feb 2022 04:54:55 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:60850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344375AbiBNJvn (ORCPT ); Mon, 14 Feb 2022 04:51:43 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55B1966FA5; Mon, 14 Feb 2022 01:42:48 -0800 (PST) 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 E50D061172; Mon, 14 Feb 2022 09:42:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1599C340E9; Mon, 14 Feb 2022 09:42:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644831767; bh=EmdIkX7A7iEE+I7vI3N50D/Fv19L8KBxC1mzjgrtM7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uYnhzYfqAZeEb7IU2ih068+W4CJL/GYGHL5PEE4fi6UCIQOBXjcI8TEq7mdtYcWCv Q4Mr/y3ebxuFb3quFj25vKWGR7FH+yYCy8b68n13iJh5vZhq277Pf7X/lNeMpxt4H/ JhyqiOZ0Myj6TTlHs00lyC4LsP/kjYFtpQvxCLCg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kosuke Tatsukawa Subject: [PATCH 5.10 089/116] n_tty: wake up poll(POLLRDNORM) on receiving data Date: Mon, 14 Feb 2022 10:26:28 +0100 Message-Id: <20220214092501.842412778@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214092458.668376521@linuxfoundation.org> References: <20220214092458.668376521@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: TATSUKAWA KOSUKE (立川 江介) commit c816b2e65b0e86b95011418cad334f0524fc33b8 upstream. The poll man page says POLLRDNORM is equivalent to POLLIN when used as an event. $ man poll POLLRDNORM Equivalent to POLLIN. However, in n_tty driver, POLLRDNORM does not return until timeout even if there is terminal input, whereas POLLIN returns. The following test program works until kernel-3.17, but the test stops in poll() after commit 57087d515441 ("tty: Fix spurious poll() wakeups"). [Steps to run test program] $ cc -o test-pollrdnorm test-pollrdnorm.c $ ./test-pollrdnorm foo <-- Type in something from the terminal followed by [RET]. The string should be echoed back. ------------------------< test-pollrdnorm.c >------------------------ #include #include #include #include void main(void) { int n; unsigned char buf[8]; struct pollfd fds[1] = {{ 0, POLLRDNORM, 0 }}; n = poll(fds, 1, -1); if (n < 0) perror("poll"); n = read(0, buf, 8); if (n < 0) perror("read"); if (n > 0) write(1, buf, n); } ------------------------------------------------------------------------ The attached patch fixes this problem. Many calls to wake_up_interruptible_poll() in the kernel source code already specify "POLLIN | POLLRDNORM". Fixes: 57087d515441 ("tty: Fix spurious poll() wakeups") Cc: stable@vger.kernel.org Signed-off-by: Kosuke Tatsukawa Link: https://lore.kernel.org/r/TYCPR01MB81901C0F932203D30E452B3EA5209@TYCPR01MB8190.jpnprd01.prod.outlook.com Signed-off-by: Greg Kroah-Hartman --- drivers/tty/n_tty.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -1372,7 +1372,7 @@ handle_newline: put_tty_queue(c, ldata); smp_store_release(&ldata->canon_head, ldata->read_head); kill_fasync(&tty->fasync, SIGIO, POLL_IN); - wake_up_interruptible_poll(&tty->read_wait, EPOLLIN); + wake_up_interruptible_poll(&tty->read_wait, EPOLLIN | EPOLLRDNORM); return 0; } } @@ -1653,7 +1653,7 @@ static void __receive_buf(struct tty_str if (read_cnt(ldata)) { kill_fasync(&tty->fasync, SIGIO, POLL_IN); - wake_up_interruptible_poll(&tty->read_wait, EPOLLIN); + wake_up_interruptible_poll(&tty->read_wait, EPOLLIN | EPOLLRDNORM); } }