android_kernel_xiaomi_sm8450/net
Martynas Pumputis cda90416c0 UPSTREAM: net: retrieve netns cookie via getsocketopt
It's getting more common to run nested container environments for
testing cloud software. One of such examples is Kind [1] which runs a
Kubernetes cluster in Docker containers on a single host. Each container
acts as a Kubernetes node, and thus can run any Pod (aka container)
inside the former. This approach simplifies testing a lot, as it
eliminates complicated VM setups.

Unfortunately, such a setup breaks some functionality when cgroupv2 BPF
programs are used for load-balancing. The load-balancer BPF program
needs to detect whether a request originates from the host netns or a
container netns in order to allow some access, e.g. to a service via a
loopback IP address. Typically, the programs detect this by comparing
netns cookies with the one of the init ns via a call to
bpf_get_netns_cookie(NULL). However, in nested environments the latter
cannot be used given the Kubernetes node's netns is outside the init ns.
To fix this, we need to pass the Kubernetes node netns cookie to the
program in a different way: by extending getsockopt() with a
SO_NETNS_COOKIE option, the orchestrator which runs in the Kubernetes
node netns can retrieve the cookie and pass it to the program instead.

Thus, this is following up on Eric's commit 3d368ab87cf6 ("net:
initialize net->net_cookie at netns setup") to allow retrieval via
SO_NETNS_COOKIE.  This is also in line in how we retrieve socket cookie
via SO_COOKIE.

  [1] https://kind.sigs.k8s.io/

