Skip to content
  • Jonathon Reinhart's avatar
    net: Ensure net namespace isolation of sysctls · 31c4d2f1
    Jonathon Reinhart authored
    
    
    This adds an ensure_safe_net_sysctl() check during register_net_sysctl()
    to validate that sysctl table entries for a non-init_net netns are
    sufficiently isolated. To be netns-safe, an entry must adhere to at
    least (and usually exactly) one of these rules:
    
    1. It is marked read-only inside the netns.
    2. Its data pointer does not point to kernel/module global data.
    
    An entry which fails both of these checks is indicative of a bug,
    whereby a child netns can affect global net sysctl values.
    
    If such an entry is found, this code will issue a warning to the kernel
    log, and force the entry to be read-only to prevent a leak.
    
    To test, simply create a new netns:
    
        $ sudo ip netns add dummy
    
    As it sits now, this patch will WARN for two sysctls which will be
    addressed in a subsequent patch:
    - /proc/sys/net/netfilter/nf_conntrack_max
    - /proc/sys/net/netfilter/nf_conntrack_expect_max
    
    Signed-off-by: default avatarJonathon Reinhart <Jonathon.Reinhart@gmail.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    31c4d2f1