linux/drivers/video/fbdev/core
Nam Cao 78d9161d2b fbdev: fix incorrect address computation in deferred IO
With deferred IO enabled, a page fault happens when data is written to the
framebuffer device. Then driver determines which page is being updated by
calculating the offset of the written virtual address within the virtual
memory area, and uses this offset to get the updated page within the
internal buffer. This page is later copied to hardware (thus the name
"deferred IO").

This offset calculation is only correct if the virtual memory area is
mapped to the beginning of the internal buffer. Otherwise this is wrong.
For example, if users do:
    mmap(ptr, 4096, PROT_WRITE, MAP_FIXED | MAP_SHARED, fd, 0xff000);

Then the virtual memory area will mapped at offset 0xff000 within the
internal buffer. This offset 0xff000 is not accounted for, and wrong page
is updated.

Correct the calculation by using vmf->pgoff instead. With this change, the
variable "offset" will no longer hold the exact offset value, but it is
rounded down to multiples of PAGE_SIZE. But this is still correct, because
this variable is only used to calculate the page offset.

Reported-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Closes: https://lore.kernel.org/linux-fbdev/271372d6-e665-4e7f-b088-dee5f4ab341a@oracle.com
Fixes: 56c134f7f1 ("fbdev: Track deferred-I/O pages in pageref struct")
Cc: <stable@vger.kernel.org>
Signed-off-by: Nam Cao <namcao@linutronix.de>
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Tested-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20240423115053.4490-1-namcao@linutronix.de
2024-04-24 15:03:37 +02:00
..
bitblit.c tty: vt: remove CM_* constants 2024-01-27 18:08:54 -08:00
cfbcopyarea.c fbdev: Warn on incorrect framebuffer access 2023-11-29 12:20:50 +01:00
cfbfillrect.c fbdev: Warn on incorrect framebuffer access 2023-11-29 12:20:50 +01:00
cfbimgblt.c fbdev: Warn on incorrect framebuffer access 2023-11-29 12:20:50 +01:00
fb_backlight.c fbdev/core: Move framebuffer and backlight helpers into separate files 2023-06-27 09:58:51 +02:00
fb_chrdev.c fbdev: Remove default file-I/O implementations 2023-11-29 12:20:53 +01:00
fb_cmdline.c fbdev: Handle video= parameter in video/cmdline.c 2023-02-20 14:56:48 +01:00
fb_ddc.c fbdev: remove I2C_CLASS_DDC support 2024-01-18 21:10:41 +01:00
fb_defio.c fbdev: fix incorrect address computation in deferred IO 2024-04-24 15:03:37 +02:00
fb_draw.h
fb_info.c fbdev: Document that framebuffer_alloc() returns zero'ed data 2023-07-24 16:50:39 +02:00
fb_internal.h fbdev/core: Move logo functions into separate source file 2023-09-11 15:12:35 +02:00
fb_io_fops.c fbdev: Warn on incorrect framebuffer access 2023-11-29 12:20:50 +01:00
fb_logo.c fbdev/core: Remove empty internal helpers from fb_logo.c 2023-09-11 15:12:37 +02:00
fb_notify.c
fb_procfs.c fbdev/core: Move procfs code to separate file 2023-06-27 09:58:51 +02:00
fb_sys_fops.c fbdev: Warn on incorrect framebuffer access 2023-11-29 12:20:50 +01:00
fbcmap.c
fbcon_ccw.c tty: vt: remove CM_* constants 2024-01-27 18:08:54 -08:00
fbcon_cw.c tty: vt: remove CM_* constants 2024-01-27 18:08:54 -08:00
fbcon_rotate.c
fbcon_rotate.h
fbcon_ud.c tty: vt: remove CM_* constants 2024-01-27 18:08:54 -08:00
fbcon.c fbdev fixes and cleanups for 6.9-rc1: 2024-03-22 10:09:08 -07:00
fbcon.h tty: vt: remove CM_* constants 2024-01-27 18:08:54 -08:00
fbcvt.c
fbmem.c fbdev fixes and cleanups for 6.9-rc1: 2024-03-22 10:09:08 -07:00
fbmon.c fbmon: prevent division by zero in fb_videomode_from_videomode() 2024-03-19 13:20:20 +01:00
fbsysfs.c fbdev/core: Use list_for_each_entry() helper 2023-08-31 22:54:34 +02:00
Kconfig video/cmdline: Introduce CONFIG_VIDEO for video= parameter 2024-01-23 10:11:22 +01:00
Makefile fbdev: Rename FB_SYS_FOPS token to FB_SYSMEM_FOPS 2023-11-29 12:20:42 +01:00
modedb.c fbdev/core: Use list_for_each_entry() helper 2023-08-31 22:54:34 +02:00
softcursor.c
svgalib.c fbcon: Increase maximum font width x height to 64 x 128 2024-03-16 08:29:48 +01:00
syscopyarea.c fbdev: Warn on incorrect framebuffer access 2023-11-29 12:20:50 +01:00
sysfillrect.c fbdev: Warn on incorrect framebuffer access 2023-11-29 12:20:50 +01:00
sysimgblt.c fbdev: Warn on incorrect framebuffer access 2023-11-29 12:20:50 +01:00
tileblit.c tty: vt: remove CM_* constants 2024-01-27 18:08:54 -08:00