# git rev-parse -q --verify 3593030761630e09200072a4bd06468892c27be3^{commit} 3593030761630e09200072a4bd06468892c27be3 already have revision, skipping fetch # git checkout -q -f -B kisskb 3593030761630e09200072a4bd06468892c27be3 # git clean -qxdf # < git log -1 # commit 3593030761630e09200072a4bd06468892c27be3 # Author: Linus Torvalds # Date: Tue Feb 15 15:28:00 2022 -0800 # # tty: n_tty: do not look ahead for EOL character past the end of the buffer # # Daniel Gibson reports that the n_tty code gets line termination wrong in # very specific cases: # # "If you feed a line with exactly 64 chars + terminating newline, and # directly afterwards (without reading) another line into a pseudo # terminal, the the first read() on the other side will return the 64 # char line *without* terminating newline, and the next read() will # return the missing terminating newline AND the complete next line (if # it fits in the buffer)" # # and bisected the behavior to commit 3b830a9c34d5 ("tty: convert # tty_ldisc_ops 'read()' function to take a kernel pointer"). # # Now, digging deeper, it turns out that the behavior isn't exactly new: # what changed in commit 3b830a9c34d5 was that the tty line discipline # .read() function is now passed an intermediate kernel buffer rather than # the final user space buffer. # # And that intermediate kernel buffer is 64 bytes in size - thus that # special case with exactly 64 bytes plus terminating newline. # # The same problem did exist before, but historically the boundary was not # the 64-byte chunk, but the user-supplied buffer size, which is obviously # generally bigger (and potentially bigger than N_TTY_BUF_SIZE, which # would hide the issue entirely). # # The reason is that the n_tty canon_copy_from_read_buf() code would look # ahead for the EOL character one byte further than it would actually # copy. It would then decide that it had found the terminator, and unmark # it as an EOL character - which in turn explains why the next read # wouldn't then be terminated by it. # # Now, the reason it did all this in the first place is related to some # historical and pretty obscure EOF behavior, see commit ac8f3bf8832a # ("n_tty: Fix poll() after buffer-limited eof push read") and commit # 40d5e0905a03 ("n_tty: Fix EOF push handling"). # # And the reason for the EOL confusion is that we treat EOF as a special # EOL condition, with the EOL character being NUL (aka "__DISABLED_CHAR" # in the kernel sources). # # So that EOF look-ahead also affects the normal EOL handling. # # This patch just removes the look-ahead that causes problems, because EOL # is much more critical than the historical "EOF in the middle of a line # that coincides with the end of the buffer" handling ever was. # # Now, it is possible that we should indeed re-introduce the "look at next # character to see if it's a EOF" behavior, but if so, that should be done # not at the kernel buffer chunk boundary in canon_copy_from_read_buf(), # but at a higher level, when we run out of the user buffer. # # In particular, the place to do that would be at the top of # 'n_tty_read()', where we check if it's a continuation of a previously # started read, and there is no more buffer space left, we could decide to # just eat the __DISABLED_CHAR at that point. # # But that would be a separate patch, because I suspect nobody actually # cares, and I'd like to get a report about it before bothering. # # Fixes: 3b830a9c34d5 ("tty: convert tty_ldisc_ops 'read()' function to take a kernel pointer") # Fixes: ac8f3bf8832a ("n_tty: Fix poll() after buffer-limited eof push read") # Fixes: 40d5e0905a03 ("n_tty: Fix EOF push handling") # Link: https://bugzilla.kernel.org/show_bug.cgi?id=215611 # Reported-and-tested-by: Daniel Gibson # Cc: Peter Hurley # Cc: Greg Kroah-Hartman # Cc: Jiri Slaby # Signed-off-by: Linus Torvalds # < /opt/cross/kisskb/korg/gcc-11.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-gcc --version # < /opt/cross/kisskb/korg/gcc-11.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-ld --version # < git log --format=%s --max-count=1 3593030761630e09200072a4bd06468892c27be3 # < make -s -j 32 ARCH=powerpc O=/kisskb/build/linus_powerpc-allyesconfig_powerpc-gcc11 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-11.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux- allyesconfig # Added to kconfig CONFIG_PROFILE_ALL_BRANCHES=n # Added to kconfig CONFIG_ENABLE_WARN_DEPRECATED=n # Added to kconfig CONFIG_ENABLE_MUST_CHECK=n # Added to kconfig CONFIG_DEBUG_INFO=n # Added to kconfig CONFIG_BUILD_DOCSRC=n # Added to kconfig CONFIG_MODULE_SIG=n # < make -s -j 32 ARCH=powerpc O=/kisskb/build/linus_powerpc-allyesconfig_powerpc-gcc11 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-11.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux- help # make -s -j 32 ARCH=powerpc O=/kisskb/build/linus_powerpc-allyesconfig_powerpc-gcc11 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-11.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux- olddefconfig # make -s -j 32 ARCH=powerpc O=/kisskb/build/linus_powerpc-allyesconfig_powerpc-gcc11 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-11.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux- /kisskb/src/arch/powerpc/boot/dts/fsl/mvme7100.dts:135.22-137.4: Warning (pci_bridge): /pcie@f1008000: missing ranges for PCI bridge (or not a bridge) also defined at /kisskb/src/arch/powerpc/boot/dts/fsl/mpc8641si-post.dtsi:92.7-117.3 /kisskb/src/arch/powerpc/boot/dts/fsl/mpc8641si-post.dtsi:102.9-116.4: Warning (pci_bridge): /pcie@f1008000/pcie@0: missing ranges for PCI bridge (or not a bridge) /kisskb/src/arch/powerpc/boot/dts/fsl/mvme7100.dts:139.22-141.4: Warning (pci_bridge): /pcie@f1009000: missing ranges for PCI bridge (or not a bridge) also defined at /kisskb/src/arch/powerpc/boot/dts/fsl/mpc8641si-post.dtsi:119.7-144.3 /kisskb/src/arch/powerpc/boot/dts/fsl/mpc8641si-post.dtsi:129.9-143.4: Warning (pci_bridge): /pcie@f1009000/pcie@0: missing ranges for PCI bridge (or not a bridge) arch/powerpc/boot/dts/fsl/mvme7100.dtb: Warning (unit_address_format): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/mvme7100.dtb: Warning (pci_device_reg): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/mvme7100.dtb: Warning (pci_device_bus_num): Failed prerequisite 'pci_bridge' /kisskb/src/arch/powerpc/boot/dts/fsl/mvme7100.dts:30.11-32.6: Warning (i2c_bus_reg): /soc@f1000000/i2c@3000/rtc@68: missing or empty reg property /kisskb/src/arch/powerpc/boot/dts/fsl/p2020rdb.dts:251.22-254.4: Warning (pci_bridge): /pcie@ffe08000: missing ranges for PCI bridge (or not a bridge) also defined at /kisskb/src/arch/powerpc/boot/dts/fsl/p2020si-post.dtsi:43.7-68.3 /kisskb/src/arch/powerpc/boot/dts/fsl/p2020si-post.dtsi:52.9-67.4: Warning (pci_bridge): /pcie@ffe08000/pcie@0: missing ranges for PCI bridge (or not a bridge) arch/powerpc/boot/dts/fsl/p2020rdb.dtb: Warning (unit_address_format): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/p2020rdb.dtb: Warning (pci_device_reg): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/p2020rdb.dtb: Warning (pci_device_bus_num): Failed prerequisite 'pci_bridge' /kisskb/src/arch/powerpc/boot/dts/fsl/mpc8541cds.dts:341.15-350.5: Warning (pci_device_reg): /pci@e0008000/i8259@19000: PCI unit address format error, expected "12,0" /kisskb/src/arch/powerpc/boot/dts/fsl/mpc8541cds.dts:330.3-21: Warning (pci_device_bus_num): /pci@e0008000/i8259@19000:bus-range: PCI bus number 1 out of range, expected (0 - 0) /kisskb/src/arch/powerpc/boot/dts/fsl/pq3-mpic.dtsi:38.2-25: Warning (interrupts_property): /soc@fffe00000/mdio@24000/ethernet-phy@0:#interrupt-cells: size is (8), expected multiple of 16 /kisskb/src/arch/powerpc/boot/dts/fsl/pq3-mpic.dtsi:38.2-25: Warning (interrupts_property): /soc@fffe00000/mdio@24000/ethernet-phy@1:#interrupt-cells: size is (8), expected multiple of 16 /kisskb/src/arch/powerpc/boot/dts/fsl/pq3-mpic.dtsi:38.2-25: Warning (interrupts_property): /soc@ffe00000/mdio@24000/ethernet-phy@0:#interrupt-cells: size is (8), expected multiple of 16 /kisskb/src/arch/powerpc/boot/dts/fsl/pq3-mpic.dtsi:38.2-25: Warning (interrupts_property): /soc@ffe00000/mdio@24000/ethernet-phy@1:#interrupt-cells: size is (8), expected multiple of 16 /kisskb/src/arch/powerpc/boot/dts/xpedite5200_xmon.dts:139.11-142.6: Warning (i2c_bus_reg): /soc@ef000000/i2c@3000/dtt@48: I2C bus unit address format error, expected "34" /kisskb/src/arch/powerpc/boot/dts/fsl/pq3-mpic.dtsi:38.2-25: Warning (interrupts_property): /soc@fffe00000/mdio@24000/ethernet-phy@0:#interrupt-cells: size is (8), expected multiple of 16 /kisskb/src/arch/powerpc/boot/dts/fsl/pq3-mpic.dtsi:38.2-25: Warning (interrupts_property): /soc@fffe00000/mdio@24000/ethernet-phy@1:#interrupt-cells: size is (8), expected multiple of 16 /kisskb/src/arch/powerpc/boot/dts/fsl/p1020rdb-pd.dts:189.11-193.6: Warning (spi_bus_reg): /soc@ffe00000/spi@7000/slic@0: SPI bus unit address format error, expected "1" /kisskb/src/arch/powerpc/boot/dts/fsl/p1020rdb-pd.dts:195.11-199.6: Warning (spi_bus_reg): /soc@ffe00000/spi@7000/slic@1: SPI bus unit address format error, expected "2" /kisskb/src/arch/powerpc/boot/dts/fsl/pq3-mpic.dtsi:38.2-25: Warning (interrupts_property): /soc@ffe00000/mdio@24000/ethernet-phy@0:#interrupt-cells: size is (8), expected multiple of 16 /kisskb/src/arch/powerpc/boot/dts/fsl/pq3-mpic.dtsi:38.2-25: Warning (interrupts_property): /soc@ffe00000/mdio@24000/ethernet-phy@1:#interrupt-cells: size is (8), expected multiple of 16 /kisskb/src/arch/powerpc/boot/dts/fsl/gef_sbc610.dts:209.22-211.4: Warning (pci_bridge): /pcie@fef09000: missing ranges for PCI bridge (or not a bridge) also defined at /kisskb/src/arch/powerpc/boot/dts/fsl/mpc8641si-post.dtsi:119.7-144.3 /kisskb/src/arch/powerpc/boot/dts/fsl/mpc8641si-post.dtsi:129.9-143.4: Warning (pci_bridge): /pcie@fef09000/pcie@0: missing ranges for PCI bridge (or not a bridge) arch/powerpc/boot/dts/fsl/gef_sbc610.dtb: Warning (unit_address_format): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/gef_sbc610.dtb: Warning (pci_device_reg): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/gef_sbc610.dtb: Warning (pci_device_bus_num): Failed prerequisite 'pci_bridge' /kisskb/src/arch/powerpc/boot/dts/fsl/mpc8555cds.dts:341.15-350.5: Warning (pci_device_reg): /pci@e0008000/i8259@19000: PCI unit address format error, expected "12,0" /kisskb/src/arch/powerpc/boot/dts/fsl/mpc8555cds.dts:330.3-21: Warning (pci_device_bus_num): /pci@e0008000/i8259@19000:bus-range: PCI bus number 1 out of range, expected (0 - 0) /kisskb/src/arch/powerpc/boot/dts/fsl/gef_ppc9a.dts:211.22-213.4: Warning (pci_bridge): /pcie@fef09000: missing ranges for PCI bridge (or not a bridge) also defined at /kisskb/src/arch/powerpc/boot/dts/fsl/mpc8641si-post.dtsi:119.7-144.3 /kisskb/src/arch/powerpc/boot/dts/fsl/mpc8641si-post.dtsi:129.9-143.4: Warning (pci_bridge): /pcie@fef09000/pcie@0: missing ranges for PCI bridge (or not a bridge) arch/powerpc/boot/dts/fsl/gef_ppc9a.dtb: Warning (unit_address_format): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/gef_ppc9a.dtb: Warning (pci_device_reg): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/gef_ppc9a.dtb: Warning (pci_device_bus_num): Failed prerequisite 'pci_bridge' /kisskb/src/arch/powerpc/boot/dts/bluestone.dts:272.13-277.7: Warning (i2c_bus_reg): /plb/opb/i2c@ef600700/sttm@4C: I2C bus unit address format error, expected "4c" /kisskb/src/arch/powerpc/boot/dts/fsl/oca4080.dts:132.23-134.4: Warning (pci_bridge): /pcie@ffe200000: missing ranges for PCI bridge (or not a bridge) also defined at /kisskb/src/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi:58.7-84.3 /kisskb/src/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi:68.9-83.4: Warning (pci_bridge): /pcie@ffe200000/pcie@0: missing ranges for PCI bridge (or not a bridge) /kisskb/src/arch/powerpc/boot/dts/fsl/oca4080.dts:136.23-138.4: Warning (pci_bridge): /pcie@ffe201000: missing ranges for PCI bridge (or not a bridge) also defined at /kisskb/src/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi:87.7-113.3 /kisskb/src/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi:97.9-112.4: Warning (pci_bridge): /pcie@ffe201000/pcie@0: missing ranges for PCI bridge (or not a bridge) /kisskb/src/arch/powerpc/boot/dts/fsl/oca4080.dts:140.23-142.4: Warning (pci_bridge): /pcie@ffe202000: missing ranges for PCI bridge (or not a bridge) also defined at /kisskb/src/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi:116.7-142.3 /kisskb/src/arch/powerpc/boot/dts/fsl/p4080si-post.dtsi:126.9-141.4: Warning (pci_bridge): /pcie@ffe202000/pcie@0: missing ranges for PCI bridge (or not a bridge) arch/powerpc/boot/dts/fsl/oca4080.dtb: Warning (unit_address_format): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/oca4080.dtb: Warning (pci_device_reg): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/oca4080.dtb: Warning (pci_device_bus_num): Failed prerequisite 'pci_bridge' /kisskb/src/arch/powerpc/boot/dts/fsl/ppa8548.dts:34.22-37.4: Warning (pci_bridge): /pci@fe0008000: missing ranges for PCI bridge (or not a bridge) also defined at /kisskb/src/arch/powerpc/boot/dts/fsl/mpc8548si-post.dtsi:43.7-51.3 /kisskb/src/arch/powerpc/boot/dts/fsl/ppa8548.dts:39.22-42.4: Warning (pci_bridge): /pci@fe0009000: missing ranges for PCI bridge (or not a bridge) also defined at /kisskb/src/arch/powerpc/boot/dts/fsl/mpc8548si-post.dtsi:54.7-62.3 /kisskb/src/arch/powerpc/boot/dts/fsl/ppa8548.dts:44.23-47.4: Warning (pci_bridge): /pcie@fe000a000: missing ranges for PCI bridge (or not a bridge) also defined at /kisskb/src/arch/powerpc/boot/dts/fsl/mpc8548si-post.dtsi:65.7-90.3 /kisskb/src/arch/powerpc/boot/dts/fsl/mpc8548si-post.dtsi:74.9-89.4: Warning (pci_bridge): /pcie@fe000a000/pcie@0: missing ranges for PCI bridge (or not a bridge) arch/powerpc/boot/dts/fsl/ppa8548.dtb: Warning (unit_address_format): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/ppa8548.dtb: Warning (pci_device_reg): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/ppa8548.dtb: Warning (pci_device_bus_num): Failed prerequisite 'pci_bridge' /kisskb/src/arch/powerpc/boot/dts/fsl/p2020rdb-pc_36b.dts:59.23-62.4: Warning (pci_bridge): /pcie@fffe08000: missing ranges for PCI bridge (or not a bridge) also defined at /kisskb/src/arch/powerpc/boot/dts/fsl/p2020si-post.dtsi:100.7-126.3 /kisskb/src/arch/powerpc/boot/dts/fsl/p2020si-post.dtsi:109.9-125.4: Warning (pci_bridge): /pcie@fffe08000/pcie@0: missing ranges for PCI bridge (or not a bridge) arch/powerpc/boot/dts/fsl/p2020rdb-pc_36b.dtb: Warning (unit_address_format): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/p2020rdb-pc_36b.dtb: Warning (pci_device_reg): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/p2020rdb-pc_36b.dtb: Warning (pci_device_bus_num): Failed prerequisite 'pci_bridge' /kisskb/src/arch/powerpc/boot/dts/fsl/p2020rdb-pc_32b.dts:59.22-62.4: Warning (pci_bridge): /pcie@ffe08000: missing ranges for PCI bridge (or not a bridge) also defined at /kisskb/src/arch/powerpc/boot/dts/fsl/p2020si-post.dtsi:100.7-126.3 /kisskb/src/arch/powerpc/boot/dts/fsl/p2020si-post.dtsi:109.9-125.4: Warning (pci_bridge): /pcie@ffe08000/pcie@0: missing ranges for PCI bridge (or not a bridge) arch/powerpc/boot/dts/fsl/p2020rdb-pc_32b.dtb: Warning (unit_address_format): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/p2020rdb-pc_32b.dtb: Warning (pci_device_reg): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/p2020rdb-pc_32b.dtb: Warning (pci_device_bus_num): Failed prerequisite 'pci_bridge' /kisskb/src/arch/powerpc/boot/dts/mpc5121.dtsi:457.13-466.5: Warning (spi_bus_bridge): /soc@80000000/psc@11900: node name for SPI buses should be 'spi' also defined at /kisskb/src/arch/powerpc/boot/dts/pdm360ng.dts:172.13-185.5 arch/powerpc/boot/dts/pdm360ng.dtb: Warning (spi_bus_reg): Failed prerequisite 'spi_bus_bridge' /kisskb/src/arch/powerpc/boot/dts/xpedite5200.dts:135.11-138.6: Warning (i2c_bus_reg): /soc@ef000000/i2c@3000/dtt@48: I2C bus unit address format error, expected "34" /kisskb/src/arch/powerpc/boot/dts/mpc8610_hpcd.dts:420.3-21: Warning (pci_device_bus_num): /pcie@e000a000/pcie@0:bus-range: PCI bus number 0 out of range, expected (1 - 3) /kisskb/src/arch/powerpc/boot/dts/fsl/kmcoge4.dts:196.23-198.4: Warning (pci_bridge): /pcie@ffe201000: missing ranges for PCI bridge (or not a bridge) also defined at /kisskb/src/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi:87.7-113.3 /kisskb/src/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi:97.9-112.4: Warning (pci_bridge): /pcie@ffe201000/pcie@0: missing ranges for PCI bridge (or not a bridge) arch/powerpc/boot/dts/fsl/kmcoge4.dtb: Warning (unit_address_format): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/kmcoge4.dtb: Warning (pci_device_reg): Failed prerequisite 'pci_bridge' arch/powerpc/boot/dts/fsl/kmcoge4.dtb: Warning (pci_device_bus_num): Failed prerequisite 'pci_bridge' /kisskb/src/arch/powerpc/boot/dts/stxssa8555.dts:340.15-349.5: Warning (pci_device_reg): /pci@e0008000/i8259@19000: PCI unit address format error, expected "12,0" /kisskb/src/arch/powerpc/boot/dts/stxssa8555.dts:329.3-21: Warning (pci_device_bus_num): /pci@e0008000/i8259@19000:bus-range: PCI bus number 1 out of range, expected (0 - 0) /kisskb/src/arch/powerpc/boot/dts/mgcoge.dts:230.14-234.7: Warning (spi_bus_reg): /soc@f0000000/cpm@119c0/spi@11aa0/ds3106@1: SPI bus unit address format error, expected "0" /kisskb/src/arch/powerpc/boot/dts/mpc5121.dtsi:397.13-406.5: Warning (spi_bus_bridge): /soc@80000000/psc@11400: node name for SPI buses should be 'spi' also defined at /kisskb/src/arch/powerpc/boot/dts/ac14xx.dts:305.19-326.5 /kisskb/src/arch/powerpc/boot/dts/mpc5121.dtsi:409.13-418.5: Warning (spi_bus_bridge): /soc@80000000/psc@11500: node name for SPI buses should be 'spi' also defined at /kisskb/src/arch/powerpc/boot/dts/ac14xx.dts:329.19-344.5 arch/powerpc/boot/dts/ac14xx.dtb: Warning (spi_bus_reg): Failed prerequisite 'spi_bus_bridge' Completed OK # rm -rf /kisskb/build/linus_powerpc-allyesconfig_powerpc-gcc11 # Build took: 0:42:52.593427