linux-stable/net/core
Denis V. Lunev 9bbaed571c neigh: fix possible DoS due to net iface start/stop loop
[ Upstream commit 66ba215cb5 ]

Normal processing of ARP request (usually this is Ethernet broadcast
packet) coming to the host is looking like the following:
* the packet comes to arp_process() call and is passed through routing
  procedure
* the request is put into the queue using pneigh_enqueue() if
  corresponding ARP record is not local (common case for container
  records on the host)
* the request is processed by timer (within 80 jiffies by default) and
  ARP reply is sent from the same arp_process() using
  NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED condition (flag is set inside
  pneigh_enqueue())

And here the problem comes. Linux kernel calls pneigh_queue_purge()
which destroys the whole queue of ARP requests on ANY network interface
start/stop event through __neigh_ifdown().

This is actually not a problem within the original world as network
interface start/stop was accessible to the host 'root' only, which
could do more destructive things. But the world is changed and there
are Linux containers available. Here container 'root' has an access
to this API and could be considered as untrusted user in the hosting
(container's) world.

Thus there is an attack vector to other containers on node when
container's root will endlessly start/stop interfaces. We have observed
similar situation on a real production node when docker container was
doing such activity and thus other containers on the node become not
accessible.

The patch proposed doing very simple thing. It drops only packets from
the same namespace in the pneigh_queue_purge() where network interface
state change is detected. This is enough to prevent the problem for the
whole node preserving original semantics of the code.

v2:
	- do del_timer_sync() if queue is empty after pneigh_queue_purge()
v3:
	- rebase to net tree

Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: David Ahern <dsahern@kernel.org>
Cc: Yajun Deng <yajun.deng@linux.dev>
Cc: Roopa Prabhu <roopa@nvidia.com>
Cc: Christian Brauner <brauner@kernel.org>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Cc: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Cc: Konstantin Khorenko <khorenko@virtuozzo.com>
Cc: kernel@openvz.org
Cc: devel@openvz.org
Investigated-by: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-09-05 10:25:07 +02:00
..
datagram.c net: use skb_queue_empty_lockless() in busy poll contexts 2019-11-10 11:25:35 +01:00
dev.c net: Fix a data-race around netdev_budget_usecs. 2022-09-05 10:25:04 +02:00
dev_addr_lists.c net: fix uninit-value in __hw_addr_add_ex() 2018-05-16 10:10:23 +02:00
dev_ioctl.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
devlink.c devlink: Add missing genlmsg_cancel() in devlink_nl_sb_port_pool_fill() 2020-11-24 13:05:36 +01:00
drop_monitor.c drop_monitor: fix data-race in dropmon_net_event / trace_napi_poll_hit 2022-02-23 11:57:34 +01:00
dst.c net: check type when freeing metadata dst 2017-08-21 10:57:38 -07:00
dst_cache.c
ethtool.c ethtool: reduce stack usage with clang 2020-01-17 19:45:40 +01:00
fib_notifier.c net: Add module reference to FIB notifiers 2017-09-01 20:33:42 -07:00
fib_rules.c fib: Return the correct errno code 2021-06-30 08:48:47 -04:00
filter.c bpf: Enlarge offset check value to INT_MAX in bpf_skb_{load,store}_bytes 2022-06-06 08:20:58 +02:00
flow_dissector.c flow_dissector: Fix out-of-bounds warnings 2021-09-22 11:45:28 +02:00
gen_estimator.c net_sched: gen_estimator: support large ewma log 2021-02-07 14:47:40 +01:00
gen_stats.c gen_stats: Fix netlink stats dumping in the presence of padding 2018-07-25 11:25:09 +02:00
gro_cells.c gro_cells: make sure device is up in gro_cells_receive() 2019-03-19 13:13:21 +01:00
hwbm.c
link_watch.c
lwt_bpf.c bpf: in __bpf_redirect_no_mac pull mac only if present 2019-01-23 08:09:50 +01:00
lwtunnel.c ipv6: sr: define core operations for seg6local lightweight tunnel 2017-08-07 14:16:22 -07:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
neighbour.c neigh: fix possible DoS due to net iface start/stop loop 2022-09-05 10:25:07 +02:00
net-procfs.c net-procfs: show net devices bound packet types 2022-02-08 18:16:26 +01:00
net-sysfs.c net-sysfs: add check for netdevice being present to speed_show 2022-03-16 12:57:08 +01:00
net-sysfs.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
net-traces.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
net_namespace.c netns: add schedule point in ops_exit_list() 2022-01-27 09:01:00 +01:00
netclassid_cgroup.c cgroup, netclassid: remove double cond_resched 2020-05-10 10:29:03 +02:00
netevent.c
netpoll.c net: Have netpoll bring-up DSA management interface 2020-11-24 13:05:39 +01:00
netprio_cgroup.c netprio_cgroup: Fix unlimited memory leak of v2 cgroups 2020-05-20 08:17:13 +02:00
pktgen.c pktgen: fix misuse of BUG_ON() in pktgen_thread_worker() 2021-03-07 11:27:44 +01:00
ptp_classifier.c
request_sock.c
rtnetlink.c rtnetlink: make sure to refresh master_dev/m_ops in __rtnl_newlink() 2022-02-08 18:16:27 +01:00
scm.c
secure_seq.c secure_seq: use the 64 bits of the siphash for port offset calculation 2022-06-06 08:20:56 +02:00
skbuff.c net: Fix a data-race around sysctl_tstamp_allow_data. 2022-09-05 10:25:04 +02:00
sock.c net: Fix a data-race around sysctl_net_busy_read. 2022-09-05 10:25:04 +02:00
sock_diag.c net: core: fix module type in sock_diag_bind 2018-01-17 09:45:21 +01:00
sock_reuseport.c soreuseport: fix mem leak in reuseport_add_sock() 2018-02-13 10:19:48 +01:00
stream.c net: stream: don't purge sk_error_queue in sk_stream_kill_queues() 2021-11-26 11:40:30 +01:00
sysctl_net_core.c net: Fix data-races around weight_p and dev_weight_[rt]x_bias. 2022-09-05 10:25:03 +02:00
timestamping.c
tso.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
utils.c net: Fix skb->csum update in inet_proto_csum_replace16(). 2020-02-05 14:18:28 +00:00