OSDN Git Service

net: Enable max_dgram_qlen unix sysctl to be configurable by non-init user namespaces
authorJoanne Koong <joannekoong@fb.com>
Fri, 10 Dec 2021 20:40:23 +0000 (12:40 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 13 Dec 2021 12:47:47 +0000 (12:47 +0000)
commitcec16052d5a774035fc6da19cb9d09106356bbef
treeca8c09da4aa40d6b65c138d3fc6b9ddd6635b76a
parent3c118547f87e930d45a5787e386734015dd93b32
net: Enable max_dgram_qlen unix sysctl to be configurable by non-init user namespaces

This patch enables the "/proc/sys/net/unix/max_dgram_qlen" sysctl to be
exposed to non-init user namespaces. max_dgram_qlen is used as the default
"sk_max_ack_backlog" value for when a unix socket is created.

Currently, when a networking namespace is initialized, its unix sysctls
are exposed only if the user namespace that "owns" it is the init user
namespace. If there is an non-init user namespace that "owns" a networking
namespace (for example, in the case after we call clone() with both
CLONE_NEWUSER and CLONE_NEWNET set), the sysctls are hidden from view
and not configurable.

Exposing the unix sysctl is safe because any changes made to it will be
limited in scope to the networking namespace the non-init user namespace
"owns" and has privileges over (changes won't affect any other net
namespace). There is also no possibility of a non-privileged user namespace
messing up the net namespace sysctls it shares with its parent user namespace.
When a new user namespace is created without unsharing the network namespace
(eg calling clone()  with CLONE_NEWUSER), the new user namespace shares its
parent's network namespace. Write access is protected by the mode set
in the sysctl's ctl_table (and enforced by procfs). Here in the case of
"max_dgram_qlen", 0644 is set; only the user owner has write access.

v1 -> v2:
* Add more detail to commit message, specify the
"/proc/sys/net/unix/max_dgram_qlen" sysctl in commit message.

Signed-off-by: Joanne Koong <joannekoong@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/unix/sysctl_net_unix.c