dmesg
calls C library's klogctl
wrapper function for kernel's syslog
syscall which reads kernel's ring buffer by accessing /dev/kmsg
character device. adb shell dmesg
returns permissions denied error because adbd
which runs with context u:r:shell:s0
is not allowed by SELinux to read kernel log. You need to explicitly allow it (requires root):
~# supolicy --live 'allow shell kernel system syslog_read'
If property ro.logd.kernel
is set to true
(default on debuggable
builds), Android's logging daemon (logd
) writes kernel messages to a separate buffer named kernel
, which can be read using logcat
(doesn't require root):
~$ logcat -b kernel