diff mbox series

[1/2] ethtool: strset: allow ETHTOOL_A_STRSET_COUNTS_ONLY attr

Message ID 20201007125348.a0b250308599.Ie9b429e276d064f28ce12db01fffa430e5c770e0@changeid (mailing list archive)
State Not Applicable
Headers show
Series [1/2] ethtool: strset: allow ETHTOOL_A_STRSET_COUNTS_ONLY attr | expand

Commit Message

Johannes Berg Oct. 7, 2020, 10:53 a.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

The ETHTOOL_A_STRSET_COUNTS_ONLY flag attribute was previously
not allowed to be used, but now due to the policy size reduction
we would access the tb[] array out of bounds since we tried to
check for the attribute despite it not being accepted.

Fix both issues by adding it correctly to the appropriate policy.

Fixes: ff419afa4310 ("ethtool: trim policy tables")
Fixes: 71921690f974 ("ethtool: provide string sets with STRSET_GET request")
Reported-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/ethtool/netlink.h | 2 +-
 net/ethtool/strset.c  | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

Comments

Leon Romanovsky Oct. 7, 2020, 11:19 a.m. UTC | #1
On Wed, Oct 07, 2020 at 12:53:50PM +0200, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
>
> The ETHTOOL_A_STRSET_COUNTS_ONLY flag attribute was previously
> not allowed to be used, but now due to the policy size reduction
> we would access the tb[] array out of bounds since we tried to
> check for the attribute despite it not being accepted.
>
> Fix both issues by adding it correctly to the appropriate policy.
>
> Fixes: ff419afa4310 ("ethtool: trim policy tables")
> Fixes: 71921690f974 ("ethtool: provide string sets with STRSET_GET request")
> Reported-by: Leon Romanovsky <leon@kernel.org>
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
>  net/ethtool/netlink.h | 2 +-
>  net/ethtool/strset.c  | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
>

Thanks,
Tested-by: Leon Romanovsky <leonro@nvidia.com>
Jakub Kicinski Oct. 7, 2020, 3:12 p.m. UTC | #2
On Wed,  7 Oct 2020 12:53:50 +0200 Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> The ETHTOOL_A_STRSET_COUNTS_ONLY flag attribute was previously
> not allowed to be used, but now due to the policy size reduction
> we would access the tb[] array out of bounds since we tried to
> check for the attribute despite it not being accepted.
> 
> Fix both issues by adding it correctly to the appropriate policy.
> 
> Fixes: ff419afa4310 ("ethtool: trim policy tables")
> Fixes: 71921690f974 ("ethtool: provide string sets with STRSET_GET request")
> Reported-by: Leon Romanovsky <leon@kernel.org>
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Jakub Kicinski Oct. 8, 2020, 11:20 p.m. UTC | #3
On Wed,  7 Oct 2020 12:53:50 +0200 Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> The ETHTOOL_A_STRSET_COUNTS_ONLY flag attribute was previously
> not allowed to be used, but now due to the policy size reduction
> we would access the tb[] array out of bounds since we tried to
> check for the attribute despite it not being accepted.
> 
> Fix both issues by adding it correctly to the appropriate policy.
> 
> Fixes: ff419afa4310 ("ethtool: trim policy tables")
> Fixes: 71921690f974 ("ethtool: provide string sets with STRSET_GET request")
> Reported-by: Leon Romanovsky <leon@kernel.org>
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Applied both, thanks!
diff mbox series

Patch

diff --git a/net/ethtool/netlink.h b/net/ethtool/netlink.h
index 3f5719786b0f..d8efec516d86 100644
--- a/net/ethtool/netlink.h
+++ b/net/ethtool/netlink.h
@@ -347,7 +347,7 @@  extern const struct ethnl_request_ops ethnl_tsinfo_request_ops;
 
 extern const struct nla_policy ethnl_header_policy[ETHTOOL_A_HEADER_FLAGS + 1];
 extern const struct nla_policy ethnl_header_policy_stats[ETHTOOL_A_HEADER_FLAGS + 1];
-extern const struct nla_policy ethnl_strset_get_policy[ETHTOOL_A_STRSET_STRINGSETS + 1];
+extern const struct nla_policy ethnl_strset_get_policy[ETHTOOL_A_STRSET_COUNTS_ONLY + 1];
 extern const struct nla_policy ethnl_linkinfo_get_policy[ETHTOOL_A_LINKINFO_HEADER + 1];
 extern const struct nla_policy ethnl_linkinfo_set_policy[ETHTOOL_A_LINKINFO_TP_MDIX_CTRL + 1];
 extern const struct nla_policy ethnl_linkmodes_get_policy[ETHTOOL_A_LINKMODES_HEADER + 1];
diff --git a/net/ethtool/strset.c b/net/ethtool/strset.c
index 0734e83c674c..0baad0ce1832 100644
--- a/net/ethtool/strset.c
+++ b/net/ethtool/strset.c
@@ -103,6 +103,7 @@  const struct nla_policy ethnl_strset_get_policy[] = {
 	[ETHTOOL_A_STRSET_HEADER]	=
 		NLA_POLICY_NESTED(ethnl_header_policy),
 	[ETHTOOL_A_STRSET_STRINGSETS]	= { .type = NLA_NESTED },
+	[ETHTOOL_A_STRSET_COUNTS_ONLY]	= { .type = NLA_FLAG },
 };
 
 static const struct nla_policy get_stringset_policy[] = {