canonical / lxd

Powerful system container and virtual machine manager
https://canonical.com/lxd
GNU Affero General Public License v3.0
4.32k stars 926 forks source link

lxd crashes when attaching a HID device #6972

Closed mpuzio closed 4 years ago

mpuzio commented 4 years ago

Required information

Issue description

lxd daemon crashes when a HID device (e.g. a mouse) is attached to the machine, either directly or by using a KVM switch. The deamon is restarted by systemd. Containers continue running unaffected.

Report of a very similar issue, likely the same bug, against lxd 3.20 in Funtoo: https://bugs.funtoo.org/browse/FL-6991 User comment about this bug in lxd 3.21: https://bugs.funtoo.org/browse/FL-6991#comment-44583

Steps to reproduce

Reproducible: always

  1. Start lxd: systemctl start lxd
  2. Plug a USB mouse into the machine
  3. Look at /var/log/syslog (see below for a log excerpt)

Information to attach

/var/log/syslog

Mar 3 15:55:42 bear kernel: [372215.593162] usb 1-10: new low-speed USB device number 16 using xhci_hcd Mar 3 15:55:42 bear kernel: [372215.745467] usb 1-10: New USB device found, idVendor=046d, idProduct=c077, bcdDevice=72.00 Mar 3 15:55:42 bear kernel: [372215.745472] usb 1-10: New USB device strings: Mfr=1, Product=2, SerialNumber=0 Mar 3 15:55:42 bear kernel: [372215.745475] usb 1-10: Product: USB Optical Mouse Mar 3 15:55:42 bear kernel: [372215.745478] usb 1-10: Manufacturer: Logitech Mar 3 15:55:42 bear kernel: [372215.751226] input: Logitech USB Optical Mouse as /devices/pci0000:00/0000:00:14.0/usb1/1-10/1-10:1.0/0003:046D:C077.000F/input/input17 Mar 3 15:55:42 bear kernel: [372215.751363] hid-generic 0003:046D:C077.000F: input,hidraw2: USB HID v1.11 Mouse [Logitech USB Optical Mouse] on usb-0000:00:14.0-10/input0 Mar 3 15:55:42 bear lxd[15027]: panic: strings: negative Repeat count Mar 3 15:55:42 bear lxd[15027]: goroutine 103 [running]: Mar 3 15:55:42 bear lxd[15027]: strings.Repeat(0x134d7d7, 0x1, 0xffffffffffffffff, 0xc42045e01c, 0x4) Mar 3 15:55:42 bear lxd[15027]: #011/usr/lib/go-1.10/src/strings/strings.go:538 +0x1c7 Mar 3 15:55:42 bear lxd[15027]: main.deviceNetlinkListener.func1.2(0xc42045e032, 0x5, 0x4, 0xc42045e01c, 0x4) Mar 3 15:55:42 bear lxd[15027]: #011/home/maciej/lxd/lxd-3.21/_dist/src/github.com/lxc/lxd/lxd/devices.go:256 +0x4c Mar 3 15:55:42 bear lxd[15027]: main.deviceNetlinkListener.func1(0x800, 0x1b, 0xc4201e8960, 0xc4201dc540, 0xc4201dc5a0, 0xc4201dc600) Mar 3 15:55:42 bear lxd[15027]: #011/home/maciej/lxd/lxd-3.21/_dist/src/github.com/lxc/lxd/lxd/devices.go:266 +0x844 Mar 3 15:55:42 bear lxd[15027]: created by main.deviceNetlinkListener Mar 3 15:55:42 bear lxd[15027]: #011/home/maciej/lxd/lxd-3.21/_dist/src/github.com/lxc/lxd/lxd/devices.go:96 +0x226 Mar 3 15:55:42 bear systemd[1]: lxd.service: Main process exited, code=exited, status=2/INVALIDARGUMENT Mar 3 15:55:42 bear systemd[1]: lxd.service: Failed with result 'exit-code'. Mar 3 15:55:43 bear systemd[1]: lxd.service: Service hold-off time over, scheduling restart. Mar 3 15:55:43 bear systemd[1]: lxd.service: Scheduled restart job, restart counter is at 8. Mar 3 15:55:43 bear systemd[1]: Stopped LXD - main daemon. Mar 3 15:55:43 bear systemd[1]: lxd.service: Found left-over process 23654 (lxd) in control group while starting unit. Ignoring. Mar 3 15:55:43 bear systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies. Mar 3 15:55:43 bear systemd[1]: Starting LXD - main daemon... Mar 3 15:55:43 bear systemd[1]: lxd.service: Found left-over process 23654 (lxd) in control group while starting unit. Ignoring. Mar 3 15:55:43 bear systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies. Mar 3 15:55:43 bear lxd[24959]: t=2020-03-03T15:55:43-0600 lvl=warn msg=" - Couldn't find the CGroup blkio.weight, I/O weight limits will be ignored" Mar 3 15:55:43 bear systemd[1]: Started LXD - main daemon.

