• Roger Pau Monne's avatar
    hvc/xen: lock console list traversal · c0dccad8
    Roger Pau Monne authored
    The currently lockless access to the xen console list in
    vtermno_to_xencons() is incorrect, as additions and removals from the
    list can happen anytime, and as such the traversal of the list to get
    the private console data for a given termno needs to happen with the
    lock held.  Note users that modify the list already do so with the
    lock taken.
    
    Adjust current lock takers to use the _irq{save,restore} helpers,
    since the context in which vtermno_to_xencons() is called can have
    interrupts disabled.  Use the _irq{save,restore} set of helpers to
    switch the current callers to disable interrupts in the locked region.
    I haven't checked if existing users could instead use the _irq
    variant, as I think it's safer to use _irq{save,restore} upfront.
    
    While there switch from using list_for_each_entry_safe to
    list_for_each_entry: the current entry cursor won't be removed as
    part of the code in the loop body, so using the _safe variant is
    pointless.
    
    Fixes: 02e19f9c ('hvc_xen: implement multiconsole support')
    Signed-off-by: default avatarRoger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: default avatarStefano Stabellini <sstabellini@kernel.org>
    Link: https://lore.kernel.org/r/20221130163611.14686-1-roger.pau@citrix.comSigned-off-by: default avatarJuergen Gross <jgross@suse.com>
    c0dccad8
hvc_xen.c 16.5 KB