fbdev: Make fb_release() return -ENODEV if fbdev was unregistered
Subsystems (2)
PATCH v2 1/1 fbdev: Make fb_release() return -ENODEV if fbdev was unregistered
A reference to the framebuffer device struct fb_info is stored in the file private data, but this reference could no longer be valid and must not be accessed directly. Instead, the file_fb_info() accessor function must be used since it does sanity checking to make sure that the fb_info is valid.
This can happen for example if the registered framebuffer device is for a driver that just uses a framebuffer provided by the system firmware. In that case, the fbdev core would unregister the framebuffer device when a real video driver is probed and ask to remove conflicting framebuffers.
The bug has been present for a long time but commit 27599aacbaef ("fbdev:
Hot-unplug firmware fb devices on forced removal") unmasked it since the fbdev core started unregistering the framebuffers' devices associated.
---
Changes in v2:
- Drop patch 1/2 since patch 2/2 should be enough to fix the issue.
- Add missing Fixes and Reported-by tags (Thomas Zimmermann).
- Add Thomas Zimmermann's Reviewed-by tag.
drivers/video/fbdev/core/fbmem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/video/fbdev/core/fbmem.c +4 -1
@@ -1434,7 +1434,10 @@ fb_release(struct inode *inode, struct file *file) __acquires(&info->lock) __releases(&info->lock) { -struct fb_info *const info = file->private_data; +struct fb_info *const info =file_fb_info (file); + +if (!info) +return -ENODEV ;lock_fb_info (info);if (info->fbops->fb_release)
Signature · 1 line
2.35.1
Javier Martinez Canillas
AppliedQuoted 14 lines · Javier Martinez Canillas
A reference to the framebuffer device struct
fb_infois stored in the file private data, but this reference could no longer be valid and must not be accessed directly. Instead, thefile_fb_info()accessor function must be used since it does sanity checking to make sure that thefb_infois valid.This can happen for example if the registered framebuffer device is for a driver that just uses a framebuffer provided by the system firmware. In that case, the fbdev core would unregister the framebuffer device when a real video driver is probed and ask to remove conflicting framebuffers.
The bug has been present for a long time but commit
27599aacbaef("fbdev:
Hot-unplug firmware fb devices on forced removal") unmasked it since the fbdev core started unregistering the framebuffers' devices associated.
Quoted 6 lines
Fixes 27599aacbaef ("fbdev: Hot-unplug firmware fb devices on forced removal")Reported-by Maxime Ripard <[email protected]>Reported-by Junxiao Chang <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>Reviewed-by Thomas Zimmermann <[email protected]>---
Applied to drm-misc (drm-misc-fixes).
Signature · 5 lines
Best regards, Javier Martinez Canillas Linux Engineering Red Hat
Quoted 15 lines · Javier Martinez Canillas
Quoted 14 lines · Javier Martinez Canillas
A reference to the framebuffer device struct
fb_infois stored in the file private data, but this reference could no longer be valid and must not be accessed directly. Instead, thefile_fb_info()accessor function must be used since it does sanity checking to make sure that thefb_infois valid.This can happen for example if the registered framebuffer device is for a driver that just uses a framebuffer provided by the system firmware. In that case, the fbdev core would unregister the framebuffer device when a real video driver is probed and ask to remove conflicting framebuffers.
The bug has been present for a long time but commit
27599aacbaef("fbdev:
Hot-unplug firmware fb devices on forced removal") unmasked it since the fbdev core started unregistering the framebuffers' devices associated.
Quoted 7 lines
Quoted 6 lines
Fixes 27599aacbaef ("fbdev: Hot-unplug firmware fb devices on forced removal")Reported-by Maxime Ripard <[email protected]>Reported-by Junxiao Chang <[email protected]>Signed-off-by Javier Martinez Canillas <[email protected]>Reviewed-by Thomas Zimmermann <[email protected]>---
Applied to drm-misc (drm-misc-fixes).
See my other reply, but how does this not result in leaks? -Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch