Linux 7.5 To Optionally Block /proc/kcore Access For Better Security

A patch that is queued up ahead of the Linux 7.5 merge window allows for optionally disabling /proc/kcore access at boot time. This can allow for better system security though will remain enabled by default for kernel builds with the typical CONFIG_PROC_KCORE option. The /proc/kcore virtual read-only file can provide the entire contents of the system's physical memory and kernel virtual address space in the ELF core dump format. The /proc/kcore file does have legitimate uses such as for live kernel debugging, memory forensics, ELF inspection, and more. Access of /proc/kcore is restricted to root or processes otherwise having CAP_SYS_RAWIO, since accessing the entire physical memory and kernel virtual address space is a pretty big deal. With Linux 7.5, /proc/kcore access will be optionally further restricted at boot time. Chris Down authored a patch to allow disabling /proc/kcore at boot time via the kcore= boot parameter with kcore=off disabling it at boot time (assuming the kernel build has CONFIG_PROC_KCORE enabled in the first place). The default value is on. Chris provided the rationale in the patch message: "/proc/kcore lets any process with CAP_SYS_RAWIO read all of kernel memory. That's a pretty large read primitive for anyone who obtains CAP_SYS_RAWIO (and it also gives away the KASLR layout). For this reason on some hosts we want to turn /proc/kcore off. In terms of what it can read, /proc/kcore isn't any more concerning than other ways to read kernel memory, like BPF with CAP_BPF and CAP_PERFMON. The distinction is that a process with CAP_SYS_RAWIO doesn't necessarily have CAP_BPF and CAP_PERFMON, because CAP_SYS_RAWIO may be needed for hardware access without necessarily wanting to grant general RAM access. CONFIG_STRICT_DEVMEM already makes that possible for /dev/mem, but /proc/kcore gives the same capability to do general purpose RAM reading anyway. However, on a kernel built with CONFIG_PROC_KCORE=y the only ways to block it today are lockdown=confidentiality (which also disables many other things we perhaps don't want to disable, like kprobes and bpf_probe_read_kernel()), or an LSM. That's annoying, because on the majority of hosts we do want it on for things like drgn/crash, so today we build two separate kernels. Let's add a "kcore=" boot parameter so that this can be disabled at boot, which lets us preserve those choices while using the same kernel image." The patch was picked up yesterday into the vfs/vfs.git's vfs-7.5.procfs Git branch. With the patch for this kcore= option now being in a VFS 7.5 branch, expect it to be submitted for the Linux 7.5 merge window happening in just over one month's time.

Original Source

Read the full article at Phoronix →

KhanList aggregates and links to publicly available news content. We do not host full articles from third-party sources. Always verify important information with original sources.