• Amit Shah's avatar
    virtio: console: add locking around c_ovq operations · 9ba5c80b
    Amit Shah authored
    When multiple ovq operations are being performed (lots of open/close
    operations on virtio_console fds), the __send_control_msg() function can
    get confused without locking.
    
    A simple recipe to cause badness is:
    * create a QEMU VM with two virtio-serial ports
    * in the guest, do
      while true;do echo abc >/dev/vport0p1;done
      while true;do echo edf >/dev/vport0p2;done
    
    In one run, this caused a panic in __send_control_msg().  In another, I
    got
    
       virtio_console virtio0: control-o:id 0 is not a head!
    
    This also results repeated messages similar to these on the host:
    
      qemu-kvm: virtio-serial-bus: Unexpected port id 478762112 for device virtio-serial-bus.0
      qemu-kvm: virtio-serial-bus: Unexpected port id 478762368 for device virtio-serial-bus.0
    Reported-by: default avatarFuXiangChun <xfu@redhat.com>
    Signed-off-by: default avatarAmit Shah <amit.shah@redhat.com>
    Reviewed-by: default avatarWanlong Gao <gaowanlong@cn.fujitsu.com>
    Reviewed-by: default avatarAsias He <asias@redhat.com>
    Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
    Cc: stable@kernel.org
    9ba5c80b
virtio_console.c 54.5 KB