]> git.baikalelectronics.ru Git - kernel.git/commit
drm/fb-helper: Fix out-of-bounds access
authorThomas Zimmermann <tzimmermann@suse.de>
Tue, 21 Jun 2022 10:46:17 +0000 (12:46 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Mon, 27 Jun 2022 09:10:43 +0000 (11:10 +0200)
commit3f80218721f7371543876d5c26c2a55de282466a
tree61368795e886d34ff2e156e808ec211f2b68f6f8
parentd9dc7d2ddf9a8d114299bfd743eb786795a66741
drm/fb-helper: Fix out-of-bounds access

Clip memory range to screen-buffer size to avoid out-of-bounds access
in fbdev deferred I/O's damage handling.

Fbdev's deferred I/O can only track pages. From the range of pages, the
damage handler computes the clipping rectangle for the display update.
If the fbdev screen buffer ends near the beginning of a page, that page
could contain more scanlines. The damage handler would then track these
non-existing scanlines as dirty and provoke an out-of-bounds access
during the screen update. Hence, clip the maximum memory range to the
size of the screen buffer.

While at it, rename the variables min/max to min_off/max_off in
drm_fb_helper_deferred_io(). This avoids confusion with the macros of
the same name.

Reported-by: Nuno Gonçalves <nunojpg@gmail.com>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Tested-by: Nuno Gonçalves <nunojpg@gmail.com>
Fixes: 0252090bb2a7 ("drm/fb-helper: Calculate damaged area in separate helper")
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Javier Martinez Canillas <javierm@redhat.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: <stable@vger.kernel.org> # v5.18+
Link: https://patchwork.freedesktop.org/patch/msgid/20220621104617.8817-1-tzimmermann@suse.de
drivers/gpu/drm/drm_fb_helper.c