1. 10 6月, 2022 2 次提交
  2. 26 11月, 2021 1 次提交
  3. 30 8月, 2021 1 次提交
    • N
      console: consume APC, DM, DCS · 3a2b2eb5
      nick black 提交于
      The Linux console's VT102 implementation already consumes OSC
      ("Operating System Command") sequences, probably because that's how
      palette changes are transmitted.
      
      In addition to OSC, there are three other major clases of ANSI control
      strings: APC ("Application Program Command"), PM ("Privacy Message"),
      and DCS ("Device Control String").  They are handled similarly to OSC in
      terms of termination.
      
      Source: vt100.net
      
      Add three new enumerated states, one for each of these types.  All three
      are handled the same way right now--they simply consume input until
      terminated.  I hope to expand upon this firmament in the future.  Add
      new predicate ansi_control_string(), returning true for any of these
      states.  Replace explicit checks against ESosc with calls to this
      function.  Transition to these states appropriately from the escape
      initiation (ESesc) state.
      
      This was motivated by the following Notcurses bugs:
      
       https://github.com/dankamongmen/notcurses/issues/2050
       https://github.com/dankamongmen/notcurses/issues/1828
       https://github.com/dankamongmen/notcurses/issues/2069
      
      where standard VT sequences are not consumed by the Linux console.  It's
      not necessary that the Linux console *support* these sequences, but it
      ought *consume* these well-specified classes of sequences.
      
      Tested by sending a variety of escape sequences to the console, and
      verifying that they still worked, or were now properly consumed.
      Verified that the escapes were properly terminated at a generic level.
      Verified that the Notcurses tools continued to show expected output on
      the Linux console, except now without escape bleedthrough.
      
      Link: https://lore.kernel.org/lkml/YSydL0q8iaUfkphg@schwarzgerat.orthanc/Signed-off-by: Nnick black <dankamongmen@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Jiri Slaby <jirislaby@kernel.org>
      Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3a2b2eb5
  4. 27 7月, 2021 1 次提交
    • J
      tty: stop using alloc_tty_driver · 39b7b42b
      Jiri Slaby 提交于
      alloc_tty_driver was deprecated by tty_alloc_driver in commit
      7f0bc6a6 (TTY: pass flags to alloc_tty_driver) in 2012.
      
      I never got into eliminating alloc_tty_driver until now. So we still
      have two functions for allocating drivers which might be confusing. So
      get rid of alloc_tty_driver uses to eliminate it for good in the next
      patch.
      
      Note we need to switch return value checking as tty_alloc_driver uses
      ERR_PTR. And flags are now a parameter of tty_alloc_driver.
      
      Cc: Richard Henderson <rth@twiddle.net>(odd fixer:ALPHA PORT)
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Jeff Dike <jdike@addtoit.com>
      Cc: Richard Weinberger <richard@nod.at>
      Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
      Cc: Jens Taprogge <jens.taprogge@taprogge.org>
      Cc: Karsten Keil <isdn@linux-pingi.de>
      Cc: Ulf Hansson <ulf.hansson@linaro.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Laurentiu Tudor <laurentiu.tudor@nxp.com>
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: David Sterba <dsterba@suse.com>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Cc: Oliver Neukum <oneukum@suse.com>
      Cc: Felipe Balbi <balbi@kernel.org>
      Cc: Johan Hovold <johan@kernel.org>
      Cc: Marcel Holtmann <marcel@holtmann.org>
      Cc: Johan Hedberg <johan.hedberg@gmail.com>
      Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
      Acked-by: NSamuel Iglesias Gonsálvez <siglesias@igalia.com>
      Acked-by: NMax Filippov <jcmvbkbc@gmail.com>
      Acked-by: NDavid Sterba <dsterba@suse.com>
      Acked-by: NChristian Borntraeger <borntraeger@de.ibm.com>
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Link: https://lore.kernel.org/r/20210723074317.32690-5-jslaby@suse.czSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      39b7b42b
  5. 21 7月, 2021 1 次提交
    • I
      tty: Fix out-of-bound vmalloc access in imageblit · 3b0c4061
      Igor Matheus Andrade Torrente 提交于
      This issue happens when a userspace program does an ioctl
      FBIOPUT_VSCREENINFO passing the fb_var_screeninfo struct
      containing only the fields xres, yres, and bits_per_pixel
      with values.
      
      If this struct is the same as the previous ioctl, the
      vc_resize() detects it and doesn't call the resize_screen(),
      leaving the fb_var_screeninfo incomplete. And this leads to
      the updatescrollmode() calculates a wrong value to
      fbcon_display->vrows, which makes the real_y() return a
      wrong value of y, and that value, eventually, causes
      the imageblit to access an out-of-bound address value.
      
      To solve this issue I made the resize_screen() be called
      even if the screen does not need any resizing, so it will
      "fix and fill" the fb_var_screeninfo independently.
      
      Cc: stable <stable@vger.kernel.org> # after 5.15-rc2 is out, give it time to bake
      Reported-and-tested-by: syzbot+858dc7a2f7ef07c2c219@syzkaller.appspotmail.com
      Signed-off-by: NIgor Matheus Andrade Torrente <igormtorrente@gmail.com>
      Link: https://lore.kernel.org/r/20210628134509.15895-1-igormtorrente@gmail.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3b0c4061
  6. 15 5月, 2021 1 次提交
  7. 14 5月, 2021 1 次提交
  8. 13 5月, 2021 4 次提交
    • J
      tty: make tty_operations::write_room return uint · 03b3b1a2
      Jiri Slaby 提交于
      Line disciplines expect a positive value or zero returned from
      tty->ops->write_room (invoked by tty_write_room). So make this
      assumption explicit by using unsigned int as a return value. Both of
      tty->ops->write_room and tty_write_room.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Acked-by: NLaurentiu Tudor <laurentiu.tudor@nxp.com>
      Acked-by: NAlex Elder <elder@linaro.org>
      Acked-by: Max Filippov <jcmvbkbc@gmail.com> # xtensa
      Acked-by: NDavid Sterba <dsterba@suse.com>
      Acked-By: NAnton Ivanov <anton.ivanov@cambridgegreys.com>
      Acked-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Jeff Dike <jdike@addtoit.com>
      Cc: Richard Weinberger <richard@nod.at>
      Cc: Chris Zankel <chris@zankel.net>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
      Cc: Jens Taprogge <jens.taprogge@taprogge.org>
      Cc: Karsten Keil <isdn@linux-pingi.de>
      Cc: Scott Branden <scott.branden@broadcom.com>
      Cc: Ulf Hansson <ulf.hansson@linaro.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: David Lin <dtwlin@gmail.com>
      Cc: Johan Hovold <johan@kernel.org>
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Cc: Oliver Neukum <oneukum@suse.com>
      Cc: Felipe Balbi <balbi@kernel.org>
      Cc: Mathias Nyman <mathias.nyman@intel.com>
      Cc: Marcel Holtmann <marcel@holtmann.org>
      Cc: Johan Hedberg <johan.hedberg@gmail.com>
      Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
      Link: https://lore.kernel.org/r/20210505091928.22010-23-jslaby@suse.czSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      03b3b1a2
    • J
      tty: cumulate and document tty_struct::ctrl* members · 64d608db
      Jiri Slaby 提交于
      Group the ctrl members under a single struct called ctrl. The new struct
      contains 'pgrp', 'session', 'pktstatus', and 'packet'. 'pktstatus' and
      'packet' used to be bits in a bitfield. The struct also contains the
      lock protecting them to share the same cache line.
      
      Note that commit c545b66c (tty: Serialize tcflow() with other tty
      flow control changes) added a padding to the original bitfield. It was
      for the bitfield to occupy a whole 64b word to avoid interferring stores
      on Alpha (cannot we evaporate this arch with weird implications to C
      code yet?). But it doesn't work as expected as the padding
      (tty_struct::ctrl_unused) is aligned to a 8B boundary too and occupies
      some bytes from the next word.
      
      So make it reliable by:
      1) setting __aligned of the struct -- that aligns the start, and
      2) making 'unsigned long unused[0]' as the last member of the struct --
         pads the end.
      
      Add a kerneldoc comment for this grouped members.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: netdev@vger.kernel.org
      Link: https://lore.kernel.org/r/20210505091928.22010-14-jslaby@suse.czSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      64d608db
    • J
      tty: cumulate and document tty_struct::flow* members · 6e94dbc7
      Jiri Slaby 提交于
      Group the flow flags under a single struct called flow. The new struct
      contains 'stopped' and 'tco_stopped' bools which used to be bits in a
      bitfield. The struct also contains the lock protecting them to
      potentially share the same cache line.
      
      Note that commit c545b66c (tty: Serialize tcflow() with other tty
      flow control changes) added a padding to the original bitfield. It was
      for the bitfield to occupy a whole 64b word to avoid interferring stores
      on Alpha (cannot we evaporate this arch with weird implications to C
      code yet?). But it doesn't work as expected as the padding
      (tty_struct::unused) is aligned to a 8B boundary too and occupies some
      bytes from the next word.
      
      So make it reliable by:
      1) setting __aligned of the struct -- that aligns the start, and
      2) making 'unsigned long unused[0]' as the last member of the struct --
         pads the end.
      
      This is also the perfect time to start the documentation of tty_struct
      where all this lives. So we start by documenting what these bools
      actually serve for. And why we do all the alignment dances. Only the few
      up-to-date information from the Theodore's comment made it into this new
      Kerneldoc comment.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Jonathan Corbet <corbet@lwn.net>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Ulf Hansson <ulf.hansson@linaro.org>
      Cc: Heiko Carstens <hca@linux.ibm.com>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Shawn Guo <shawnguo@kernel.org>
      Cc: Sascha Hauer <s.hauer@pengutronix.de>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: "Maciej W. Rozycki" <macro@orcam.me.uk>
      Link: https://lore.kernel.org/r/20210505091928.22010-13-jslaby@suse.czSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6e94dbc7
    • J
      tty: remove broken r3964 line discipline · ed5aecd3
      Jiri Slaby 提交于
      Noone stepped up in the past two years since it was marked as BROKEN by
      commit c7084edc (tty: mark Siemens R3964 line discipline as BROKEN).
      Remove the line discipline for good.
      
      Three remarks:
      * we remove also the uapi header (as noone is able to use that interface
        anyway)
      * we do *not* remove the N_R3964 constant definition from tty.h, so it
        remains reserved.
      * in_interrupt() check is now removed from vt's con_put_char. Noone else
        calls tty_operations::put_char from interrupt context.
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Link: https://lore.kernel.org/r/20210505091928.22010-2-jslaby@suse.czSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ed5aecd3
  9. 28 3月, 2021 1 次提交
  10. 23 3月, 2021 1 次提交
  11. 07 1月, 2021 2 次提交
  12. 09 11月, 2020 1 次提交
    • D
      vt: Disable KD_FONT_OP_COPY · 3c4e0dff
      Daniel Vetter 提交于
      It's buggy:
      
      On Fri, Nov 06, 2020 at 10:30:08PM +0800, Minh Yuan wrote:
      > We recently discovered a slab-out-of-bounds read in fbcon in the latest
      > kernel ( v5.10-rc2 for now ).  The root cause of this vulnerability is that
      > "fbcon_do_set_font" did not handle "vc->vc_font.data" and
      > "vc->vc_font.height" correctly, and the patch
      > <https://lkml.org/lkml/2020/9/27/223> for VT_RESIZEX can't handle this
      > issue.
      >
      > Specifically, we use KD_FONT_OP_SET to set a small font.data for tty6, and
      > use  KD_FONT_OP_SET again to set a large font.height for tty1. After that,
      > we use KD_FONT_OP_COPY to assign tty6's vc_font.data to tty1's vc_font.data
      > in "fbcon_do_set_font", while tty1 retains the original larger
      > height. Obviously, this will cause an out-of-bounds read, because we can
      > access a smaller vc_font.data with a larger vc_font.height.
      
      Further there was only one user ever.
      - Android's loadfont, busybox and console-tools only ever use OP_GET
        and OP_SET
      - fbset documentation only mentions the kernel cmdline font: option,
        not anything else.
      - systemd used OP_COPY before release 232 published in Nov 2016
      
      Now unfortunately the crucial report seems to have gone down with
      gmane, and the commit message doesn't say much. But the pull request
      hints at OP_COPY being broken
      
      https://github.com/systemd/systemd/pull/3651
      
      So in other words, this never worked, and the only project which
      foolishly every tried to use it, realized that rather quickly too.
      
      Instead of trying to fix security issues here on dead code by adding
      missing checks, fix the entire thing by removing the functionality.
      
      Note that systemd code using the OP_COPY function ignored the return
      value, so it doesn't matter what we're doing here really - just in
      case a lone server somewhere happens to be extremely unlucky and
      running an affected old version of systemd. The relevant code from
      font_copy_to_all_vcs() in systemd was:
      
      	/* copy font from active VT, where the font was uploaded to */
      	cfo.op = KD_FONT_OP_COPY;
      	cfo.height = vcs.v_active-1; /* tty1 == index 0 */
      	(void) ioctl(vcfd, KDFONTOP, &cfo);
      
      Note this just disables the ioctl, garbage collecting the now unused
      callbacks is left for -next.
      
      v2: Tetsuo found the old mail, which allowed me to find it on another
      archive. Add the link too.
      Acked-by: NPeilin Ye <yepeilin.cs@gmail.com>
      Reported-by: NMinh Yuan <yuanmingbuaa@gmail.com>
      References: https://lists.freedesktop.org/archives/systemd-devel/2016-June/036935.html
      References: https://github.com/systemd/systemd/pull/3651
      Cc: Greg KH <greg@kroah.com>
      Cc: Peilin Ye <yepeilin.cs@gmail.com>
      Cc: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
      Signed-off-by: NDaniel Vetter <daniel.vetter@intel.com>
      Link: https://lore.kernel.org/r/20201108153806.3140315-1-daniel.vetter@ffwll.chSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3c4e0dff
  13. 24 8月, 2020 1 次提交
  14. 18 8月, 2020 5 次提交
  15. 22 7月, 2020 2 次提交
    • A
      tty: vt: Replace HTTP links with HTTPS ones · a6fdf0c7
      Alexander A. Klimov 提交于
      Rationale:
      Reduces attack surface on kernel devs opening the links for MITM
      as HTTPS traffic is much harder to manipulate.
      
      Deterministic algorithm:
      For each file:
        If not .svg:
          For each line:
            If doesn't contain `\bxmlns\b`:
              For each link, `\bhttp://[^# \t\r\n]*(?:\w|/)`:
      	  If neither `\bgnu\.org/license`, nor `\bmozilla\.org/MPL\b`:
                  If both the HTTP and HTTPS versions
                  return 200 OK and serve the same content:
                    Replace HTTP with HTTPS.
      Signed-off-by: NAlexander A. Klimov <grandmaster@al2klimov.de>
      Link: https://lore.kernel.org/r/20200718133452.24290-1-grandmaster@al2klimov.deSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a6fdf0c7
    • T
      vt: Reject zero-sized screen buffer size. · ce684552
      Tetsuo Handa 提交于
      syzbot is reporting general protection fault in do_con_write() [1] caused
      by vc->vc_screenbuf == ZERO_SIZE_PTR caused by vc->vc_screenbuf_size == 0
      caused by vc->vc_cols == vc->vc_rows == vc->vc_size_row == 0 caused by
      fb_set_var() from ioctl(FBIOPUT_VSCREENINFO) on /dev/fb0 , for
      gotoxy(vc, 0, 0) from reset_terminal() from vc_init() from vc_allocate()
       from con_install() from tty_init_dev() from tty_open() on such console
      causes vc->vc_pos == 0x10000000e due to
      ((unsigned long) ZERO_SIZE_PTR) + -1U * 0 + (-1U << 1).
      
      I don't think that a console with 0 column or 0 row makes sense. And it
      seems that vc_do_resize() does not intend to allow resizing a console to
      0 column or 0 row due to
      
        new_cols = (cols ? cols : vc->vc_cols);
        new_rows = (lines ? lines : vc->vc_rows);
      
      exception.
      
      Theoretically, cols and rows can be any range as long as
      0 < cols * rows * 2 <= KMALLOC_MAX_SIZE is satisfied (e.g.
      cols == 1048576 && rows == 2 is possible) because of
      
        vc->vc_size_row = vc->vc_cols << 1;
        vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row;
      
      in visual_init() and kzalloc(vc->vc_screenbuf_size) in vc_allocate().
      
      Since we can detect cols == 0 or rows == 0 via screenbuf_size = 0 in
      visual_init(), we can reject kzalloc(0). Then, vc_allocate() will return
      an error, and con_write() will not be called on a console with 0 column
      or 0 row.
      
      We need to make sure that integer overflow in visual_init() won't happen.
      Since vc_do_resize() restricts cols <= 32767 and rows <= 32767, applying
      1 <= cols <= 32767 and 1 <= rows <= 32767 restrictions to vc_allocate()
      will be practically fine.
      
      This patch does not touch con_init(), for returning -EINVAL there
      does not help when we are not returning -ENOMEM.
      
      [1] https://syzkaller.appspot.com/bug?extid=017265e8553724e514e8Reported-and-tested-by: Nsyzbot <syzbot+017265e8553724e514e8@syzkaller.appspotmail.com>
      Signed-off-by: NTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: stable <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20200712111013.11881-1-penguin-kernel@I-love.SAKURA.ne.jpSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ce684552
  16. 24 6月, 2020 15 次提交