Skip to content
Snippets Groups Projects
  1. Jan 11, 2022
  2. Sep 08, 2021
  3. Jul 19, 2021
  4. Jul 13, 2021
    • Zhen Lei's avatar
      fbmem: Do not delete the mode that is still in use · 0af77826
      Zhen Lei authored
      
      The execution of fb_delete_videomode() is not based on the result of the
      previous fbcon_mode_deleted(). As a result, the mode is directly deleted,
      regardless of whether it is still in use, which may cause UAF.
      
      ==================================================================
      BUG: KASAN: use-after-free in fb_mode_is_equal+0x36e/0x5e0 \
      drivers/video/fbdev/core/modedb.c:924
      Read of size 4 at addr ffff88807e0ddb1c by task syz-executor.0/18962
      
      CPU: 2 PID: 18962 Comm: syz-executor.0 Not tainted 5.10.45-rc1+ #3
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ...
      Call Trace:
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x137/0x1be lib/dump_stack.c:118
       print_address_description+0x6c/0x640 mm/kasan/report.c:385
       __kasan_report mm/kasan/report.c:545 [inline]
       kasan_report+0x13d/0x1e0 mm/kasan/report.c:562
       fb_mode_is_equal+0x36e/0x5e0 drivers/video/fbdev/core/modedb.c:924
       fbcon_mode_deleted+0x16a/0x220 drivers/video/fbdev/core/fbcon.c:2746
       fb_set_var+0x1e1/0xdb0 drivers/video/fbdev/core/fbmem.c:975
       do_fb_ioctl+0x4d9/0x6e0 drivers/video/fbdev/core/fbmem.c:1108
       vfs_ioctl fs/ioctl.c:48 [inline]
       __do_sys_ioctl fs/ioctl.c:753 [inline]
       __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:739
       do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Freed by task 18960:
       kasan_save_stack mm/kasan/common.c:48 [inline]
       kasan_set_track+0x3d/0x70 mm/kasan/common.c:56
       kasan_set_free_info+0x17/0x30 mm/kasan/generic.c:355
       __kasan_slab_free+0x108/0x140 mm/kasan/common.c:422
       slab_free_hook mm/slub.c:1541 [inline]
       slab_free_freelist_hook+0xd6/0x1a0 mm/slub.c:1574
       slab_free mm/slub.c:3139 [inline]
       kfree+0xca/0x3d0 mm/slub.c:4121
       fb_delete_videomode+0x56a/0x820 drivers/video/fbdev/core/modedb.c:1104
       fb_set_var+0x1f3/0xdb0 drivers/video/fbdev/core/fbmem.c:978
       do_fb_ioctl+0x4d9/0x6e0 drivers/video/fbdev/core/fbmem.c:1108
       vfs_ioctl fs/ioctl.c:48 [inline]
       __do_sys_ioctl fs/ioctl.c:753 [inline]
       __se_sys_ioctl+0xfb/0x170 fs/ioctl.c:739
       do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
       entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Fixes: 13ff178c ("fbcon: Call fbcon_mode_deleted/new_modelist directly")
      Signed-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
      Cc: <stable@vger.kernel.org> # v5.3+
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Link: https://patchwork.freedesktop.org/patch/msgid/20210712085544.2828-1-thunder.leizhen@huawei.com
      0af77826
  5. Jun 01, 2021
  6. May 09, 2021
    • Linus Torvalds's avatar
      fbmem: fix horribly incorrect placement of __maybe_unused · 6dae40ae
      Linus Torvalds authored
      
      Commit b9d79e4c ("fbmem: Mark proc_fb_seq_ops as __maybe_unused")
      places the '__maybe_unused' in an entirely incorrect location between
      the "struct" keyword and the structure name.
      
      It's a wonder that gcc accepts that silently, but clang quite reasonably
      warns about it:
      
          drivers/video/fbdev/core/fbmem.c:736:21: warning: attribute declaration must precede definition [-Wignored-attributes]
          static const struct __maybe_unused seq_operations proc_fb_seq_ops = {
                              ^
      
      Fix it.
      
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6dae40ae
  7. May 04, 2021
  8. Mar 12, 2021
  9. Nov 10, 2020
  10. Sep 25, 2020
  11. Sep 08, 2020
  12. Aug 23, 2020
  13. Aug 04, 2020
  14. Aug 03, 2020
  15. Jan 15, 2020
  16. Jan 03, 2020
  17. Dec 03, 2019
  18. Nov 19, 2019
  19. Oct 14, 2019
  20. Aug 23, 2019
  21. Aug 05, 2019
  22. Jul 23, 2019
  23. Jun 12, 2019
    • Daniel Vetter's avatar
      fbcon: Call con2fb_map functions directly · fe2d70d6
      Daniel Vetter authored
      
      These are actually fbcon ioctls which just happen to be exposed
      through /dev/fb*. They completely ignore which fb_info they're called
      on, and I think the userspace tool even hardcodes to /dev/fb0.
      
      Hence just forward the entire thing to fbcon.c wholesale.
      
      Note that this patch drops the fb_lock/unlock on the set side. Since
      the ioctl can operate on any fb (as passed in through
      con2fb.framebuffer) this is bogus. Also note that fbcon.c in general
      never calls fb_lock on anything, so this has been badly broken
      already.
      
      With this the last user of the fbcon notifier callback is gone, and we
      can garbage collect that too.
      
      v2: add missing uaccess.h include (alpha fails to compile otherwise),
      reported by kbuild.
      
      v3: Remember to also drop the #defines (Maarten)
      
      v4: Add the static inline to dummy functions.
      
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Yisheng Xie <ysxie@foxmail.com>
      Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: Mikulas Patocka <mpatocka@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190528090304.9388-31-daniel.vetter@ffwll.ch
      fe2d70d6
    • Daniel Vetter's avatar
      fbcon: replace FB_EVENT_MODE_CHANGE/_ALL with direct calls · 9e146700
      Daniel Vetter authored
      
      Create a new wrapper function for this, feels like there's some
      refactoring room here between the two modes.
      
      v2: backlight notifier is also interested in the mode change event,
      it calls lcd->set_mode, of which there are 3 implementations. Thanks
      to Maarten for spotting this. So we keep that. We can ditch the differentiation
      between mode change and all mode changes (because backlight notifier
      doesn't care), and we can drop the FBINFO_MISC_USEREVENT stuff too,
      because that's just to prevent recursion between fbmem.c and fbcon.c.
      
      While at it flatten the control flow a bit.
      
      v3: Need to add a static inline to the dummy function.
      
      v4: Add missing #include <fbcon.h> to sh_mob (Sam).
      
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Acked-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Lee Jones <lee.jones@linaro.org>
      Cc: Daniel Thompson <daniel.thompson@linaro.org>
      Cc: Jingoo Han <jingoohan1@gmail.com>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Yisheng Xie <ysxie@foxmail.com>
      Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: Mikulas Patocka <mpatocka@redhat.com>
      Cc: linux-fbdev@vger.kernel.org
      Link: https://patchwork.freedesktop.org/patch/msgid/20190528090304.9388-29-daniel.vetter@ffwll.ch
      9e146700
    • Daniel Vetter's avatar
      fb: Flatten control flow in fb_set_var · c428f35a
      Daniel Vetter authored
      
      Instead of wiring almost everything down to the very last line using
      goto soup (but not consistently, where would the fun be otherwise)
      drop out early when checks fail. This allows us to flatten the huge
      indent levels to just 1.
      
      Aside: If a driver doesn't set ->fb_check_var, then FB_ACTIVATE_NOW
      does nothing. This bug exists ever since this code was extracted as a
      common helper in 2002, hence I decided against fixing it. Everyone
      just better have a fb_check_var to make sure things work correctly.
      
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Mikulas Patocka <mpatocka@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190528090304.9388-28-daniel.vetter@ffwll.ch
      c428f35a
    • Daniel Vetter's avatar
      fbdev: remove FBINFO_MISC_USEREVENT around fb_blank · 36676173
      Daniel Vetter authored
      
      With the recursion broken in the previous patch we can drop the
      FBINFO_MISC_USEREVENT flag around calls to fb_blank - recursion
      prevention was it's only job.
      
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Yisheng Xie <ysxie@foxmail.com>
      Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: Mikulas Patocka <mpatocka@redhat.com>
      Cc: Rob Clark <robdclark@gmail.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190528090304.9388-27-daniel.vetter@ffwll.ch
      36676173
    • Daniel Vetter's avatar
      fbmem: pull fbcon_fb_blanked out of fb_blank · de29ae5c
      Daniel Vetter authored
      
      There's a callchain of:
      
      fbcon_fb_blanked -> do_(un)blank_screen -> consw->con_blank
      	-> fbcon_blank -> fb_blank
      
      Things don't go horribly wrong because the BKL console_lock safes the
      day, but that's about it. And the seeming recursion is broken in 2
      ways:
      - Starting from the fbdev ioctl we set FBINFO_MISC_USEREVENT, which
        tells the fbcon_blank code to not call fb_blank. This was required
        to not deadlock when recursing on the fb_notifier_chain mutex.
      - Starting from the con_blank hook we're getting saved by the
        console_blanked checks in do_blank/unblank_screen. Or at least
        that's my theory.
      
      Anyway, recursion isn't awesome, so let's stop it. Breaking the
      recursion avoids the need to be in the FBINFO_MISC_USEREVENT critical
      section, so lets move it out of that too.
      
      The astute reader will notice that fb_blank seems to require
      lock_fb_info(), which the fbcon code seems to ignore. I have no idea
      how to fix that problem, so let's keep ignoring it.
      
      v2: I forgot the sysfs blanking code.
      
      v3: Fix typo in callchain in the commmit message (Sam).
      
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Mikulas Patocka <mpatocka@redhat.com>
      Cc: Rob Clark <robdclark@gmail.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190528090304.9388-26-daniel.vetter@ffwll.ch
      de29ae5c
    • Daniel Vetter's avatar
      Revert "backlight/fbcon: Add FB_EVENT_CONBLANK" · 7a625549
      Daniel Vetter authored
      
      This reverts commit 994efacd.
      
      The justification is that if hw blanking fails (i.e. fbops->fb_blank)
      fails, then we still want to shut down the backlight. Which is exactly
      _not_ what fb_blank() does and so rather inconsistent if we end up
      with different behaviour between fbcon and direct fbdev usage. Given
      that the entire notifier maze is getting in the way anyway I figured
      it's simplest to revert this not well justified commit.
      
      v2: Add static inline to the dummy version.
      
      Cc: Richard Purdie <rpurdie@rpsys.net>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Acked-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
      Cc: Lee Jones <lee.jones@linaro.org>
      Cc: Daniel Thompson <daniel.thompson@linaro.org>
      Cc: Jingoo Han <jingoohan1@gmail.com>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Yisheng Xie <ysxie@foxmail.com>
      Cc: linux-fbdev@vger.kernel.org
      Link: https://patchwork.freedesktop.org/patch/msgid/20190528090304.9388-25-daniel.vetter@ffwll.ch
      7a625549
    • Daniel Vetter's avatar
      fbdev: Call fbcon_get_requirement directly · 0526c223
      Daniel Vetter authored
      
      Pretty simple case really.
      
      v2: Forgot to remove a break;
      
      v3: Add static inline to the dummy versions.
      
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Yisheng Xie <ysxie@foxmail.com>
      Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: Mikulas Patocka <mpatocka@redhat.com>
      Cc: linux-fbdev@vger.kernel.org
      Link: https://patchwork.freedesktop.org/patch/msgid/20190528090304.9388-24-daniel.vetter@ffwll.ch
      0526c223
    • Daniel Vetter's avatar
      fbcon: Call fbcon_mode_deleted/new_modelist directly · 13ff178c
      Daniel Vetter authored
      
      I'm not entirely clear on what new_modelist actually does, it seems
      exclusively for a sysfs interface. Which in the end does amount to a
      normal fb_set_par to check the mode, but then takes a different path
      in both fbmem.c and fbcon.c.
      
      I have no idea why these 2 paths are different, but then I also don't
      really want to find out. So just do the simple conversion to a direct
      function call.
      
      v2: static inline for the dummy versions, I forgot.
      
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Mikulas Patocka <mpatocka@redhat.com>
      Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: Yisheng Xie <ysxie@foxmail.com>
      Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
      Cc: linux-fbdev@vger.kernel.org
      Link: https://patchwork.freedesktop.org/patch/msgid/20190528090304.9388-23-daniel.vetter@ffwll.ch
      13ff178c
    • Daniel Vetter's avatar
      fbdev: directly call fbcon_suspended/resumed · 50c50563
      Daniel Vetter authored
      
      With the sh_mobile notifier removed we can just directly call the
      fbcon code here.
      
      v2: Remove now unused local variable.
      
      v3: fixup !CONFIG_FRAMEBUFFER_CONSOLE, noticed by kbuild
      
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Konstantin Khorenko <khorenko@virtuozzo.com>
      Cc: Yisheng Xie <ysxie@foxmail.com>
      Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: Mikulas Patocka <mpatocka@redhat.com>
      Cc: linux-fbdev@vger.kernel.org
      Link: https://patchwork.freedesktop.org/patch/msgid/20190528090304.9388-22-daniel.vetter@ffwll.ch
      50c50563
    • Daniel Vetter's avatar
      fbdev: unify unlink_framebuffer paths · 927ab1ae
      Daniel Vetter authored
      
      For some reasons the pm_vt_switch_unregister call was missing from the
      direct unregister_framebuffer path. Fix this.
      
      v2: fbinfo->dev is used to decided whether unlink_framebuffer has been
      called already. I botched that in v1. Make this all clearer by
      inlining __unlink_framebuffer.
      
      v3: Fix typoe in subject (Maarten).
      
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Mikulas Patocka <mpatocka@redhat.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20190528090304.9388-20-daniel.vetter@ffwll.ch
      927ab1ae
    • Daniel Vetter's avatar
      fbdev: make unregister/unlink functions not fail · deb00d27
      Daniel Vetter authored
      
      Except for driver bugs (which we'll catch with a WARN_ON) this is only
      to report failures of the new driver taking over the console. There's
      nothing the outgoing driver can do about that, and no one ever
      bothered to actually look at these return values. So remove them all.
      
      v2: fixup unregister_framebuffer in savagefb, fbtft, ivtvfb, and neofb
      drivers, reported by kbuild.
      
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Mikulas Patocka <mpatocka@redhat.com>
      Cc: linux-fbdev@vger.kernel.org
      Link: https://patchwork.freedesktop.org/patch/msgid/20190528090304.9388-19-daniel.vetter@ffwll.ch
      deb00d27
    • Daniel Vetter's avatar
      fbcon: call fbcon_fb_bind directly · 0e0f3250
      Daniel Vetter authored
      
      Also remove the error return value. That's all errors for either
      driver bugs (trying to unbind something that isn't bound), or errors
      of the new driver that will take over.
      
      There's nothing the outgoing driver can do about this anyway, so
      switch over to void.
      
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Konstantin Khorenko <khorenko@virtuozzo.com>
      Cc: Yisheng Xie <ysxie@foxmail.com>
      Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
      Cc: Mikulas Patocka <mpatocka@redhat.com>
      Cc: Thomas Zimmermann <tzimmermann@suse.de>
      Cc: linux-fbdev@vger.kernel.org
      Link: https://patchwork.freedesktop.org/patch/msgid/20190528090304.9388-18-daniel.vetter@ffwll.ch
      0e0f3250
    • Daniel Vetter's avatar
      fbdev: lock_fb_info cannot fail · cf4a3ae4
      Daniel Vetter authored
      
      Ever since
      
      commit c47747fd
      Author: Linus Torvalds <torvalds@linux-foundation.org>
      Date:   Wed May 11 14:58:34 2011 -0700
      
          fbmem: make read/write/ioctl use the frame buffer at open time
      
      fbdev has gained proper refcounting for the fbinfo attached to any
      open files, which means that the backing driver (stored in
      fb_info->fbops) cannot untimely disappear anymore.
      
      The only thing that can happen is that the entire device just outright
      disappears and gets unregistered, but file_fb_info does check for
      that. Except that it's racy - it only checks once at the start of a
      file_ops, there's no guarantee that the underlying fbdev won't
      untimely disappear. Aside: A proper way to fix that race is probably
      to replicate the srcu trickery we've rolled out in drm.
      
      But given that this race has existed since forever it's probably not
      one we need to fix right away. do_unregister_framebuffer also nowhere
      clears fb_info->fbops, hence the check in lock_fb_info can't possible
      catch a disappearing fbdev later on.
      
      Long story short: Ever since the above commit the fb_info->fbops
      checks have essentially become dead code. Remove this all.
      
      Aside from the file_ops callbacks, and stuff called from there
      there's only register/unregister code left. If that goes wrong a driver
      managed to register/unregister a device instance twice or in the wrong
      order.  That's just a driver bug.
      
      v2:
      - fb_mmap had an open-coded version of the fbinfo->fops check, because
        it doesn't need the fbinfo->lock. Delete that too.
      - Use the wrapper function in fb_open/release now, since no difference
        anymore.
      
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Yisheng Xie <ysxie@foxmail.com>
      Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
      Cc: "Noralf Trønnes" <noralf@tronnes.org>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
      Cc: Mikulas Patocka <mpatocka@redhat.com>
      Cc: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
      Cc: linux-fbdev@vger.kernel.org
      Link: https://patchwork.freedesktop.org/patch/msgid/20190528090304.9388-17-daniel.vetter@ffwll.ch
      cf4a3ae4
    • Daniel Vetter's avatar
      fbcon: call fbcon_fb_(un)registered directly · 97b67986
      Daniel Vetter authored
      
      With
      
      commit 6104c370
      Author: Daniel Vetter <daniel.vetter@ffwll.ch>
      Date:   Tue Aug 1 17:32:07 2017 +0200
      
          fbcon: Make fbcon a built-time depency for fbdev
      
      we have a static dependency between fbcon and fbdev, and we can
      replace the indirection through the notifier chain with a function
      call.
      
      v2: Sam Ravnborg noticed that mach-pxa/am200epd.c has a notifier too,
      and listens to this.
      
      ...
      
      Looking at the code it seems to wait for some fb to show up, so that
      it can get the framebuffer base address from the fb_info struct. I
      suspect his is some firmware fbdev. Then it uses that information to
      let the real fbdev driver (metronomefb.c by the looks) get at the
      framebuffer memory.
      
      This doesn't looke like it's easy to fix (except by deleting the
      entire thing, seems untouched since 2008, we might be able to get away
      with that), so let's just stuff a few #ifdef into fb.h and fbmem.c and
      cry over them for a bit.
      
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
      Reviewed-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Hans de Goede <hdegoede@redhat.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: "Noralf Trønnes" <noralf@tronnes.org>
      Cc: Yisheng Xie <ysxie@foxmail.com>
      Cc: Peter Rosin <peda@axentia.se>
      Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
      Cc: Thomas Zimmermann <tzimmermann@suse.de>
      Cc: Mikulas Patocka <mpatocka@redhat.com>
      Cc: linux-fbdev@vger.kernel.org
      Cc: Daniel Mack <daniel@zonque.org>
      Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
      Cc: Robert Jarzmik <robert.jarzmik@free.fr>
      Cc: Konstantin Khorenko <khorenko@virtuozzo.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Cc: Steve Sakoman <sakoman@gmail.com>
      Cc: Steve Sakoman <steve@sakoman.com>
      Cc: linux-arm-kernel@lists.infradead.org
      Link: https://patchwork.freedesktop.org/patch/msgid/20190528090304.9388-11-daniel.vetter@ffwll.ch
      97b67986
Loading