[SOLVED] dmesg outside VM

Andrii

Member
Jul 6, 2016
50
0
6
41
I run the command 'dmesg' into the VM 101 and can see the logs for VM 108. Why this is possible?
20170428_57Ggs7Ir.png
 
that is not a VM, it is a container - and containers share a kernel (including the kernel's dmesg facility). you can disable access for non-root users (and thus also for unprivileged containers) by setting the sysctl kernel.dmesg_restrict to 1
 
And
Code:
sysctl -w kernel.dmesg_restrict=1
does not help for root into unprivileged container.
 
should work - please verify that you set the sysctl correctly (and that you are actually testing with an unpriv. container!)

Code:
$ echo 0 | sudo tee /proc/sys/kernel/dmesg_restrict
0
$ sudo pct enter 123
root@unprivtest:/# dmesg | head -3
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Initializing cgroup subsys cpuacct
root@unprivtest:/# exit

$ echo 1 | sudo tee /proc/sys/kernel/dmesg_restrict
1
$ sudo pct enter 123
root@unprivtest:/# dmesg | head -3
dmesg: read kernel buffer failed: Operation not permitted
root@unprivtest:/# exit
 
Found the solution
Need to add syslog errno 1 into /usr/share/lxc/config/common.seccomp
 
Last edited: