All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amit Cohen <amcohen@nvidia.com>
To: <netdev@vger.kernel.org>
Cc: <davem@davemloft.net>, <kuba@kernel.org>, <mkubecek@suse.cz>,
	<idosch@nvidia.com>, Amit Cohen <amcohen@nvidia.com>,
	Jiri Pirko <jiri@nvidia.com>
Subject: [PATCH net] ethtool: strset: Fix reply_size value
Date: Thu, 17 Jun 2021 18:42:52 +0300	[thread overview]
Message-ID: <20210617154252.688724-1-amcohen@nvidia.com> (raw)

strset_reply_size() does not take into account the size required for the
'ETHTOOL_A_STRSET_STRINGSETS' nested attribute.
Since commit 4d1fb7cde0cc ("ethtool: add a stricter length check") this
results in the following warning in the kernel log:

ethnl cmd 1: calculated reply length 2236, but consumed 2240
WARNING: CPU: 2 PID: 30549 at net/ethtool/netlink.c:360 ethnl_default_doit+0x29f/0x310

Add the appropriate size to the calculation.

Fixes: 71921690f974 ("ethtool: provide string sets with STRSET_GET request")
Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Tested-by: Ido Schimmel <idosch@nvidia.com>
---
 net/ethtool/strset.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ethtool/strset.c b/net/ethtool/strset.c
index b3029fff715d..86dcb6b099b3 100644
--- a/net/ethtool/strset.c
+++ b/net/ethtool/strset.c
@@ -365,7 +365,7 @@ static int strset_reply_size(const struct ethnl_req_info *req_base,
 		len += ret;
 	}
 
-	return len;
+	return nla_total_size(len);
 }
 
 /* fill one string into reply */
-- 
2.31.1


             reply	other threads:[~2021-06-17 15:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-17 15:42 Amit Cohen [this message]
2021-06-17 16:29 ` [PATCH net] ethtool: strset: Fix reply_size value Ido Schimmel
2021-06-17 16:29 ` Michal Kubecek
2021-06-17 16:33   ` Ido Schimmel
2021-06-17 21:07     ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210617154252.688724-1-amcohen@nvidia.com \
    --to=amcohen@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=idosch@nvidia.com \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.