From: Andrew Lunn <andrew@lunn.ch>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: "Hans Ulli Kroll" <ulli.kroll@googlemail.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
"Vladimir Oltean" <olteanv@gmail.com>,
linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 3/4] net: ethernet: cortina: Protect against oversized frames
Date: Sat, 4 Nov 2023 15:46:09 +0100 [thread overview]
Message-ID: <39debb25-bf30-4ede-99b1-d9f6091a039c@lunn.ch> (raw)
In-Reply-To: <20231104-gemini-largeframe-fix-v1-3-9c5513f22f33@linaro.org>
On Sat, Nov 04, 2023 at 01:43:50PM +0100, Linus Walleij wrote:
> The max size of a transfer no matter the MTU is 64KB-1 so immediately
> bail out if the skb exceeds that.
>
> Fixes: 4d5ae32f5e1e ("net: ethernet: Add a driver for Gemini gigabit ethernet")
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/net/ethernet/cortina/gemini.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
> index fd08f098850b..23723c9c0f93 100644
> --- a/drivers/net/ethernet/cortina/gemini.c
> +++ b/drivers/net/ethernet/cortina/gemini.c
> @@ -1156,6 +1156,12 @@ static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb,
> mtu = MTU_SIZE_BIT_MASK;
> }
>
> + if (skb->len > 65535) {
> + /* The field for length is only 16 bits */
> + netdev_err(netdev, "%s: frame too big, max size 65535 bytes\n", __func__);
> + return -EINVAL;
> + }
> +
The caller of gmac_map_tx_bufs() is a but funky:
if (gmac_map_tx_bufs(netdev, skb, txq, &w)) {
if (skb_linearize(skb))
goto out_drop;
u64_stats_update_begin(&port->tx_stats_syncp);
port->tx_frags_linearized++;
u64_stats_update_end(&port->tx_stats_syncp);
if (gmac_map_tx_bufs(netdev, skb, txq, &w))
goto out_drop_free;
}
So return -EINVAL is going to cause the skb to be linearised, and then
re-tried. Maybe you want to check the error code here, and go straight
to out_drop?
Andrew
next prev parent reply other threads:[~2023-11-04 14:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-04 12:43 [PATCH net 0/4] Fix large frames in the Gemini ethernet driver Linus Walleij
2023-11-04 12:43 ` [PATCH net 1/4] net: ethernet: cortina: Fix MTU max setting Linus Walleij
2023-11-04 14:36 ` Andrew Lunn
2023-11-04 12:43 ` [PATCH net 2/4] net: ethernet: cortina: Fix max RX frame define Linus Walleij
2023-11-04 14:38 ` Andrew Lunn
2023-11-04 12:43 ` [PATCH net 3/4] net: ethernet: cortina: Protect against oversized frames Linus Walleij
2023-11-04 14:46 ` Andrew Lunn [this message]
2023-11-04 12:43 ` [PATCH net 4/4] net: ethernet: cortina: Handle large frames Linus Walleij
2023-11-04 14:56 ` Andrew Lunn
2023-11-05 20:56 ` Linus Walleij
2023-11-04 15:18 ` kernel test robot
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=39debb25-bf30-4ede-99b1-d9f6091a039c@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mirq-linux@rere.qmqm.pl \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=ulli.kroll@googlemail.com \
/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
all inboxes | Powered by JetHome®