set kernel.printk sysctl to prevent kernel info leaks

Information

ID: 950
PHID: PHID-TASK-rwjib2gat7fydn57kogf
Author: Patrick
Status at Migration Time: resolved
Priority at Migration Time: Normal

Description

quote @madaidan:

During boot, the kernel logs are displayed on the console. As the kernel logs are meant to be restricted to root (kernel.dmesg_restrict=1), this should probably be disabled.

Setting kernel.printk=3 3 3 3 with sysctl configures it so only really important errors will be displayed.

Also see Does printk() cause any security issues?

This can improve boot and shutdown speed too. I’ve noticed that performance improves significantly after setting this.

dmesg --console-off does not do the trick.

I still see some logs after running that. Changing the kernel.printk sysctl hides more. I can still see some logs even with changing kernel.printk as it starts displaying logs before systemd-sysctl is executed.

The only way around that would be setting kernel.printk in the initramfs, before systemd has started if it’s even possible.

Edit:
Setting kernel.printk = 3 3 3 3 was implemented in /etc/sysctl.d/30_security-misc.conf and it is being set initramfs before systemd has started using /etc/initramfs-tools/scripts/init-bottom/sysctl-initramfs.


Maybe from Linux 5.7+ sysctls can be set from Linux boot cmdline which is planned as per T984 which might fix the remaining unwanted messages.


https://wiki.archlinux.org/index.php/Silent_boot

Comments


madaidan

2019-12-23 20:08:08 UTC


Patrick

2019-12-24 11:02:21 UTC


madaidan

2019-12-24 15:39:35 UTC


Patrick

2019-12-24 15:47:17 UTC


madaidan

2019-12-24 16:10:03 UTC


madaidan

2019-12-24 16:34:51 UTC


Patrick

2019-12-24 16:54:29 UTC


Patrick

2019-12-24 17:24:01 UTC


madaidan

2019-12-24 18:09:26 UTC


Patrick

2020-01-01 11:05:51 UTC


Patrick

2020-01-01 11:31:50 UTC


Patrick

2020-01-15 11:11:00 UTC


madaidan

2020-03-21 17:55:27 UTC


Patrick

2020-03-22 11:48:26 UTC


Patrick

2020-03-22 18:47:50 UTC


Patrick

2020-04-16 09:30:04 UTC


Patrick

2020-04-16 11:29:53 UTC


Patrick

2020-04-16 12:01:48 UTC


Patrick

2020-04-16 14:02:18 UTC


Patrick

2020-04-23 16:40:39 UTC


Patrick

2020-05-14 18:58:38 UTC


Patrick

2020-09-28 14:32:44 UTC