iproute2/tc
Stephen Hemminger c90d25e96b tc/prio: handle possible truncated kernel response
Reported by -fanalyzer. If kernel did not send full qdisc
info, then uninitialized or null data could be referenced.

q_prio.c: In function ‘prio_print_opt’:
q_prio.c:105:57: warning: dereference of NULL ‘0’ [CWE-476] [-Wanalyzer-null-dereference]
  105 |         print_uint(PRINT_ANY, "bands", "bands %u ", qopt->bands);
      |                                                     ~~~~^~~~~~~
  ‘prio_print_opt’: event 1
    |
    |   98 |         if (opt == NULL)
    |      |            ^
    |      |            |
    |      |            (1) following ‘false’ branch (when ‘opt’ is non-NULL)...
    |
  ‘prio_print_opt’: event 2
    |
    |../include/uapi/linux/rtnetlink.h:228:38:
    |  228 | #define RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - RTA_LENGTH(0))
    |      |                                ~~~~~~^~~~~~~~~~
    |      |                                      |
    |      |                                      (2) ...to here
../include/libnetlink.h:236:19: note: in expansion of macro ‘RTA_PAYLOAD’
    |  236 |         ({ data = RTA_PAYLOAD(rta) >= len ? RTA_DATA(rta) : NULL;       \
    |      |                   ^~~~~~~~~~~
q_prio.c:101:13: note: in expansion of macro ‘parse_rtattr_nested_compat’
    |  101 |         if (parse_rtattr_nested_compat(tb, TCA_PRIO_MAX, opt, qopt,
    |      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~
    |
  ‘prio_print_opt’: event 3
    |
    |../include/libnetlink.h:236:59:
    |  236 |         ({ data = RTA_PAYLOAD(rta) >= len ? RTA_DATA(rta) : NULL;       \
q_prio.c:101:13: note: in expansion of macro ‘parse_rtattr_nested_compat’
    |  101 |         if (parse_rtattr_nested_compat(tb, TCA_PRIO_MAX, opt, qopt,
    |      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~
    |
  ‘prio_print_opt’: events 4-5
    |
    |  105 |         print_uint(PRINT_ANY, "bands", "bands %u ", qopt->bands);
    |      |                                                     ~~~~^~~~~~~
    |      |                                                         |
    |      |                                                         (4) ...to here
    |      |                                                         (5) dereference of NULL ‘<unknown>’
    |

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2023-05-13 19:02:41 -07:00
..
.gitignore make yacc usage POSIX compatible 2020-01-20 09:43:22 -08:00
e_bpf.c tc: use SPDX 2023-01-14 09:00:34 -08:00
em_canid.c tc: use SPDX 2023-01-14 09:00:34 -08:00
em_cmp.c tc: use SPDX 2023-01-14 09:00:34 -08:00
em_ipset.c tc: use SPDX 2023-01-14 09:00:34 -08:00
em_ipt.c tc: use SPDX 2023-01-14 09:00:34 -08:00
em_meta.c tc: use SPDX 2023-01-14 09:00:34 -08:00
em_nbyte.c tc: use SPDX 2023-01-14 09:00:34 -08:00
em_u32.c tc: use SPDX 2023-01-14 09:00:34 -08:00
emp_ematch.l make yacc usage POSIX compatible 2020-01-20 09:43:22 -08:00
emp_ematch.y tc: use SPDX 2023-01-14 09:00:34 -08:00
f_basic.c tc: use SPDX 2023-01-14 09:00:34 -08:00
f_bpf.c tc: use SPDX 2023-01-14 09:00:34 -08:00
f_cgroup.c tc: use SPDX 2023-01-14 09:00:34 -08:00
f_flow.c tc: use SPDX 2023-01-14 09:00:34 -08:00
f_flower.c tc: use SPDX 2023-01-14 09:00:34 -08:00
f_fw.c tc: use SPDX 2023-01-14 09:00:34 -08:00
f_matchall.c tc: use SPDX 2023-01-14 09:00:34 -08:00
f_route.c tc: use SPDX 2023-01-14 09:00:34 -08:00
f_rsvp.c tc: use SPDX 2023-01-14 09:00:34 -08:00
f_tcindex.c treewide: refactor help messages 2019-05-20 14:35:07 -07:00
f_u32.c tc: f_u32: fix json object leak 2023-03-05 08:35:57 -08:00
m_action.c m_action: fix warning of overwrite of const string 2023-05-13 19:02:41 -07:00
m_bpf.c tc: use SPDX 2023-01-14 09:00:34 -08:00
m_connmark.c tc: use SPDX 2023-01-14 09:00:34 -08:00
m_csum.c tc: m_csum: parse index argument correctly 2023-03-05 08:49:32 -08:00
m_ct.c tc: m_ct: add support for helper 2023-02-18 10:07:10 -07:00
m_ctinfo.c tc: skip actions that don't have options attribute when printing 2020-10-31 09:14:01 -06:00
m_ematch.c tc: use SPDX 2023-01-14 09:00:34 -08:00
m_ematch.h tc/ematch: make local functions static 2018-11-19 11:42:44 -08:00
m_estimator.c tc: use SPDX 2023-01-14 09:00:34 -08:00
m_gact.c tc: use SPDX 2023-01-14 09:00:34 -08:00
m_gate.c tc: m_gate: use SPRINT_BUF when needed 2021-02-22 18:11:03 -08:00
m_ife.c tc: use SPDX 2023-01-14 09:00:34 -08:00
m_ipt.c remove unnecessary checks for NULL before calling free() 2023-05-10 08:16:40 -07:00
m_mirred.c tc: use SPDX 2023-01-14 09:00:34 -08:00
m_mpls.c tc: m_mpls: parse index argument correctly 2023-03-05 08:49:32 -08:00
m_nat.c tc: m_nat: parse index argument correctly 2023-03-05 08:49:32 -08:00
m_pedit.c tc: use SPDX 2023-01-14 09:00:34 -08:00
m_pedit.h tc: use SPDX 2023-01-14 09:00:34 -08:00
m_police.c tc: use SPDX 2023-01-14 09:00:34 -08:00
m_sample.c tc: use SPDX 2023-01-14 09:00:34 -08:00
m_simple.c tc: use SPDX 2023-01-14 09:00:34 -08:00
m_skbedit.c tc: use SPDX 2023-01-14 09:00:34 -08:00
m_skbmod.c tc: use SPDX 2023-01-14 09:00:34 -08:00
m_tunnel_key.c tc: m_tunnel_key: support code for "nofrag" tunnels 2023-04-07 09:37:32 -06:00
m_vlan.c tc: use SPDX 2023-01-14 09:00:34 -08:00
m_xt_old.c remove unnecessary checks for NULL before calling free() 2023-05-10 08:16:40 -07:00
m_xt.c remove unnecessary checks for NULL before calling free() 2023-05-10 08:16:40 -07:00
Makefile tc: remove support for rr qdisc 2023-01-11 09:14:29 -08:00
p_eth.c tc: use SPDX 2023-01-14 09:00:34 -08:00
p_icmp.c tc: use SPDX 2023-01-14 09:00:34 -08:00
p_ip6.c tc: use SPDX 2023-01-14 09:00:34 -08:00
p_ip.c tc: use SPDX 2023-01-14 09:00:34 -08:00
p_tcp.c tc: use SPDX 2023-01-14 09:00:34 -08:00
p_udp.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_atm.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_cake.c q_cake: allow changing to diffserv3 2022-01-12 15:26:11 -08:00
q_cbq.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_cbs.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_choke.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_clsact.c SPDX license identifiers 2017-11-24 12:21:35 -08:00
q_codel.c tc: replace GPL-BSD boilerplate in codel and fq 2023-01-14 09:00:34 -08:00
q_drr.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_dsmark.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_etf.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_ets.c tc: q_ets: drop dead code from argument parsing 2021-05-06 14:42:44 +00:00
q_fifo.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_fq_codel.c tc: replace GPL-BSD boilerplate in codel and fq 2023-01-14 09:00:34 -08:00
q_fq_pie.c lib: Move sprint_size() from tc here, add print_size() 2020-12-09 02:30:25 +00:00
q_fq.c tc: replace GPL-BSD boilerplate in codel and fq 2023-01-14 09:00:34 -08:00
q_gred.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_hfsc.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_hhf.c lib: Move sprint_size() from tc here, add print_size() 2020-12-09 02:30:25 +00:00
q_htb.c tc/htb: add SPDX comment 2023-01-09 13:39:27 -08:00
q_ingress.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_mqprio.c tc/mqprio: add support for preemptible traffic classes 2023-04-24 19:42:33 -06:00
q_multiq.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_netem.c netem: fix NULL deref on allocation failure 2023-05-13 19:02:41 -07:00
q_pie.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_plug.c tc: add support for plug qdisc 2019-05-04 09:22:14 -07:00
q_prio.c tc/prio: handle possible truncated kernel response 2023-05-13 19:02:41 -07:00
q_qfq.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_red.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_sfb.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_sfq.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_skbprio.c tc: use SPDX 2023-01-14 09:00:34 -08:00
q_taprio.c tc/taprio: add support for preemptible traffic classes 2023-04-24 19:43:26 -06:00
q_tbf.c tc: use SPDX 2023-01-14 09:00:34 -08:00
static-syms.c SPDX license identifiers 2017-11-24 12:21:35 -08:00
tc_cbq.c tc: use SPDX 2023-01-14 09:00:34 -08:00
tc_cbq.h SPDX license identifiers 2017-11-24 12:21:35 -08:00
tc_class.c iproute2: optimize code and fix some mem-leak risk 2023-05-11 14:15:12 -07:00
tc_common.h tc: add json support to size table 2022-11-22 20:46:57 -08:00
tc_core.c tc: use SPDX 2023-01-14 09:00:34 -08:00
tc_core.h iproute2-next: police: support 64bit rate and peakrate in tc utility 2019-09-15 10:39:19 -07:00
tc_estimator.c tc: use SPDX 2023-01-14 09:00:34 -08:00
tc_exec.c tc_exec: don't dereference NULL on calloc failure 2023-05-13 19:02:41 -07:00
tc_filter.c tc_filter: fix unitialized warning 2023-05-13 19:02:41 -07:00
tc_monitor.c Revert "tc/tc_monitor: print netlink extack message" 2023-01-22 11:00:14 -07:00
tc_qdisc.c iproute2: optimize code and fix some mem-leak risk 2023-05-11 14:15:12 -07:00
tc_qevent.c tc: Add space after format specifier 2020-07-29 17:03:46 +00:00
tc_qevent.h tc: Look for blocks in qevents 2020-07-20 16:34:02 +00:00
tc_red.c tc: use SPDX 2023-01-14 09:00:34 -08:00
tc_red.h tc: move RED flag printing to helper 2018-11-24 07:10:58 -08:00
tc_stab.c tc: use SPDX 2023-01-14 09:00:34 -08:00
tc_util.c tc_util fix unitialized warning 2023-05-13 19:02:41 -07:00
tc_util.h tc: add new attr TCA_EXT_WARN_MSG 2023-01-22 11:01:11 -07:00
tc.c tc: use SPDX 2023-01-14 09:00:34 -08:00