From: Jakub Kicinski <kuba@kernel.org>
To: Michal Kubecek <mkubecek@suse.cz>
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [RFC net-next] ethtool: add a stricter length check
Date: Tue, 15 Jun 2021 20:28:10 -0700 [thread overview]
Message-ID: <20210615202810.37c680b1@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <20210615231033.32opvfjz7hhha7zs@lion.mk-sys.cz>
On Wed, 16 Jun 2021 01:10:33 +0200 Michal Kubecek wrote:
> > @@ -346,15 +346,20 @@ static int ethnl_default_doit(struct sk_buff *skb, struct genl_info *info)
> > ret = ops->reply_size(req_info, reply_data);
> > if (ret < 0)
> > goto err_cleanup;
> > - reply_len = ret + ethnl_reply_header_size();
> > + reply_len = ret;
> > ret = -ENOMEM;
> > - rskb = ethnl_reply_init(reply_len, req_info->dev, ops->reply_cmd,
> > + rskb = ethnl_reply_init(reply_len + ethnl_reply_header_size(),
> > + req_info->dev, ops->reply_cmd,
> > ops->hdr_attr, info, &reply_payload);
> > if (!rskb)
> > goto err_cleanup;
> > + hdr_len = rskb->len;
> > ret = ops->fill_reply(rskb, req_info, reply_data);
> > if (ret < 0)
> > goto err_msg;
> > + WARN(rskb->len - hdr_len > reply_len,
> > + "ethnl cmd %d: calculated reply length %d, but consumed %d\n",
> > + cmd, reply_len, rskb->len - hdr_len);
> > if (ops->cleanup_data)
> > ops->cleanup_data(reply_data);
>
> We may want WARN_ONCE or ratelimited here, if there is bug in reply
> length estimate for a request not requiring admin privileges, the
> warning might be invoked by a regular user at will.
Ah, good point!
> Also the patch changes the meaning of reply_len which is also used in
> the original warning after err_msg label. But it's probably not a big
> deal, it's not obvious what exactly "payload" means there so that anyone
> trying to investigate the problem has to start by checking what exactly
> the value reported means.
I'll add a note to this effect to the commit message.
Thanks!
prev parent reply other threads:[~2021-06-16 3:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-12 3:11 [RFC net-next] ethtool: add a stricter length check Jakub Kicinski
2021-06-15 23:10 ` Michal Kubecek
2021-06-16 3:28 ` Jakub Kicinski [this message]
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=20210615202810.37c680b1@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--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 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).