Comment 5 for bug 1699161

Revision history for this message
Stéphane Graber (stgraber) wrote : Re: lshw crashes with SEGV in unprivileged container

Unable to reproduce in a normal unprivileged container:
```
stgraber@castiana:~$ lxc launch ubuntu:16.04 unpriv
Creating unpriv
Starting unpriv
stgraber@castiana:~$ lxc exec unpriv bash
root@unpriv:~# ls -lh /sys/kernel/
total 0
drwxr-xr-x 2 nobody nogroup 0 Jun 26 06:32 boot_params
drwx------ 38 nobody nogroup 0 Jun 24 14:56 debug
-r--r--r-- 1 nobody nogroup 4.0K Jun 26 06:32 fscaps
drwxr-xr-x 2 nobody nogroup 0 Jun 26 06:32 iommu_groups
drwxr-xr-x 38 nobody nogroup 0 Jun 26 06:32 irq
-r--r--r-- 1 nobody nogroup 4.0K Jun 26 06:32 kexec_crash_loaded
-rw-r--r-- 1 nobody nogroup 4.0K Jun 26 06:32 kexec_crash_size
-r--r--r-- 1 nobody nogroup 4.0K Jun 26 06:32 kexec_loaded
drwxr-xr-x 2 nobody nogroup 0 Jun 26 06:32 livepatch
drwxr-xr-x 6 nobody nogroup 0 Jun 26 06:32 mm
-r--r--r-- 1 nobody nogroup 516 Jun 26 06:32 notes
-rw-r--r-- 1 nobody nogroup 4.0K Jun 26 06:32 profiling
-rw-r--r-- 1 nobody nogroup 4.0K Jun 26 06:32 rcu_expedited
-rw-r--r-- 1 nobody nogroup 4.0K Jun 26 06:32 rcu_normal
drwxr-xr-x 4 nobody nogroup 0 Jun 24 14:55 security
drwxr-xr-x 140 nobody nogroup 0 Jun 26 06:32 slab
dr-xr-xr-x 2 nobody nogroup 0 Jun 26 06:33 tracing
-rw-r--r-- 1 nobody nogroup 4.0K Jun 24 14:55 uevent_helper
-r--r--r-- 1 nobody nogroup 4.0K Jun 26 06:32 uevent_seqnum
-r--r--r-- 1 nobody nogroup 4.0K Jun 26 06:32 vmcoreinfo
root@unpriv:~# lshw >/dev/null
root@unpriv:~# echo $?
0
root@unpriv:~#
```

But I can reproduce it in a privileged container where lshw is seen attempting to access /sys/kernel/debug/usb/devices and /proc/bus/usb/devices. The former is denied as all debugfs access should be in privileged containers, the latter doesn't exist.

So this is a lshw bug. It shouldn't just crash when the kernel denies it access to a path. I'd instead expect it to skip the particular subsystem.