Skip to content

Sysctl: clean the code and prepare for secure use in containers

Pavel Emelyanov lkml 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3Sysctl: merge equal proc_sys_read and proc_sys_writefs/proc/proc_sysctl.c+11 -390 replies
2/3Sysctl: clean from unneeded extern and forward declarationsinclude/linux/sysctl.h kernel/sysctl.c+68 -810 replies
3/3Sysctl: add the ->permissions callback on the ctl_table_rootfs/proc/proc_sysctl.c include/linux/sysctl.h kernel/sysctl.c+26 -100 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3]Sysctl: clean the code and prepare for secure use in containers

Many (most of) sysctls do not have a per-container sense. E.g. kernel.print_fatal_signals, vm.panic_on_oom, net.core.netdev_budget and so on and so forth. Besides, tuning then from inside a container is not even secure. On the other hand, hiding them completely from the container's tasks sometimes causes user-space to stop working.

When developing net sysctl, the common practice was to duplicate a table and drop the write bits in table->mode, but this approach was not very elegant, lead to excessive memory consumption and was not suitable in general.

Here's the alternative solution. To facilitate the per-container sysctls ctl_table_root-s were introduced. Each root contains a list of ctl_table_header-s that are visible to different namespaces. The idea of this set is to add the permissions() callback on the ctl_table_root to allow ctl root limit permissions to the same ctl_table-s.

The main user of this functionality is the net-namespaces code, but later this will (should) be used by more and more namespaces, containers and control groups.

Actually, this idea's core is in a single hunk in the third patch. First two patches are cleanups for sysctl code, while the third one mostly extends the arguments set of some sysctl functions.