kernel-fxtec-pro1x/net/core
Chinmay Agarwal e786a31cce net/sched: fix race between deactivation and dequeue for NOLOCK qdisc
The test implemented by some_qdisc_is_busy() is somewhat loosy for
NOLOCK qdisc, as we may hit the following scenario :

CPU1						CPU2
// in net_tx_action()
clear_bit(__QDISC_STATE_SCHED...);
					// in some_qdisc_is_busy()
					val = (qdisc_is_running(q) ||
					     test_bit(__QDISC_STATE_SCHED,
							&q->state));
					// here val is 0 but...
qdisc_run(q)
// ... CPU1 is going to run the qdisc next

As a conseguence qdisc_run() in net_tx_action() can race with
qdisc_reset() in dev_qdisc_reset(). Such race is not possible for !NOLOCK
qdisc as both the above bit operations are under the root qdisc lock().

After commit 021a17ed79 ("pfifo_fast: drop unneeded additional lock on
dequeue") the race can cause use after free and/or null ptr dereference,
but the root cause is likely older.

This patch addresses the issue explicitly checking for deactivation under
the seqlock for NOLOCK qdisc, so that the qdisc_run() in the critical
scenario becomes a no-op.

Note that the enqueue() op can still execute concurrently with
dev_qdisc_reset(), but that is safe due to the skb_array() locking, and
we can't avoid that for NOLOCK qdiscs.

Fixes: 021a17ed79 ("pfifo_fast: drop unneeded additional lock on
			dequeue")
Reported-by: Li Shuang <shuali@redhat.com>
Reported-and-tested-by: Davide Caratti <dcaratti@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

(Backported from commit d518d2ed8640c1cbbbb6f63939e3e65471817367).

Git-Commit: d518d2ed8640c1cbbbb6f63939e3e65471817367
Git-repo: https://android.googlesource.com/kernel/common/
Change-Id: Id4e048bd00ea0d9be49f98958e648c74af965e12
Signed-off-by: Chinmay Agarwal <chinagar@codeaurora.org>
2021-03-15 21:01:16 +05:30
..
datagram.c net: add READ_ONCE() annotation in __skb_wait_for_more_packets() 2019-11-10 11:27:49 +01:00
dev.c net/sched: fix race between deactivation and dequeue for NOLOCK qdisc 2021-03-15 21:01:16 +05:30
dev_addr_lists.c
dev_ioctl.c net: remove redundant input checks in SIOCSIFTXQLEN case of dev_ifsioc 2018-07-24 11:36:15 -07:00
devlink.c devlink: validate length of region addr/len 2020-03-18 07:14:18 +01:00
drop_monitor.c drop_monitor: work around gcc-10 stringop-overflow warning 2020-05-20 08:18:33 +02:00
dst.c netfilter: nf_tables: add tunnel support 2018-08-03 21:12:12 +02:00
dst_cache.c
ethtool.c ethtool: reduce stack usage with clang 2020-01-17 19:46:55 +01:00
failover.c failover: allow name change on IFF_UP slave interfaces 2019-04-27 09:36:30 +02:00
fib_notifier.c
fib_rules.c net: fib_rules: Correctly set table field when table number exceeds 8 bits 2020-03-05 16:42:15 +01:00
filter.c This is the 4.19.149 stable release 2020-10-01 16:49:05 +02:00
flow_dissector.c net: dsa: fix flow dissection on Tx path 2019-12-21 10:57:11 +01:00
gen_estimator.c net: core: protect rate estimator statistics pointer with lock 2018-08-11 12:37:10 -07:00
gen_stats.c net: sched: put back q.qlen into a single location 2019-03-10 07:17:16 +01:00
gro_cells.c gro_cells: make sure device is up in gro_cells_receive() 2019-03-19 13:12:38 +01:00
hwbm.c
link_watch.c
lwt_bpf.c bpf: in __bpf_redirect_no_mac pull mac only if present 2019-01-22 21:40:35 +01:00
lwtunnel.c
Makefile net: Add snapshot of sockev module 2019-03-01 12:40:58 +05:30
neighbour.c Merge android-4.19-stable.149 (9ce79d9) into msm-4.19 2020-10-21 09:25:49 +05:30
net-procfs.c net: add a per-cpu counter for the number of frames coalesced in GRO 2018-10-29 16:33:33 -06:00
net-sysfs.c net-sysfs: add a newline when printing 'tx_timeout' by sysfs 2020-07-31 18:37:47 +02:00
net-sysfs.h
net-traces.c ANDROID: Unconditionally create bridge tracepoints 2020-03-04 07:57:47 +00:00
net_namespace.c net/net_namespace: Check the return value of register_pernet_subsys() 2019-12-05 09:20:51 +01:00
netclassid_cgroup.c cgroup, netclassid: remove double cond_resched 2020-05-10 10:30:12 +02:00
netevent.c
netpoll.c net: disable netpoll on fresh napis 2020-09-12 13:40:23 +02:00
netprio_cgroup.c netprio_cgroup: Fix unlimited memory leak of v2 cgroups 2020-05-20 08:18:38 +02:00
page_pool.c net/page_pool: Fix inconsistent lock state warning 2018-07-19 23:23:01 -07:00
pktgen.c pktgen: do not sleep with the thread lock held. 2019-06-11 12:20:49 +02:00
ptp_classifier.c
request_sock.c
rtnetlink.c rtnetlink: Fix memory(net_device) leak when ->newlink fails 2020-07-31 18:37:49 +02:00
scm.c
secure_seq.c infiniband: i40iw, nes: don't use wall time for TCP sequence numbers 2018-07-11 12:10:19 -06:00
skbuff.c Merge "Merge android-4.19-stable.152 (13abe23) into msm-4.19" 2020-11-10 06:31:20 -08:00
sock.c This is the 4.19.141 stable release 2020-08-21 13:01:46 +02:00
sock_diag.c net: sock_diag: Fix spectre v1 gadget in __sock_diag_cmd() 2018-08-14 10:01:24 -07:00
sock_reuseport.c udp: Copy has_conns in reuseport_grow(). 2020-07-31 18:37:48 +02:00
sockev_nlmcast.c net: sockev: avoid races between sockev and socket_close 2019-05-21 11:09:21 -07:00
stream.c tcp: make sure EPOLLOUT wont be missed 2019-09-06 10:22:07 +02:00
sysctl_net_core.c bpf: Check correct cred for CAP_SYSLOG in bpf_dump_raw_ok() 2020-07-16 08:17:27 +02:00
timestamping.c
tso.c
utils.c net: Fix skb->csum update in inet_proto_csum_replace16(). 2020-02-05 14:43:53 +00:00
xdp.c net/xdp: Fix suspicious RCU usage warning 2018-08-16 21:55:21 +02:00