Skip to content
Snippets Groups Projects
  1. Dec 21, 2022
  2. Dec 20, 2022
    • Olivier Fourdan's avatar
      modesetting: Log whether atomic modesetting is enabled · 6ac3178c
      Olivier Fourdan authored
      
      If atomic modesetting is to be enabled in the configuration file, log
      whether this is supported and eventually enabled or disabled.
      
      Signed-off-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
      Reviewed-by: default avatarMartin Roukala <martin.roukala@mupuf.org>
      6ac3178c
    • Olivier Fourdan's avatar
      modesetting: Document the "Atomic" option · c066a46a
      Olivier Fourdan authored
      
      The modesetting driver has atomic modesetting disabled by default but
      can be enabled (if supported) using a configuration option.
      
      Add this option in the man page.
      
      Signed-off-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
      Reviewed-by: default avatarMartin Roukala <martin.roukala@mupuf.org>
      c066a46a
    • Sultan Alsawaf's avatar
      modesetting: add support for TearFree page flips · a94dd953
      Sultan Alsawaf authored
      
      This adds support for TearFree page flips to eliminate tearing without the
      use of a compositor. It allocates two shadow buffers for each CRTC, a back
      buffer and a front buffer, and uses damage tracking to minimize excessive
      copying between buffers and skip unnecessary flips when the screen's
      contents remain unchanged. It works on transformed screens too, such as
      rotated and scaled CRTCs.
      
      When PageFlip is enabled, TearFree won't force fullscreen DRI clients to
      synchronize their page flips to the vblank interval.
      
      TearFree is disabled by default.
      
      Signed-off-by: default avatarSultan Alsawaf <sultan@kerneltoast.com>
      a94dd953
    • Sultan Alsawaf's avatar
      modesetting: coalesce vblank events to avoid DRM event queue exhaustion · 2d272b70
      Sultan Alsawaf authored
      
      The DRM event queue in the kernel is quite small and can be easily
      exhausted by DRI clients. When the event queue is full, that means nothing
      can be queued onto it anymore, which can lead to incorrect presentation
      times for DRI clients and failure when attempting to queue a page flip.
      
      To make matters worse, once an event is placed onto the kernel's event
      queue, there's no straightforward way to prematurely remove it from the
      kernel's event queue in userspace, which means that aborting a sequence
      number doesn't free up space in the event queue.
      
      Since vblank events from DRI clients are the largest consumers of the
      event queue, and since it's often easy to know the desired target MSC of
      their vblank events without querying the kernel for a CRTC's current MSC,
      we can coalesce vblank events occurring at the same MSC such that only one
      of them is placed onto the kernel's event queue, instead of allowing
      duplicate vblank events to pollute the event queue.
      
      This is achieved by tracking the next kernel-queued event's MSC on a
      per-CRTC basis and then running all of that CRTC's vblank event handlers
      which have reached their target MSC when the queued MSC is signaled.
      
      Signed-off-by: default avatarSultan Alsawaf <sultan@kerneltoast.com>
      2d272b70
    • Sultan Alsawaf's avatar
      present: add awareness for drivers with TearFree · 9108a2bf
      Sultan Alsawaf authored
      
      When a driver uses TearFree to flip all frames synchronized to the vblank
      interval, Present has no idea and still assumes that each presentation
      occurs immediately upon copying its damages to the primary scanout. This
      faulty assumption breaks presentation timestamping, potentially leading to
      A/V de-synchronization and dropped frames.
      
      Present needs to have some awareness of a driver using TearFree so that it
      can know when each presentation actually becomes visible on the screen.
      
      Teach Present about drivers using TearFree by expanding PresentFlipReason
      to allow drivers to export some contextual info about TearFree when Present
      cannot page-flip directly anyway.
      
      PRESENT_FLIP_REASON_DRIVER_TEARFREE indicates that a driver has TearFree
      enabled but doesn't have a TearFree flip currently pending.
      
      PRESENT_FLIP_REASON_DRIVER_TEARFREE_FLIPPING indicates that a driver has a
      TearFree flip currently pending.
      
      Signed-off-by: default avatarSultan Alsawaf <sultan@kerneltoast.com>
      9108a2bf
    • Sultan Alsawaf's avatar
      modesetting: make do_queue_flip_on_crtc generic · 5f5690b8
      Sultan Alsawaf authored
      
      do_queue_flip_on_crtc() is about to be used to flip buffers other than the
      primary scanout (`ms->drmmode.fb_id`), so make it generic to accept any
      frame buffer ID, as well as x and y coordinates in the frame buffer, to
      flip on a given CRTC. Move the retry logic from queue_flip_on_crtc() into
      it as well, so that it's robust for all callers.
      
      Signed-off-by: default avatarSultan Alsawaf <sultan@kerneltoast.com>
      5f5690b8
    • Sultan Alsawaf's avatar
      modesetting: make the shadow buffer helpers generic · 80d0035e
      Sultan Alsawaf authored
      
      Shadow buffers are about to be used for TearFree, so make the shadow buffer
      helpers generic such that they can be used to create arbitrary per-CRTC
      shadows aside from just the per-CRTC rotated buffer.
      
      Signed-off-by: default avatarSultan Alsawaf <sultan@kerneltoast.com>
      80d0035e
    • Sultan Alsawaf's avatar
      xfree86: make xf86RotateCrtcRedisplay public · 07ad7a11
      Sultan Alsawaf authored
      
      xf86RotateCrtcRedisplay() is about to be used outside of xf86Rotate.c in
      order to copy transformed pixmaps, so fix up its interface by specifying
      the source drawable and destination pixmap rather than assuming the root
      drawable and rotated pixmap, respectively. In addition, add an argument to
      make xf86RotateCrtcRedisplay() not perform any transformations, which is an
      indicator that it should only copy a transformed pixmap rather than
      actually transform a pixmap.
      
      These changes make it possible to use xf86RotateCrtcRedisplay() to not
      only copy transformed pixmaps, but also actually transform pixmaps, making
      it very useful outside of xf86Rotate.c.
      
      Signed-off-by: default avatarSultan Alsawaf <sultan@kerneltoast.com>
      07ad7a11
    • Sultan Alsawaf's avatar
      pixmap: make PixmapDirtyCopyArea public · 08183c66
      Sultan Alsawaf authored
      
      PixmapDirtyCopyArea() is about to be used outside of pixmap.c, so fix up
      its interface by specifying the dirty area directly rather than passing a
      `PixmapDirtyUpdatePtr`. This makes it easier to use outside of pixmap.c, as
      the caller doesn't need to create a bulky PixmapDirtyUpdateRec to use this
      function.
      
      Signed-off-by: default avatarSultan Alsawaf <sultan@kerneltoast.com>
      08183c66
  3. Dec 19, 2022
  4. Dec 14, 2022
    • Jeremy Huddleston Sequoia's avatar
    • John D Pell's avatar
    • Peter Hutterer's avatar
      xkb: reset the radio_groups pointer to NULL after freeing it · ccdd431c
      Peter Hutterer authored
      
      Unlike other elements of the keymap, this pointer was freed but not
      reset. On a subsequent XkbGetKbdByName request, the server may access
      already freed memory.
      
      CVE-2022-4283, ZDI-CAN-19530
      
      This vulnerability was discovered by:
      Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
      
      Signed-off-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
      Acked-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
      ccdd431c
    • Peter Hutterer's avatar
      Xi: avoid integer truncation in length check of ProcXIChangeProperty · 8f454b79
      Peter Hutterer authored
      
      This fixes an OOB read and the resulting information disclosure.
      
      Length calculation for the request was clipped to a 32-bit integer. With
      the correct stuff->num_items value the expected request size was
      truncated, passing the REQUEST_FIXED_SIZE check.
      
      The server then proceeded with reading at least stuff->num_items bytes
      (depending on stuff->format) from the request and stuffing whatever it
      finds into the property. In the process it would also allocate at least
      stuff->num_items bytes, i.e. 4GB.
      
      The same bug exists in ProcChangeProperty and ProcXChangeDeviceProperty,
      so let's fix that too.
      
      CVE-2022-46344, ZDI-CAN 19405
      
      This vulnerability was discovered by:
      Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
      
      Signed-off-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
      Acked-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
      8f454b79
    • Peter Hutterer's avatar
      Xi: return an error from XI property changes if verification failed · b8a84cb0
      Peter Hutterer authored
      
      Both ProcXChangeDeviceProperty and ProcXIChangeProperty checked the
      property for validity but didn't actually return the potential error.
      
      Signed-off-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
      Acked-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
      b8a84cb0
    • Peter Hutterer's avatar
      Xext: free the screen saver resource when replacing it · 842ca3cc
      Peter Hutterer authored
      
      This fixes a use-after-free bug:
      
      When a client first calls ScreenSaverSetAttributes(), a struct
      ScreenSaverAttrRec is allocated and added to the client's
      resources.
      
      When the same client calls ScreenSaverSetAttributes() again, a new
      struct ScreenSaverAttrRec is allocated, replacing the old struct. The
      old struct was freed but not removed from the clients resources.
      
      Later, when the client is destroyed the resource system invokes
      ScreenSaverFreeAttr and attempts to clean up the already freed struct.
      
      Fix this by letting the resource system free the old attrs instead.
      
      CVE-2022-46343, ZDI-CAN 19404
      
      This vulnerability was discovered by:
      Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
      
      Signed-off-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
      Acked-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
      842ca3cc
    • Peter Hutterer's avatar
      Xext: free the XvRTVideoNotify when turning off from the same client · b79f32b5
      Peter Hutterer authored
      
      This fixes a use-after-free bug:
      
      When a client first calls XvdiSelectVideoNotify() on a drawable with a
      TRUE onoff argument, a struct XvVideoNotifyRec is allocated. This struct
      is added twice to the resources:
        - as the drawable's XvRTVideoNotifyList. This happens only once per
          drawable, subsequent calls append to this list.
        - as the client's XvRTVideoNotify. This happens for every client.
      
      The struct keeps the ClientPtr around once it has been added for a
      client. The idea, presumably, is that if the client disconnects we can remove
      all structs from the drawable's list that match the client (by resetting
      the ClientPtr to NULL), but if the drawable is destroyed we can remove
      and free the whole list.
      
      However, if the same client then calls XvdiSelectVideoNotify() on the
      same drawable with a FALSE onoff argument, only the ClientPtr on the
      existing struct was set to NULL. The struct itself remained in the
      client's resources.
      
      If the drawable is now destroyed, the resource system invokes
      XvdiDestroyVideoNotifyList which frees the whole list for this drawable
      - including our struct. This function however does not free the resource
      for the client since our ClientPtr is NULL.
      
      Later, when the client is destroyed and the resource system invokes
      XvdiDestroyVideoNotify, we unconditionally set the ClientPtr to NULL. On
      a struct that has been freed previously. This is generally frowned upon.
      
      Fix this by calling FreeResource() on the second call instead of merely
      setting the ClientPtr to NULL. This removes the struct from the client
      resources (but not from the list), ensuring that it won't be accessed
      again when the client quits.
      
      Note that the assignment tpn->client = NULL; is superfluous since the
      XvdiDestroyVideoNotify function will do this anyway. But it's left for
      clarity and to match a similar invocation in XvdiSelectPortNotify.
      
      CVE-2022-46342, ZDI-CAN 19400
      
      This vulnerability was discovered by:
      Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
      
      Signed-off-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
      Acked-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
      b79f32b5
    • Peter Hutterer's avatar
      Xi: disallow passive grabs with a detail > 255 · 51eb63b0
      Peter Hutterer authored
      
      The XKB protocol effectively prevents us from ever using keycodes above
      255. For buttons it's theoretically possible but realistically too niche
      to worry about. For all other passive grabs, the detail must be zero
      anyway.
      
      This fixes an OOB write:
      
      ProcXIPassiveUngrabDevice() calls DeletePassiveGrabFromList with a
      temporary grab struct which contains tempGrab->detail.exact = stuff->detail.
      For matching existing grabs, DeleteDetailFromMask is called with the
      stuff->detail value. This function creates a new mask with the one bit
      representing stuff->detail cleared.
      
      However, the array size for the new mask is 8 * sizeof(CARD32) bits,
      thus any detail above 255 results in an OOB array write.
      
      CVE-2022-46341, ZDI-CAN 19381
      
      This vulnerability was discovered by:
      Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
      
      Signed-off-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
      Acked-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
      51eb63b0
  5. Dec 12, 2022
    • Peter Hutterer's avatar
      Xtest: disallow GenericEvents in XTestSwapFakeInput · b320ca0f
      Peter Hutterer authored
      
      XTestSwapFakeInput assumes all events in this request are
      sizeof(xEvent) and iterates through these in 32-byte increments.
      However, a GenericEvent may be of arbitrary length longer than 32 bytes,
      so any GenericEvent in this list would result in subsequent events to be
      misparsed.
      
      Additional, the swapped event is written into a stack-allocated struct
      xEvent (size 32 bytes). For any GenericEvent longer than 32 bytes,
      swapping the event may thus smash the stack like an avocado on toast.
      
      Catch this case early and return BadValue for any GenericEvent.
      Which is what would happen in unswapped setups anyway since XTest
      doesn't support GenericEvent.
      
      CVE-2022-46340, ZDI-CAN 19265
      
      This vulnerability was discovered by:
      Jan-Niklas Sohn working with Trend Micro Zero Day Initiative
      
      Signed-off-by: default avatarPeter Hutterer <peter.hutterer@who-t.net>
      Acked-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
      b320ca0f
  6. Dec 09, 2022
    • Doğukan Korkmaztürk's avatar
      GLX: Free the tag of the old context later · 4781f2a5
      Doğukan Korkmaztürk authored and Olivier Fourdan's avatar Olivier Fourdan committed
      
      In CommonMakeCurrent() function, the tag of the old context is freed
      before the new context is made current. This is problematic because if
      the CommonMakeNewCurrent() function fails, the tag of the old context
      ends up being removed, even though it is still active. This causes
      subsequent glXMakeCurrent() or glXMakeContextCurrent() requests to
      generate a GLXBadContextTag error.
      
      This change moves the function call that frees the old tag to a location
      where the result of CommonMakeNewCurrent() call is known and it is safe
      to free it.
      
      Signed-off-by: Doğukan Korkmaztürk's avatarDoğukan Korkmaztürk <dkorkmazturk@nvidia.com>
      4781f2a5
  7. Dec 06, 2022
  8. Dec 01, 2022
  9. Nov 30, 2022
  10. Nov 28, 2022
  11. Nov 27, 2022
  12. Nov 24, 2022
  13. Nov 16, 2022
    • Shashank Sharma's avatar
      xf86: allow DDX driver for GPU/PCI hot-plug · 82bf391c
      Shashank Sharma authored and Shashank Sharma's avatar Shashank Sharma committed
      
      The current X server infrastructure sets modesetting driver as default driver
      to handle PCI-hotplug of a GPU device. This prevents the respective DDX driver
      (like AMDGPU DDX driver) to take control of the card.
      
      This patch:
      - Adds a few functions and fine-tunes the GPU hotplug infrastructure to allow
        the DDX driver to be loaded, if it is configured in the X config file
        options as "hotplug-driver".
      - Scans and updates the PCI device list before adding the new GPU device
        in platform, so that the association of the platform device and PCI device
        is in place (dev->pdev).
      - Adds documentation of this new option
      
      An example usage in the config file would look like:
      
      Section "OutputClass"
              Identifier "AMDgpu"
              MatchDriver "amdgpu"
              Driver "amdgpu"
      	HotplugDriver "amdgpu"
      EndSection
      
      V2:
      Fixed typo in commit message (Martin)
      Added R-B from Adam.
      Added ACK from Alex and Martin.
      
      V3:
      Added an output class based approach for finding the DDX driver (Aaron)
      Rebase
      
      V4:
      Addressed review comment from Aaron:
      GPU hot-plug handling driver's name to be read from the DDX config file options.
      In this way only the DDX drivers interested in handling GPU hot-plug will be
      picked and loaded, for others modesetting driver will be used as usual.
      
      V5:
      Addressed review comments from Aaron:
      - X config option to be listed in CamelCase.
      - Indentation fix at one place.
      - Code readability related optimization.
      
      V6:
      Addressed review comments from Aaron:
      - Squash the doc in the same patch
      - Doc formatting changes
      
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Suggested-by: Aaron Plattner aplattner@nvidia.com (v3)
      Acked-by: default avatarMartin Roukala <martin.roukala@mupuf.org(v1)>
      Acked-by: Alex Deucher alexander.deucher@amd.com (v1)
      Reviewed-by: default avatarAdam Jackson <ajax@redhat.com(v1)>
      Signed-off-by: default avatarShashank Sharma <shashank.sharma@amd.com>
      82bf391c
  14. Nov 05, 2022
    • pkubaj's avatar
      Fix build on FreeBSD/powerpc* · 8c54d590
      pkubaj authored and Alan Coopersmith's avatar Alan Coopersmith committed
      Current error:
      ld: error: undefined symbol: xf86EnableIO
      >>> referenced by xf86Configure.c
      >>>               libxorg_common.a.p/xf86Configure.c.o:(DoConfigure) in archive hw/xfree86/common/libxorg_common.a
      >>> referenced by xf86Events.c
      >>>               libxorg_common.a.p/xf86Events.c.o:(xf86VTEnter) in archive hw/xfree86/common/libxorg_common.a
      >>> referenced by xf86Init.c
      >>>               libxorg_common.a.p/xf86Init.c.o:(InitOutput) in archive hw/xfree86/common/libxorg_common.a
      >>> referenced 1 more times
      8c54d590
Loading