From: Alexander Duyck <alexander.duyck@gmail.com>
To: Ding Hui <dinghui@sangfor.com.cn>
Cc: Jakub Kicinski <kuba@kernel.org>, Andrew Lunn <andrew@lunn.ch>,
davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
pengdonglin@sangfor.com.cn, huangcun@sangfor.com.cn
Subject: Re: [PATCH net-next] net: ethtool: Fix out-of-bounds copy to user
Date: Thu, 8 Jun 2023 07:17:25 -0700 [thread overview]
Message-ID: <CAKgT0UdX7cc-LVFowFrY7mSZMvN0xc+w+oH16GNrduLY-AddSA@mail.gmail.com> (raw)
In-Reply-To: <034f5393-e519-1e8d-af76-ae29677a1bf5@sangfor.com.cn>
On Thu, Jun 8, 2023 at 2:06 AM Ding Hui <dinghui@sangfor.com.cn> wrote:
>
> On 2023/6/6 2:39, Jakub Kicinski wrote:
> > On Mon, 5 Jun 2023 11:39:59 +0800 Ding Hui wrote:
> >> Case 1:
> >> If the user len/n_stats is not zero, we will treat it as correct usage
> >> (although we cannot distinguish between the real correct usage and
> >> uninitialized usage). Return -EINVAL if current length exceed the one
> >> user specified.
> >
> > This assumes user will zero-initialize the value rather than do
> > something like:
> >
> > buf = malloc(1 << 16); // 64k should always be enough
> > ioctl(s, ETHTOOL_GSTATS, buf)
> >
> > for (i = 0; i < buf.n_stats; i++)
> > /* use stats */
> >
> > :(
> >
>
> Sorry for late.
>
> Now I'm not sure what can I do next besides reporting the issue.
Well as I said before. The issue points to a driver problem more than
anything else.
Normally the solution is to make it so that the counts don't
fluctuate. That mostly consists of providing strings equal to the
maximum count, and then 0 populating the data for any fields that
don't exist in the case of ethtool -S.
So for example in the case of igb which you had pointed out you could
take a look at ixgbe for inspiration on how to fix it since the two
drivers should be similar and one has the issue and one does not.
next prev parent reply other threads:[~2023-06-08 14:18 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-01 11:28 [PATCH net-next] net: ethtool: Fix out-of-bounds copy to user Ding Hui
2023-06-01 15:04 ` Alexander H Duyck
2023-06-02 1:46 ` Ding Hui
2023-06-02 12:26 ` Andrew Lunn
2023-06-02 15:01 ` Ding Hui
2023-06-02 15:37 ` Andrew Lunn
2023-06-02 16:01 ` Alexander Duyck
2023-06-02 16:37 ` Andrew Lunn
2023-06-02 18:02 ` Alexander Duyck
2023-06-03 1:51 ` Ding Hui
2023-06-03 5:55 ` Jakub Kicinski
2023-06-03 7:11 ` Ding Hui
2023-06-04 17:47 ` Jakub Kicinski
2023-06-05 3:39 ` Ding Hui
2023-06-05 18:39 ` Jakub Kicinski
2023-06-08 9:06 ` Ding Hui
2023-06-08 14:17 ` Alexander Duyck [this message]
2023-06-09 15:25 ` Ding Hui
2023-06-09 17:13 ` Jakub Kicinski
2023-06-09 17:59 ` Alexander Duyck
2023-06-10 3:47 ` Ding Hui
2023-06-10 4:01 ` Ding Hui
2023-06-02 15:30 ` Alexander Duyck
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=CAKgT0UdX7cc-LVFowFrY7mSZMvN0xc+w+oH16GNrduLY-AddSA@mail.gmail.com \
--to=alexander.duyck@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=dinghui@sangfor.com.cn \
--cc=edumazet@google.com \
--cc=huangcun@sangfor.com.cn \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pengdonglin@sangfor.com.cn \
/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).