linux-stable/drivers/tty
TATSUKAWA KOSUKE (立川 江介) c816b2e65b n_tty: wake up poll(POLLRDNORM) on receiving data
The poll man page says POLLRDNORM is equivalent to POLLIN when used as
an event.
$ man poll
<snip>
              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 57087d5154 ("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 <stdio.h>
  #include <errno.h>
  #include <poll.h>
  #include <unistd.h>

  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: 57087d5154 ("tty: Fix spurious poll() wakeups")
Cc: stable@vger.kernel.org
Signed-off-by: Kosuke Tatsukawa <tatsu-ab1@nec.com>
Link: https://lore.kernel.org/r/TYCPR01MB81901C0F932203D30E452B3EA5209@TYCPR01MB8190.jpnprd01.prod.outlook.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-01-31 14:31:28 +01:00
..
hvc xen/console: harden hvc_xen against event channel storms 2021-12-16 08:24:08 +01:00
ipwireless tty: drop put_tty_driver 2021-07-27 12:17:21 +02:00
serdev Revert "serdev: BREAK/FRAME/PARITY/OVERRUN notification prototype V2" 2021-12-31 13:42:30 +01:00
serial serial: core: Initialize rs485 RTS polarity already on probe 2022-01-26 14:53:12 +01:00
vt tty: Fix the keyboard led light display problem 2021-12-21 09:19:14 +01:00
amiserial.c tty: drop put_tty_driver 2021-07-27 12:17:21 +02:00
ehv_bytechan.c tty: drop put_tty_driver 2021-07-27 12:17:21 +02:00
goldfish.c tty: goldfish: Use platform_get_irq() to get the interrupt 2021-12-30 13:50:05 +01:00
Kconfig tty: add rpmsg driver 2021-10-21 12:35:35 +02:00
Makefile tty: add rpmsg driver 2021-10-21 12:35:35 +02:00
mips_ejtag_fdc.c tty: mips_ejtag_fdc: Make use of the helper function kthread_run_on_cpu() 2021-12-03 16:00:41 +01:00
moxa.c tty: drivers/tty/, stop using tty_schedule_flip() 2021-11-25 18:35:23 +01:00
mxser.c mxser: use PCI_DEVICE_DATA 2021-11-25 18:33:22 +01:00
n_gsm.c tty: n_gsm: fix SW flow control encoding/handling 2022-01-26 14:51:42 +01:00
n_hdlc.c Linux 5.16-rc6 2021-12-20 10:00:30 +01:00
n_null.c tty: make tty_ldisc_ops a param in tty_unregister_ldisc 2021-05-13 16:57:16 +02:00
n_tty.c n_tty: wake up poll(POLLRDNORM) on receiving data 2022-01-31 14:31:28 +01:00
nozomi.c tty: drop put_tty_driver 2021-07-27 12:17:21 +02:00
pty.c tty: pty: correct function name pty_resize() 2021-05-20 16:33:06 +02:00
rpmsg_tty.c tty: rpmsg: Fix race condition releasing tty port 2022-01-26 14:50:26 +01:00
synclink_gt.c tty: synclink_gt: rename a conflicting function name 2021-09-14 10:51:37 +02:00
sysrq.c TTY / Serial driver update for 5.16-rc1 2021-11-04 09:09:37 -07:00
tty.h tty: clean include/linux/tty.h up 2021-04-15 10:32:17 +02:00
tty_audit.c tty: audit: move some local functions out of tty.h 2021-04-15 10:24:58 +02:00
tty_baudrate.c tty: baudrate: Explicit usage of B0 for encoding input baudrate 2021-10-05 15:00:56 +02:00
tty_buffer.c tty: reformat kernel-doc in tty_buffer.c 2021-11-26 16:27:43 +01:00
tty_io.c tty: tty_io: Switch to vmalloc() fallback in case of TTY_NO_WRITE_SPLIT 2021-12-21 09:18:44 +01:00
tty_ioctl.c tty: remove file from n_tty_ioctl_helper 2021-09-22 16:59:13 +02:00
tty_jobctrl.c tty: tty_jobctrl: Fix 2 incorrectly documented functions 2021-05-20 17:06:15 +02:00
tty_ldisc.c tty: reformat kernel-doc in tty_ldisc.c 2021-11-26 16:27:43 +01:00
tty_ldsem.c tty/ldsem: Fix syntax errors in comments 2021-12-21 09:15:49 +01:00
tty_mutex.c tty: move some internal tty lock enums and functions out of tty.h 2021-04-15 10:26:58 +02:00
tty_port.c tty: add kernel-doc for more tty_port functions 2021-11-26 16:27:43 +01:00
ttynull.c tty: drop put_tty_driver 2021-07-27 12:17:21 +02:00
vcc.c tty: drop put_tty_driver 2021-07-27 12:17:21 +02:00