Re: [PATCH 18/39] fbdev: defio: assert FBINFO_VIRTFB, drop VM_IO, add VM_MIXEDMAP
From: sashiko-bot@kernel.org
Date: 2026-09-08 20:39:54
Also in:
bpf, dri-devel, kvm, kvmarm, linux-perf-users, linux-s390, linux-scsi, selinux
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: Pre-existing issues: - [High] Unchecked return value of fb_deferred_io_init() in ssd1307fb_probe() leads to a NULL pointer dereference in fb_deferred_io_mmap(). -- commit 20b4c9f03621ce152d836b82e0b4d3c3cda114ce Author: Lorenzo Stoakes (ARM) [off-list ref] fbdev: defio: assert FBINFO_VIRTFB, drop VM_IO, add VM_MIXEDMAP This commit updates defio drivers to assert the FBINFO_VIRTFB flag, drops the VM_IO flag, and sets VM_MIXEDMAP since kernel-allocated memory is mapped. It also ensures the ssd1307fb driver sets FBINFO_VIRTFB during its probe.
quoted hunk ↗ jump to hunk
diff --git a/drivers/video/fbdev/core/fb_defio.c b/drivers/video/fbdev/core/fb_defio.c index fd00b86e1ae60..fb359ecc39661 100644 --- a/drivers/video/fbdev/core/fb_defio.c +++ b/drivers/video/fbdev/core/fb_defio.c@@ -366,13 +366,13 @@ int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma) { vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot); + if (WARN_ON_ONCE(!(info->flags & FBINFO_VIRTFB))) + return -EINVAL; if (!try_module_get(THIS_MODULE)) return -EINVAL; vma->vm_ops = &fb_deferred_io_vm_ops; - vm_flags_set(vma, VM_DONTEXPAND | VM_DONTDUMP); - if (!(info->flags & FBINFO_VIRTFB)) - vm_flags_set(vma, VM_IO); + vm_flags_set(vma, VM_MIXEDMAP | VM_DONTEXPAND | VM_DONTDUMP); vma->vm_private_data = info->fbdefio_state; fb_deferred_io_state_get(info->fbdefio_state); /* released in vma->vm_ops->close() */
[Severity: High] This isn't a bug introduced by this patch, but could this lead to a NULL pointer dereference if fb_deferred_io_init() previously failed? If memory allocation fails during fb_deferred_io_init() in the driver probe, it returns an error code and leaves info->fbdefio_state as NULL. When a userspace program maps the framebuffer, fb_deferred_io_mmap() unconditionally passes the NULL info->fbdefio_state to fb_deferred_io_state_get(), which will subsequently dereference it via kref_get(). [ ... ]
quoted hunk ↗ jump to hunk
diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c index c4fdecafd8560..958514a354338 100644 --- a/drivers/video/fbdev/ssd1307fb.c +++ b/drivers/video/fbdev/ssd1307fb.c@@ -763,6 +763,8 @@ static int ssd1307fb_probe(struct i2c_client *client) info->fix.smem_start = __pa(vmem); info->fix.smem_len = vmem_size; + info->flags = FBINFO_VIRTFB; + fb_deferred_io_init(info);
[Severity: High] This is a pre-existing issue, but the return value of fb_deferred_io_init() is ignored here in ssd1307fb_probe(). Should we check the return value of fb_deferred_io_init() and handle the potential allocation failure so we don't proceed with a NULL info->fbdefio_state? -- Sashiko AI review · https://sashiko.dev/#/patchset/20260908-b4-mmap-prepare-vma-flag-sanify-v1-0-dacf19cce22b@kernel.org?part=18