dumbbell f4f3c54f4e MFC r258549 and r258553:
drm: Dereference pointers given to qsort_r()'s cmp callback

drm_le_cmp() (qsort_r()'s callback) receives pointers to elements in the
array passed to qsort_r(), not the elements themselves.

Before this fix, the use of qsort_r() shuffled the array, not sorted it,
because the compare callback accessed random memory locations, not the
expected elements.

This bug triggered an infinite loop in KDE/xserver:

    1. KDE has a kded module called "randrmonitor" which queries xserver
       for current monitors at startup and then listens to RandR
       notifications from xserver.

    2. xserver handles the query from "randrmonitor" by polling the
       video device using the "drm_mode_getconnector()" ioctl. This
       ioctl returns a list of connectors and, for those with a
       connected monitor, the available modes. Each modes list is sorted
       by the kernel before returning. When xserver gets the connectors
       list, it sorts the modes lists again.

       In the case of this bug, when two modes are equal (in xserver's
       compare function PoV), their order is kept stable (ie. the
       kernel order is kept for those two modes). And because the list
       was shuffled by the kernel, the order of two equal modes was
       frequently changed in the final modes list in xserver.

    3. xserver compares the returned connectors list with the list
       obtained earlier. In particular, it compares the sorted
       modes lists for each connector. If a property of a connector
       changes (eg. modes), xserver sends a "RRNotify_OutputChange"
       notification.

       Because of the change of order between equal modes, xserver sent
       a notification after each polling of the connectors.

    4. "randrmonitor" receives a notification, triggered by its query. The
       notification doesn't contain the new connectors list, therefore, it
       asks for the new list using the same function: go back to step #2.

Approved by:	re (kib)
2013-11-28 10:04:53 +00:00
..
2013-10-10 19:48:43 +00:00
2013-11-01 21:15:39 +00:00
2013-10-24 10:33:31 +00:00
2013-11-25 20:47:37 +00:00
2013-10-21 06:31:56 +00:00
2013-11-26 08:46:39 +00:00
2013-11-28 10:04:53 +00:00
2013-10-25 16:33:24 +00:00
2013-11-23 23:54:38 +00:00
2013-11-22 19:27:17 +00:00
2013-09-29 15:19:34 +00:00
2013-11-01 21:17:45 +00:00
2013-10-21 01:15:05 +00:00
2013-11-11 09:47:51 +00:00
2013-11-21 23:00:09 +00:00
2013-11-21 23:00:09 +00:00
2013-11-14 09:19:50 +00:00
2013-11-17 22:24:34 +00:00
2013-11-04 05:58:59 +00:00
2013-10-28 23:47:52 +00:00
2013-11-12 08:01:58 +00:00
2013-10-18 17:08:23 +00:00