linux-stable/net/core
Thadeu Lima de Souza Cascardo 0c3248bc70 net: fix out-of-bounds access in ops_init
commit a26ff37e62 upstream.

net_alloc_generic is called by net_alloc, which is called without any
locking. It reads max_gen_ptrs, which is changed under pernet_ops_rwsem. It
is read twice, first to allocate an array, then to set s.len, which is
later used to limit the bounds of the array access.

It is possible that the array is allocated and another thread is
registering a new pernet ops, increments max_gen_ptrs, which is then used
to set s.len with a larger than allocated length for the variable array.

Fix it by reading max_gen_ptrs only once in net_alloc_generic. If
max_gen_ptrs is later incremented, it will be caught in net_assign_generic.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
Fixes: 073862ba5d ("netns: fix net_alloc_generic()")
Reviewed-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20240502132006.3430840-1-cascardo@igalia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-05-17 11:48:10 +02:00
..
Makefile
bpf_sk_storage.c bpf: Add length check for SK_DIAG_BPF_STORAGE_REQ_MAP_FD parsing 2023-08-11 11:57:47 +02:00
datagram.c net: datagram: fix data-races in datagram_poll() 2023-05-30 12:57:46 +01:00
datagram.h
dev.c packet: annotate data-races around ignore_outgoing 2024-03-26 18:22:03 -04:00
dev_addr_lists.c
dev_ioctl.c net: dev: Convert sa_data to flexible array in struct sockaddr 2024-03-01 13:16:50 +01:00
devlink.c devlink: remove reload failed checks in params get/set callbacks 2023-09-23 11:01:05 +02:00
drop_monitor.c drop_monitor: Require 'CAP_SYS_ADMIN' when joining "events" group 2023-12-13 18:27:06 +01:00
dst.c ipv6: remove max_size check inline with ipv4 2024-01-15 18:48:07 +01:00
dst_cache.c wireguard: device: reset peer src endpoint when netns exits 2021-12-08 09:03:22 +01:00
failover.c
fib_notifier.c
fib_rules.c ipv6: fix memory leak in fib6_rule_suppress 2021-12-08 09:03:21 +01:00
filter.c bpf: net: Change sk_getsockopt() to take the sockptr_t argument 2024-03-15 10:48:20 -04:00
flow_dissector.c net/ipv6: SKB symmetric hash should incorporate transport ports 2023-09-19 12:20:23 +02:00
flow_offload.c netfilter: nf_tables: bail out early if hardware offload is not supported 2022-06-14 18:32:40 +02:00
gen_estimator.c
gen_stats.c
gro_cells.c net: Fix data-races around netdev_max_backlog. 2022-08-31 17:15:19 +02:00
hwbm.c
link_watch.c net: linkwatch: fix failure to restore device state across suspend/resume 2021-08-18 08:59:13 +02:00
lwt_bpf.c lwt: Fix return values of BPF xmit ops 2023-09-19 12:20:09 +02:00
lwtunnel.c lwtunnel: Validate RTA_ENCAP_TYPE attribute length 2022-01-11 15:25:00 +01:00
neighbour.c neighbour: Don't let neigh_forced_gc() disable preemption for long 2024-01-25 14:37:37 -08:00
net-procfs.c net-procfs: show net devices bound packet types 2022-02-01 17:25:44 +01:00
net-sysfs.c net-sysfs: add check for netdevice being present to speed_show 2022-03-16 14:16:00 +01:00
net-sysfs.h
net-traces.c
net_namespace.c net: fix out-of-bounds access in ops_init 2024-05-17 11:48:10 +02:00
netclassid_cgroup.c
netevent.c
netpoll.c net: don't let netpoll invoke NAPI if in xmit context 2023-04-20 12:10:21 +02:00
netprio_cgroup.c
page_pool.c
pktgen.c net: pktgen: Fix interface flags printing 2023-10-25 11:54:20 +02:00
ptp_classifier.c
request_sock.c tcp: make sure init the accept_queue's spinlocks once 2024-02-23 08:41:55 +01:00
rtnetlink.c rtnetlink: Correct nested IFLA_VF_VLAN_LIST attribute validation 2024-05-17 11:48:07 +02:00
scm.c io_uring/unix: drop usage of io_uring socket 2024-03-26 18:21:45 -04:00
secure_seq.c tcp: Fix data-races around sysctl knobs related to SYN option. 2022-07-29 17:19:21 +02:00
skbuff.c kcov: Remove kcov include from sched.h and move it to its users. 2024-05-17 11:48:07 +02:00
skmsg.c net: fix refcount bug in sk_psock_get (2) 2022-09-05 10:28:56 +02:00
sock.c net: mark racy access on sk->sk_rcvbuf 2024-05-17 11:48:03 +02:00
sock_diag.c sock_diag: annotate data-races around sock_diag_handlers[family] 2024-03-26 18:21:49 -04:00
sock_map.c bpf, sockmap: Prevent lock inversion deadlock in map delete elem 2024-04-13 12:59:25 +02:00
sock_reuseport.c udp: Update reuse->has_conns under reuseport_lock. 2022-10-30 09:41:19 +01:00
stream.c net: deal with most data-races in sk_wait_event() 2023-05-30 12:57:46 +01:00
sysctl_net_core.c net: Fix data-races around weight_p and dev_weight_[rt]x_bias. 2022-08-31 17:15:19 +02:00
timestamping.c
tso.c
utils.c
xdp.c