From ee037ea1bbe3e9134eab3586bbd54613f39a1693 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Sun, 23 Dec 2018 22:12:36 +0000
Subject: [PATCH 09/27] rtnl_link: fix off-by-one errors in indexed and sorted
xlat lookups
* rtnl_link.c (decode_nla_tun_type, decode_ifla_xdp_attached,
decode_ifla_inet_conf, decode_ifla_inet6_flags, decode_ifla_inet6_conf,
decode_ifla_inet6_stats, decode_ifla_inet6_icmp6_stats,
decode_ifla_inet6_agm): Decrement xlat size by one to account
for XLAT_END as other users of indexed and sorted xlats do.
Fixes: v4.25~71 "rtnl_link: decode named constants for IFLA_XDP_ATTACHED attribute value"
Fixes: v4.23~41 "rtnl_link: decode IFLA_AF_SPEC"
Fixes: v4.23~37 "rtnl_link: implement IFLA_INFO_DATA for tun devices"
Conflicts:
rtnl_link.c
---
rtnl_link.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/rtnl_link.c b/rtnl_link.c
index 1fbfd26..8e02bc7 100644
--- a/rtnl_link.c
+++ b/rtnl_link.c
@@ -356,7 +356,7 @@ decode_nla_tun_type(struct tcb *const tcp,
{
const struct decode_nla_xlat_opts opts = {
.xlat = tun_device_types,
- .xlat_size = ARRAY_SIZE(tun_device_types),
+ .xlat_size = ARRAY_SIZE(tun_device_types) - 1,
.xt = XT_INDEXED,
.dflt = "IFF_???",
.size = 1,
@@ -626,7 +626,8 @@ decode_ifla_inet_conf(struct tcb *const tcp,
print_array_ex(tcp, addr, cnt, &elem, sizeof(elem),
tfetch_mem, print_int32_array_member, NULL,
PAF_PRINT_INDICES | PAF_INDEX_XLAT_VALUE_INDEXED
- | XLAT_STYLE_FMT_D, ARRSZ_PAIR(inet_devconf_indices),
+ | XLAT_STYLE_FMT_D,
+ ARRSZ_PAIR(inet_devconf_indices) - 1,
"IPV4_DEVCONF_???");
return true;
@@ -643,7 +644,7 @@ decode_ifla_inet6_flags(struct tcb *const tcp,
const void *const opaque_data)
{
const struct decode_nla_xlat_opts opts = {
- ARRSZ_PAIR(inet6_if_flags), "IF_???",
+ ARRSZ_PAIR(inet6_if_flags) - 1, "IF_???",
.size = 4,
};
@@ -665,7 +666,8 @@ decode_ifla_inet6_conf(struct tcb *const tcp,
print_array_ex(tcp, addr, cnt, &elem, sizeof(elem),
tfetch_mem, print_int32_array_member, NULL,
PAF_PRINT_INDICES | PAF_INDEX_XLAT_VALUE_INDEXED
- | XLAT_STYLE_FMT_D, ARRSZ_PAIR(inet6_devconf_indices),
+ | XLAT_STYLE_FMT_D,
+ ARRSZ_PAIR(inet6_devconf_indices) - 1,
"DEVCONF_???");
return true;
@@ -686,7 +688,7 @@ decode_ifla_inet6_stats(struct tcb *const tcp,
print_array_ex(tcp, addr, cnt, &elem, sizeof(elem),
tfetch_mem, print_uint64_array_member, NULL,
PAF_PRINT_INDICES | PAF_INDEX_XLAT_VALUE_INDEXED
- | XLAT_STYLE_FMT_U, ARRSZ_PAIR(snmp_ip_stats),
+ | XLAT_STYLE_FMT_U, ARRSZ_PAIR(snmp_ip_stats) - 1,
"IPSTATS_MIB_???");
return true;
@@ -733,7 +735,7 @@ decode_ifla_inet6_icmp6_stats(struct tcb *const tcp,
print_array_ex(tcp, addr, cnt, &elem, sizeof(elem),
tfetch_mem, print_uint64_array_member, NULL,
PAF_PRINT_INDICES | PAF_INDEX_XLAT_VALUE_INDEXED
- | XLAT_STYLE_FMT_U, ARRSZ_PAIR(snmp_icmp6_stats),
+ | XLAT_STYLE_FMT_U, ARRSZ_PAIR(snmp_icmp6_stats) - 1,
"ICMP6_MIB_???");
return true;
@@ -762,7 +764,7 @@ decode_ifla_inet6_agm(struct tcb *const tcp,
const void *const opaque_data)
{
const struct decode_nla_xlat_opts opts = {
- ARRSZ_PAIR(in6_addr_gen_mode), "IN6_ADDR_GEN_MODE_???",
+ ARRSZ_PAIR(in6_addr_gen_mode) - 1, "IN6_ADDR_GEN_MODE_???",
.xt = XT_INDEXED,
.size = 1,
};
--
2.1.4