linux/include/net/netns
Bobby Eshleman 102eab95f0 vsock: lock down child_ns_mode as write-once
Two administrator processes may race when setting child_ns_mode as one
process sets child_ns_mode to "local" and then creates a namespace, but
another process changes child_ns_mode to "global" between the write and
the namespace creation. The first process ends up with a namespace in
"global" mode instead of "local". While this can be detected after the
fact by reading ns_mode and retrying, it is fragile and error-prone.

Make child_ns_mode write-once so that a namespace manager can set it
once and be sure it won't change. Writing a different value after the
first write returns -EBUSY. This applies to all namespaces, including
init_net, where an init process can write "local" to lock all future
namespaces into local mode.

Fixes: eafb64f40c ("vsock: add netns to vsock core")
Suggested-by: Daan De Meyer <daan.j.demeyer@gmail.com>
Suggested-by: Stefano Garzarella <sgarzare@redhat.com>
Co-developed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Bobby Eshleman <bobbyeshleman@meta.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://patch.msgid.link/20260223-vsock-ns-write-once-v3-2-c0cde6959923@meta.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2026-02-26 11:10:03 +01:00
..
bpf.h
can.h
conntrack.h netfilter: conntrack: remove DCCP protocol support 2025-07-03 13:51:39 +02:00
core.h net: Introduce net.core.bypass_prot_mem sysctl. 2025-10-16 12:04:47 -07:00
flow_table.h
generic.h
hash.h
ieee802154_6lowpan.h
ipv4.h inet: move icmp_global_{credit,stamp} to a separate cache line 2026-02-18 16:46:36 -08:00
ipv6.h ipv6: add sysctl_ipv6_flowlabel group 2026-01-19 09:56:42 -08:00
mctp.h net: mctp: Use hashtable for binds 2025-07-15 12:08:39 +02:00
mib.h
mpls.h mpls: Protect net->mpls.platform_label with a per-netns mutex. 2025-11-03 17:40:53 -08:00
netfilter.h
nexthop.h
nftables.h netfilter: nf_tables: place base_seq in struct net 2025-09-10 20:30:37 +02:00
packet.h
sctp.h sctp: Convert cookie authentication to use HMAC-SHA256 2025-08-19 19:36:26 -07:00
smc.h net/smc: bpf: Introduce generic hook for handshake flow 2025-11-10 11:19:41 -08:00
unix.h
vsock.h vsock: lock down child_ns_mode as write-once 2026-02-26 11:10:03 +01:00
xdp.h
xfrm.h xfrm: Add an inbound percpu state cache. 2024-10-29 11:56:18 +01:00