/var/log/lxd/lxd.log

Nothing interesting, these messages are from the restart after the crash. No messages from the crash itself.

t=2020-03-03T15:55:43-0600 lvl=info msg="LXD 3.21 is starting in normal mode" path=/var/lib/lxd t=2020-03-03T15:55:43-0600 lvl=info msg="Kernel uid/gid map:" t=2020-03-03T15:55:43-0600 lvl=info msg=" - u 0 0 4294967295" t=2020-03-03T15:55:43-0600 lvl=info msg=" - g 0 0 4294967295" t=2020-03-03T15:55:43-0600 lvl=info msg="Configured LXD uid/gid map:" t=2020-03-03T15:55:43-0600 lvl=info msg=" - u 0 231072 65536" t=2020-03-03T15:55:43-0600 lvl=info msg=" - g 0 231072 65536" t=2020-03-03T15:55:43-0600 lvl=info msg="Kernel features:" t=2020-03-03T15:55:43-0600 lvl=info msg=" - netnsid-based network retrieval: yes" t=2020-03-03T15:55:43-0600 lvl=info msg=" - uevent injection: yes" t=2020-03-03T15:55:43-0600 lvl=info msg=" - seccomp listener: yes" t=2020-03-03T15:55:43-0600 lvl=info msg=" - seccomp listener continue syscalls: yes" t=2020-03-03T15:55:43-0600 lvl=info msg=" - unprivileged file capabilities: yes" t=2020-03-03T15:55:43-0600 lvl=info msg=" - cgroup layout: hybrid" t=2020-03-03T15:55:43-0600 lvl=warn msg=" - Couldn't find the CGroup blkio.weight, I/O weight limits will be ignored" t=2020-03-03T15:55:43-0600 lvl=info msg=" - shiftfs support: yes" t=2020-03-03T15:55:43-0600 lvl=info msg="Initializing local database" t=2020-03-03T15:55:43-0600 lvl=info msg="Starting /dev/lxd handler:" t=2020-03-03T15:55:43-0600 lvl=info msg=" - binding devlxd socket" socket=/var/lib/lxd/devlxd/sock t=2020-03-03T15:55:43-0600 lvl=info msg="REST API daemon:" t=2020-03-03T15:55:43-0600 lvl=info msg=" - binding Unix socket" inherited=true socket=/var/lib/lxd/unix.socket t=2020-03-03T15:55:43-0600 lvl=info msg="Initializing global database" t=2020-03-03T15:55:43-0600 lvl=info msg="Initializing storage pools" t=2020-03-03T15:55:43-0600 lvl=info msg="Initializing networks" t=2020-03-03T15:55:43-0600 lvl=info msg="Pruning leftover image files" t=2020-03-03T15:55:43-0600 lvl=info msg="Done pruning leftover image files" t=2020-03-03T15:55:43-0600 lvl=info msg="Loading daemon configuration" t=2020-03-03T15:55:43-0600 lvl=info msg="Started seccomp handler" path=/var/lib/lxd/seccomp.socket t=2020-03-03T15:55:43-0600 lvl=info msg="Pruning expired images" t=2020-03-03T15:55:43-0600 lvl=info msg="Done pruning expired images" t=2020-03-03T15:55:43-0600 lvl=info msg="Pruning expired container backups" t=2020-03-03T15:55:43-0600 lvl=info msg="Done pruning expired container backups" t=2020-03-03T15:55:43-0600 lvl=info msg="Updating instance types" t=2020-03-03T15:55:43-0600 lvl=info msg="Done updating instance types" t=2020-03-03T15:55:43-0600 lvl=info msg="Expiring log files" t=2020-03-03T15:55:43-0600 lvl=info msg="Done expiring log files"

Output of lxc info

config: images.auto_update_interval: "0" api_extensions:

stgraber commented 4 years ago

@brauner