• Maciej W. Rozycki's avatar
    vgacon: Propagate console boot parameters before calling `vc_resize' · 3dfac26e
    Maciej W. Rozycki authored
    Fix a division by zero in `vgacon_resize' with a backtrace like:
    
    vgacon_resize
    vc_do_resize
    vgacon_init
    do_bind_con_driver
    do_unbind_con_driver
    fbcon_fb_unbind
    do_unregister_framebuffer
    do_register_framebuffer
    register_framebuffer
    __drm_fb_helper_initial_config_and_unlock
    drm_helper_hpd_irq_event
    dw_hdmi_irq
    irq_thread
    kthread
    
    caused by `c->vc_cell_height' not having been initialized.  This has
    only started to trigger with commit 860dafa9 ("vt: Fix character
    height handling with VT_RESIZEX"), however the ultimate offender is
    commit 50ec42ed ("[PATCH] Detaching fbcon: fix vgacon to allow
    retaking of the console").
    
    Said commit has added a call to `vc_resize' whenever `vgacon_init' is
    called with the `init' argument set to 0, which did not happen before.
    And the call is made before a key vgacon boot parameter retrieved in
    `vgacon_startup' has been propagated in `vgacon_init' for `vc_resize' to
    use to the console structure being worked on.  Previously the parameter
    was `c->vc_font.height' and now it is `c->vc_cell_height'.
    
    In this particular scenario the registration of fbcon has failed and vt
    resorts to vgacon.  Now fbcon does have initialized `c->vc_font.height'
    somehow, unlike `c->vc_cell_height', which is why this code did not
    crash before, but either way the boot parameters should have been copied
    to the console structure ahead of the call to `vc_resize' rather than
    afterwards, so that first the call has a chance to use them and second
    they do not change the console structure to something possibly different
    from what was used by `vc_resize'.
    
    Move the propagation of the vgacon boot parameters ahead of the call to
    `vc_resize' then.  Adjust the comment accordingly.
    
    Fixes: 50ec42ed ("[PATCH] Detaching fbcon: fix vgacon to allow retaking of the console")
    Cc: stable@vger.kernel.org # v2.6.18+
    Reported-by: default avatarWim Osterholt <wim@djo.tudelft.nl>
    Reported-by: default avatarPavel V. Panteleev <panteleev_p@mcst.ru>
    Signed-off-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
    Link: https://lore.kernel.org/r/alpine.DEB.2.21.2110252317110.58149@angie.orcam.me.ukSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    3dfac26e
vgacon.c 36.5 KB