android_kernel_motorola_sm6225/net/sched
Peilin Ye 9988941715 net/sched: sch_netem: Fix arithmetic in netem_dump() for 32-bit platforms
[ Upstream commit a2b1a5d40bd12b44322c2ccd40bb0ec1699708b6 ]

As reported by Yuming, currently tc always show a latency of UINT_MAX
for netem Qdisc's on 32-bit platforms:

    $ tc qdisc add dev dummy0 root netem latency 100ms
    $ tc qdisc show dev dummy0
    qdisc netem 8001: root refcnt 2 limit 1000 delay 275s  275s
                                               ^^^^^^^^^^^^^^^^

Let us take a closer look at netem_dump():

        qopt.latency = min_t(psched_tdiff_t, PSCHED_NS2TICKS(q->latency,
                             UINT_MAX);

qopt.latency is __u32, psched_tdiff_t is signed long,
(psched_tdiff_t)(UINT_MAX) is negative for 32-bit platforms, so
qopt.latency is always UINT_MAX.

Fix it by using psched_time_t (u64) instead.

Note: confusingly, users have two ways to specify 'latency':

  1. normally, via '__u32 latency' in struct tc_netem_qopt;
  2. via the TCA_NETEM_LATENCY64 attribute, which is s64.

For the second case, theoretically 'latency' could be negative.  This
patch ignores that corner case, since it is broken (i.e. assigning a
negative s64 to __u32) anyways, and should be handled separately.

Thanks Ted Lin for the analysis [1] .

[1] https://github.com/raspberrypi/linux/issues/3512

Reported-by: Yuming Chen <chenyuming.junnan@bytedance.com>
Fixes: 112f9cb656 ("netem: convert to qdisc_watchdog_schedule_ns")
Reviewed-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Link: https://lore.kernel.org/r/20220616234336.2443-1-yepeilin.cs@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-07-02 16:27:32 +02:00
..
act_api.c net: sched: limit TC_ACT_REPEAT loops 2022-02-23 11:58:41 +01:00
act_bpf.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:33:39 +01:00
act_connmark.c sched: consistently handle layer3 header accesses in the presence of VLANs 2020-07-22 09:32:00 +02:00
act_csum.c sched: consistently handle layer3 header accesses in the presence of VLANs 2020-07-22 09:32:00 +02:00
act_gact.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:33:39 +01:00
act_ife.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:33:39 +01:00
act_ipt.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:33:39 +01:00
act_meta_mark.c
act_meta_skbprio.c
act_meta_skbtcindex.c
act_mirred.c act_mirred: Fix mirred_init_module error handling 2020-01-27 14:51:18 +01:00
act_nat.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:33:39 +01:00
act_pedit.c net/sched: act_pedit: sanitize shift argument before usage 2022-05-25 09:10:39 +02:00
act_police.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:33:39 +01:00
act_sample.c net/sched: act_sample: don't push mac header on ip6gre ingress 2019-10-05 13:09:28 +02:00
act_simple.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:33:39 +01:00
act_skbedit.c sched: consistently handle layer3 header accesses in the presence of VLANs 2020-07-22 09:32:00 +02:00
act_skbmod.c net/sched: act_skbmod: Skip non-Ethernet packets 2021-07-28 11:13:48 +02:00
act_tunnel_key.c net/sched: act_tunnel_key: fix OOB write in case of IPv6 ERSPAN tunnels 2020-10-29 09:54:58 +01:00
act_vlan.c net_sched: fix a NULL pointer deref in ipt action 2019-09-10 10:33:39 +01:00
cls_api.c net_sched: fix a crash in tc_new_tfilter() 2021-12-14 10:18:10 +01:00
cls_basic.c net_sched: fix ops->bind_class() implementations 2020-02-01 09:37:06 +00:00
cls_bpf.c net_sched: fix ops->bind_class() implementations 2020-02-01 09:37:06 +00:00
cls_cgroup.c
cls_flow.c sched: consistently handle layer3 header accesses in the presence of VLANs 2020-07-22 09:32:00 +02:00
cls_flower.c net/sched: flower: fix parsing of ethertype following VLAN header 2022-04-20 09:12:48 +02:00
cls_fw.c net_sched: fix ops->bind_class() implementations 2020-02-01 09:37:06 +00:00
cls_matchall.c net/sched: matchall: add missing validation of TCA_MATCHALL_FLAGS 2020-02-24 08:34:34 +01:00
cls_route.c net_sched: cls_route: remove the right filter from hashtable 2020-04-02 15:28:11 +02:00
cls_rsvp.c
cls_rsvp.h cls_rsvp: fix rsvp_policy 2020-02-11 04:33:52 -08:00
cls_rsvp6.c
cls_tcindex.c net: sched: fix warning in tcindex_alloc_perfect_hash 2021-07-20 16:15:53 +02:00
cls_u32.c net/sched: cls_u32: fix netns refcount changes in u32_change() 2022-05-01 17:00:35 +02:00
em_canid.c
em_cmp.c
em_ipset.c sched: consistently handle layer3 header accesses in the presence of VLANs 2020-07-22 09:32:00 +02:00
em_ipt.c
em_meta.c sched: consistently handle layer3 header accesses in the presence of VLANs 2020-07-22 09:32:00 +02:00
em_nbyte.c
em_text.c
em_u32.c
ematch.c net_sched: ematch: reject invalid TCF_EM_SIMPLE 2020-02-01 09:37:05 +00:00
Kconfig net/sched: add skbprio scheduler 2018-07-24 14:44:00 -07:00
Makefile net/sched: add skbprio scheduler 2018-07-24 14:44:00 -07:00
sch_api.c net: sched: Clarify error message when qdisc kind is unknown 2022-02-16 12:51:44 +01:00
sch_atm.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_blackhole.c
sch_cake.c sch_cake: do not call cake_destroy() from cake_init() 2021-12-22 09:19:01 +01:00
sch_cbq.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_cbs.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_choke.c net: sched: validate stab values 2021-03-30 14:37:03 +02:00
sch_codel.c net: sched: Fix a possible null-pointer dereference in dequeue_func() 2019-08-09 17:52:32 +02:00
sch_drr.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_dsmark.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_etf.c sched: etf: do not assume all sockets are full blown 2020-04-29 16:31:21 +02:00
sch_fifo.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_fq.c net: fq: add missing attribute validation for orphan mask 2020-03-18 07:14:16 +01:00
sch_fq_codel.c fq_codel: reject silly quantum parameters 2021-09-22 11:48:14 +02:00
sch_generic.c net_sched: restore "mpu xxx" handling 2022-01-27 09:04:33 +01:00
sch_gred.c net: sched: validate stab values 2021-03-30 14:37:03 +02:00
sch_hfsc.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_hhf.c net/flow_dissector: switch to siphash 2019-11-10 11:27:54 +01:00
sch_htb.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_ingress.c
sch_mq.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_mqprio.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_multiq.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_netem.c net/sched: sch_netem: Fix arithmetic in netem_dump() for 32-bit platforms 2022-07-02 16:27:32 +02:00
sch_pie.c
sch_plug.c
sch_prio.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_qfq.c sch_qfq: prevent shift-out-of-bounds in qfq_init_qdisc 2022-01-11 13:58:49 +01:00
sch_red.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_sfb.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_sfq.c net: sched: validate stab values 2021-03-30 14:37:03 +02:00
sch_skbprio.c net_sched: sch_skbprio: add message validation to skbprio_change() 2020-05-14 07:57:17 +02:00
sch_tbf.c net: sched: rename qdisc_destroy() to qdisc_put() 2021-12-14 10:18:04 +01:00
sch_teql.c net: sched: sch_teql: fix null-pointer dereference 2021-04-14 08:22:33 +02:00