netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ethtool: strset: allow ETHTOOL_A_STRSET_COUNTS_ONLY attr
@ 2020-10-07 10:53 Johannes Berg
  2020-10-07 10:53 ` [PATCH 2/2] ethtool: correct policy for ETHTOOL_MSG_CHANNELS_SET Johannes Berg
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Johannes Berg @ 2020-10-07 10:53 UTC (permalink / raw)
  To: netdev; +Cc: Jakub Kicinski, Leon Romanovsky, Johannes Berg

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(-)

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[] = {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] ethtool: correct policy for ETHTOOL_MSG_CHANNELS_SET
  2020-10-07 10:53 [PATCH 1/2] ethtool: strset: allow ETHTOOL_A_STRSET_COUNTS_ONLY attr Johannes Berg
@ 2020-10-07 10:53 ` Johannes Berg
  2020-10-07 11:18   ` Leon Romanovsky
  2020-10-07 15:12   ` Jakub Kicinski
  2020-10-07 11:19 ` [PATCH 1/2] ethtool: strset: allow ETHTOOL_A_STRSET_COUNTS_ONLY attr Leon Romanovsky
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 7+ messages in thread
From: Johannes Berg @ 2020-10-07 10:53 UTC (permalink / raw)
  To: netdev; +Cc: Jakub Kicinski, Leon Romanovsky, Johannes Berg

From: Johannes Berg <johannes.berg@intel.com>

This accidentally got wired up to the *get* policy instead
of the *set* policy, causing operations to be rejected. Fix
it by wiring up the correct policy instead.

Fixes: 5028588b62cb ("ethtool: wire up set policies to ops")
Reported-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/ethtool/netlink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index 8a85a4e6be9b..50d3c8896f91 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -830,8 +830,8 @@ static const struct genl_ops ethtool_genl_ops[] = {
 		.cmd	= ETHTOOL_MSG_CHANNELS_SET,
 		.flags	= GENL_UNS_ADMIN_PERM,
 		.doit	= ethnl_set_channels,
-		.policy = ethnl_channels_get_policy,
-		.maxattr = ARRAY_SIZE(ethnl_channels_get_policy) - 1,
+		.policy = ethnl_channels_set_policy,
+		.maxattr = ARRAY_SIZE(ethnl_channels_set_policy) - 1,
 	},
 	{
 		.cmd	= ETHTOOL_MSG_COALESCE_GET,
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] ethtool: correct policy for ETHTOOL_MSG_CHANNELS_SET
  2020-10-07 10:53 ` [PATCH 2/2] ethtool: correct policy for ETHTOOL_MSG_CHANNELS_SET Johannes Berg
@ 2020-10-07 11:18   ` Leon Romanovsky
  2020-10-07 15:12   ` Jakub Kicinski
  1 sibling, 0 replies; 7+ messages in thread
From: Leon Romanovsky @ 2020-10-07 11:18 UTC (permalink / raw)
  To: Johannes Berg; +Cc: netdev, Jakub Kicinski, Johannes Berg

On Wed, Oct 07, 2020 at 12:53:51PM +0200, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
>
> This accidentally got wired up to the *get* policy instead
> of the *set* policy, causing operations to be rejected. Fix
> it by wiring up the correct policy instead.
>
> Fixes: 5028588b62cb ("ethtool: wire up set policies to ops")
> Reported-by: Leon Romanovsky <leon@kernel.org>
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
>  net/ethtool/netlink.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>

Thanks,
Tested-by: Leon Romanovsky <leonro@nvidia.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] ethtool: strset: allow ETHTOOL_A_STRSET_COUNTS_ONLY attr
  2020-10-07 10:53 [PATCH 1/2] ethtool: strset: allow ETHTOOL_A_STRSET_COUNTS_ONLY attr Johannes Berg
  2020-10-07 10:53 ` [PATCH 2/2] ethtool: correct policy for ETHTOOL_MSG_CHANNELS_SET Johannes Berg
@ 2020-10-07 11:19 ` Leon Romanovsky
  2020-10-07 15:12 ` Jakub Kicinski
  2020-10-08 23:20 ` Jakub Kicinski
  3 siblings, 0 replies; 7+ messages in thread
From: Leon Romanovsky @ 2020-10-07 11:19 UTC (permalink / raw)
  To: Johannes Berg; +Cc: netdev, Jakub Kicinski, Johannes Berg

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>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] ethtool: strset: allow ETHTOOL_A_STRSET_COUNTS_ONLY attr
  2020-10-07 10:53 [PATCH 1/2] ethtool: strset: allow ETHTOOL_A_STRSET_COUNTS_ONLY attr Johannes Berg
  2020-10-07 10:53 ` [PATCH 2/2] ethtool: correct policy for ETHTOOL_MSG_CHANNELS_SET Johannes Berg
  2020-10-07 11:19 ` [PATCH 1/2] ethtool: strset: allow ETHTOOL_A_STRSET_COUNTS_ONLY attr Leon Romanovsky
@ 2020-10-07 15:12 ` Jakub Kicinski
  2020-10-08 23:20 ` Jakub Kicinski
  3 siblings, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2020-10-07 15:12 UTC (permalink / raw)
  To: Johannes Berg; +Cc: netdev, Leon Romanovsky, Johannes Berg

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>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] ethtool: correct policy for ETHTOOL_MSG_CHANNELS_SET
  2020-10-07 10:53 ` [PATCH 2/2] ethtool: correct policy for ETHTOOL_MSG_CHANNELS_SET Johannes Berg
  2020-10-07 11:18   ` Leon Romanovsky
@ 2020-10-07 15:12   ` Jakub Kicinski
  1 sibling, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2020-10-07 15:12 UTC (permalink / raw)
  To: Johannes Berg; +Cc: netdev, Leon Romanovsky, Johannes Berg

On Wed,  7 Oct 2020 12:53:51 +0200 Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> This accidentally got wired up to the *get* policy instead
> of the *set* policy, causing operations to be rejected. Fix
> it by wiring up the correct policy instead.
> 
> Fixes: 5028588b62cb ("ethtool: wire up set policies to ops")
> Reported-by: Leon Romanovsky <leon@kernel.org>
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Reviewed-by: Jakub Kicinski <kuba@kernel.org>

Thanks!

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] ethtool: strset: allow ETHTOOL_A_STRSET_COUNTS_ONLY attr
  2020-10-07 10:53 [PATCH 1/2] ethtool: strset: allow ETHTOOL_A_STRSET_COUNTS_ONLY attr Johannes Berg
                   ` (2 preceding siblings ...)
  2020-10-07 15:12 ` Jakub Kicinski
@ 2020-10-08 23:20 ` Jakub Kicinski
  3 siblings, 0 replies; 7+ messages in thread
From: Jakub Kicinski @ 2020-10-08 23:20 UTC (permalink / raw)
  To: Johannes Berg; +Cc: netdev, Leon Romanovsky, Johannes Berg

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!

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-10-08 23:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-07 10:53 [PATCH 1/2] ethtool: strset: allow ETHTOOL_A_STRSET_COUNTS_ONLY attr Johannes Berg
2020-10-07 10:53 ` [PATCH 2/2] ethtool: correct policy for ETHTOOL_MSG_CHANNELS_SET Johannes Berg
2020-10-07 11:18   ` Leon Romanovsky
2020-10-07 15:12   ` Jakub Kicinski
2020-10-07 11:19 ` [PATCH 1/2] ethtool: strset: allow ETHTOOL_A_STRSET_COUNTS_ONLY attr Leon Romanovsky
2020-10-07 15:12 ` Jakub Kicinski
2020-10-08 23:20 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).