Signed-off-by: Lorenz Bauer <lmb@cloudflare.com>
Signed-off-by: Martynas Pumputis <m@lambda.lt>
Cc: Eric Dumazet <edumazet@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit e8b9eab99232c4e62ada9d7976c80fd5e8118289)
Bug: 274789652
Tested: builds, net_test passes
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If784a592450af38d70f16da61e36cbbaff80ebca
2023-03-23 15:42:38 +00:00
..
6lowpan 6lowpan: iphc: Fix an off-by-one check of array index 2021-09-15 09:50:34 +02:00
9p This is the 5.10.159 stable release 2022-12-14 13:11:31 +01:00
802 mrp: introduce active flags to prevent UAF when applicant uninit 2023-01-14 10:16:18 +01:00
8021q net: make free_netdev() more lenient with unregistering devices 2022-07-29 17:19:07 +02:00
appletalk appletalk: Fix skb allocation size in loopback case 2021-04-07 15:00:08 +02:00
atm net/atm: fix proc_mpc_write incorrect return value 2022-10-30 09:41:16 +01:00
ax25 net: ax25: Fix deadlock caused by skb_recv_datagram in ax25_recvmsg 2022-06-22 14:13:17 +02:00
batman-adv batman-adv: Don't skb_split skbuffs with frag_list 2022-05-18 10:23:42 +02:00
bluetooth Merge 5.10.167 into android12-5.10-lts 2023-02-17 15:21:25 +00:00
bpf bpf: Move skb->len == 0 checks into __bpf_redirect 2023-01-14 10:15:31 +01:00
bpfilter ANDROID: GKI: set vfs-only exports into their own namespace 2022-01-11 09:30:47 +01:00
bridge netfilter: br_netfilter: disable sabotage_in hook after first suppression 2023-02-15 17:22:12 +01:00
caif caif: fix memory leak in cfctrl_linkup_request() 2023-01-14 10:16:48 +01:00
can can: j1939: do not wait 250 ms if the same addr was already claimed 2023-02-15 17:22:23 +01:00
ceph libceph: fix potential use-after-free on linger ping and resends 2022-05-25 09:17:56 +02:00
core UPSTREAM: net: retrieve netns cookie via getsocketopt 2023-03-23 15:42:38 +00:00
dcb net: dcb: disable softirqs in dcbnl_flush_dev() 2022-03-08 19:09:37 +01:00
dccp This is the 5.10.157 stable release 2022-12-04 12:51:21 +00:00
decnet net: Fix data-races around sysctl_[rw]mem(_offset)?. 2022-08-31 17:15:19 +02:00
dns_resolver
dsa net: dsa: ksz: Check return value 2022-12-14 11:32:01 +01:00
ethernet
ethtool net/ethtool/ioctl: return -EOPNOTSUPP if we have no phy stats 2023-01-24 07:19:55 +01:00
hsr hsr: Synchronize sequence number updates. 2023-01-14 10:15:37 +01:00
ieee802154 net: ieee802154: fix error return code in dgram_bind() 2022-11-03 23:57:51 +09:00
ife
ipv4 Merge 5.10.168 into android12-5.10-lts 2023-02-17 15:23:41 +00:00
ipv6 This is the 5.10.164 stable release 2023-02-16 13:59:20 +00:00
iucv
kcm kcm: close race conditions on sk_receive_queue 2022-11-25 17:45:56 +01:00
key af_key: Fix send_acquire race with pfkey_register 2022-12-02 17:39:58 +01:00
l2tp l2tp: prevent lockdep issue in l2tp_tunnel_register() 2023-02-01 08:23:14 +01:00
l3mdev l3mdev: l3mdev_master_upper_ifindex_by_index_rcu should be using netdev_master_upper_dev_get_rcu 2022-04-27 13:53:50 +02:00
lapb
llc llc: only change llc->dev when bind() succeeds 2022-03-28 09:57:10 +02:00
mac80211 Revert "wifi: mac80211: fix memory leak in ieee80211_if_add()" 2023-01-24 07:20:01 +01:00
mac802154 mac802154: fix missing INIT_LIST_HEAD in ieee802154_if_add() 2022-12-14 11:32:01 +01:00
mpls net: Use u64_stats_fetch_begin_irq() for stats fetch. 2022-09-08 11:11:40 +02:00
mptcp mptcp: use proper req destructor for IPv6 2023-01-14 10:16:52 +01:00
ncsi net/ncsi: check for error return from call to nla_put_u32 2022-01-05 12:40:32 +01:00
netfilter Merge 5.10.166 into android12-5.10-lts 2023-02-17 12:18:56 +00:00
netlabel netlabel: fix out-of-bounds memory accesses 2022-04-13 21:01:00 +02:00
netlink netlink: annotate data races around sk_state 2023-02-01 08:23:24 +01:00
netrom netrom: Fix use-after-free caused by accept on already connected socket 2023-02-15 17:22:12 +01:00
nfc net: nfc: Fix use-after-free in local_cleanup() 2023-02-01 08:23:12 +01:00
nsh
openvswitch net: openvswitch: fix flow memory leak in ovs_flow_cmd_new 2023-02-15 17:22:14 +01:00
packet net/af_packet: make sure to pull mac header 2023-01-14 10:16:29 +01:00
phonet phonet: refcount leak in pep_sock_accep 2022-01-11 15:25:01 +01:00
psample
qrtr Merge tag 'android12-5.10.168_r00' into android12-5.10 2023-03-23 11:09:43 +00:00
rds rds: rds_rm_zerocopy_callback() use list_first_entry() 2023-02-15 17:22:25 +01:00
rfkill
rose rose: Fix NULL pointer dereference in rose_send_frame() 2022-11-10 18:14:19 +01:00
rxrpc rxrpc: Fix missing unlock in rxrpc_do_sendmsg() 2023-01-14 10:16:12 +01:00
sched Merge tag 'android12-5.10.168_r00' into android12-5.10 2023-03-23 11:09:43 +00:00
sctp Merge 5.10.166 into android12-5.10-lts 2023-02-17 12:18:56 +00:00
smc net/smc: Stop the CLC flow if no link to map buffers on 2022-09-28 11:10:36 +02:00
strparser bpf: sockmap, strparser, and tls are reusing qdisc_skb_cb and colliding 2021-11-18 14:04:27 +01:00
sunrpc This is the 5.10.163 stable release 2023-02-06 12:30:05 +00:00
switchdev
tipc This is the 5.10.164 stable release 2023-02-16 13:59:20 +00:00
tls net/tls: Remove the context from the list in tls_device_down 2022-08-03 12:00:46 +02:00
unix This is the 5.10.159 stable release 2022-12-14 13:11:31 +01:00
vmw_vsock This is the 5.10.163 stable release 2023-02-06 12:30:05 +00:00
wimax
wireless This is the 5.10.163 stable release 2023-02-06 12:30:05 +00:00
x25 net/x25: Fix to not accept on connected socket 2023-02-15 17:22:15 +01:00
xdp xsk: Inherit need_wakeup flag for shared sockets 2022-10-15 07:55:51 +02:00
xfrm Merge 5.10.168 into android12-5.10-lts 2023-02-17 15:23:41 +00:00
compat.c net: Return the correct errno code 2021-06-18 10:00:06 +02:00
devres.c
Kconfig
Makefile
socket.c UPSTREAM: net: remove cmsg restriction from io_uring based send/recvmsg calls 2023-02-07 13:38:15 +00:00
sysctl_net.c
TEST_MAPPING ANDROID: add TEST_MAPPING for net/, include/net 2023-01-23 17:55:25 +00:00