1. 13 May, 2021 3 commits
    • Maciej W. Rozycki's avatar
      vt: Fix character height handling with VT_RESIZEX · 860dafa9
      Maciej W. Rozycki authored
      Restore the original intent of the VT_RESIZEX ioctl's `v_clin' parameter
      which is the number of pixel rows per character (cell) rather than the
      height of the font used.
      
      For framebuffer devices the two values are always the same, because the
      former is inferred from the latter one.  For VGA used as a true text
      mode device these two parameters are independent from each other: the
      number of pixel rows per character is set in the CRT controller, while
      font height is in fact hardwired to 32 pixel rows and fonts of heights
      below that value are handled by padding their data with blanks when
      loaded to hardware for use by the character generator.  One can change
      the setting in the CRT controller and it will update the screen contents
      accordingly regardless of the font loaded.
      
      The `v_clin' parameter is used by the `vgacon' driver to set the height
      of the character cell and then the cursor position within.  Make the
      parameter explicit then, by defining a new `vc_cell_height' struct
      member of `vc_data', set it instead of `vc_font.height' from `v_clin' in
      the VT_RESIZEX ioctl, and then use it throughout the `vgacon' driver
      except where actual font data is accessed which as noted above is
      independent from the CRTC setting.
      
      This way the framebuffer console driver is free to ignore the `v_clin'
      parameter as irrelevant, as it always should have, avoiding any issues
      attempts to give the parameter a meaning there could have caused, such
      as one that has led to commit 988d0763 ("vt_ioctl: make VT_RESIZEX
      behave like VT_RESIZE"):
      
       "syzbot is reporting UAF/OOB read at bit_putcs()/soft_cursor() [1][2],
        for vt_resizex() from ioctl(VT_RESIZEX) allows setting font height
        larger than actual font height calculated by con_font_set() from
        ioctl(PIO_FONT). Since fbcon_set_font() from con_font_set() allocates
        minimal amount of memory based on actual font height calculated by
        con_font_set(), use of vt_resizex() can cause UAF/OOB read for font
        data."
      
      The problem first appeared around Linux 2.5.66 which predates our repo
      history, but the origin could be identified with the old MIPS/Linux repo
      also at: <git://git.kernel.org/pub/scm/linux/kernel/git/ralf/linux.git>
      as commit 9736a3546de7 ("Merge with Linux 2.5.66."), where VT_RESIZEX
      code in `vt_ioctl' was updated as follows:
      
       		if (clin)
      -			video_font_height = clin;
      +			vc->vc_font.height = clin;
      
      making the parameter apply to framebuffer devices as well, perhaps due
      to the use of "font" in the name of the original `video_font_height'
      variable.  Use "cell" in the new struct member then to avoid ambiguity.
      
      References:
      
      [1] https://syzkaller.appspot.com/bug?id=32577e96d88447ded2d3b76d71254fb855245837
      [2] https://syzkaller.appspot.com/bug?id=6b8355d27b2b94fb5cedf4655e3a59162d9e48e3Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Cc: stable@vger.kernel.org # v2.6.12+
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      860dafa9
    • Maciej W. Rozycki's avatar
      vt_ioctl: Revert VT_RESIZEX parameter handling removal · a90c275e
      Maciej W. Rozycki authored
      Revert the removal of code handling extra VT_RESIZEX ioctl's parameters
      beyond those that VT_RESIZE supports, fixing a functional regression
      causing `svgatextmode' not to resize the VT anymore.
      
      As a consequence of the reverted change when the video adapter is
      reprogrammed from the original say 80x25 text mode using a 9x16
      character cell (720x400 pixel resolution) to say 80x37 text mode and the
      same character cell (720x592 pixel resolution), the VT geometry does not
      get updated and only upper two thirds of the screen are used for the VT,
      and the lower part remains blank.  The proportions change according to
      text mode geometries chosen.
      
      Revert the change verbatim then, bringing back previous VT resizing.
      Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Fixes: 988d0763 ("vt_ioctl: make VT_RESIZEX behave like VT_RESIZE")
      Cc: stable@vger.kernel.org # v5.10+
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a90c275e
    • Maciej W. Rozycki's avatar
      vgacon: Record video mode changes with VT_RESIZEX · d4d0ad57
      Maciej W. Rozycki authored
      Fix an issue with VGA console font size changes made after the initial
      video text mode has been changed with a user tool like `svgatextmode'
      calling the VT_RESIZEX ioctl.  As it stands in that case the original
      screen geometry continues being used to validate further VT resizing.
      
      Consequently when the video adapter is firstly reprogrammed from the
      original say 80x25 text mode using a 9x16 character cell (720x400 pixel
      resolution) to say 80x37 text mode and the same character cell (720x592
      pixel resolution), and secondly the CRTC character cell updated to 9x8
      (by loading a suitable font with the KD_FONT_OP_SET request of the
      KDFONTOP ioctl), the VT geometry does not get further updated from 80x37
      and only upper half of the screen is used for the VT, with the lower
      half showing rubbish corresponding to whatever happens to be there in
      the video memory that maps to that part of the screen.  Of course the
      proportions change according to text mode geometries and font sizes
      chosen.
      
      Address the problem then, by updating the text mode geometry defaults
      rather than checking against them whenever the VT is resized via a user
      ioctl.
      Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Fixes: e400b6ec ("vt/vgacon: Check if screen resize request comes from userspace")
      Cc: stable@vger.kernel.org # v2.6.24+
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d4d0ad57
  2. 25 Apr, 2021 6 commits
  3. 24 Apr, 2021 3 commits
  4. 23 Apr, 2021 17 commits
  5. 22 Apr, 2021 8 commits
  6. 21 Apr, 2021 3 commits