From: Sascha Hauer <sha@pengutronix.de>
To: Christian Melki <christian.melki@t2data.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] net.c: Don't forget about the first fragment.
Date: Fri, 28 Jul 2023 08:37:06 +0200 [thread overview]
Message-ID: <20230728063706.GG18491@pengutronix.de> (raw)
In-Reply-To: <20230704175535.1183448-1-christian.melki@t2data.com>
On Tue, Jul 04, 2023 at 07:55:35PM +0200, Christian Melki wrote:
> It's possible to request very large messages using
> the current code base. F.ex. UDP datagrams with the tftp client.
> The tftp servers will happily reply with fragmented IP frames.
> All these frame parts need to be dropped as BB currently doesn't
> do fragment reassembly.
>
> The current check was for fragment offsets only (0x1fff).
> But the first frame has fragment offset 0 and would slip through
> this check. That could result in a seemingly OK frame
> for the tftp client, but with broken data.
>
> Add check for the MF (More Fragments) flag. Should cover the
> first packet too.
>
> Signed-off-by: Christian Melki <christian.melki@t2data.com>
> ---
> net/net.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/net/net.c b/net/net.c
> index 19161d2e82..b842041d59 100644
> --- a/net/net.c
> +++ b/net/net.c
> @@ -678,7 +678,12 @@ static int net_handle_ip(struct eth_device *edev, unsigned char *pkt, int len)
> if ((ip->hl_v & 0xf0) != 0x40)
> goto bad;
>
> - if (ip->frag_off & htons(0x1fff)) /* Can't deal w/ fragments */
> + /* Can't deal w/ fragments.
> + * Ether a fragment offset (13 bits), or
> + * MF (More Fragments) from frag. flags (3 bits).
> + * MF - because first fragment has fragment offset 0
> + */
> + if (ip->frag_off & htons(0x3fff))
Nice catch ;)
Applied with typo fixed (Ether->Either)
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2023-07-28 6:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-04 17:55 Christian Melki
2023-07-28 6:37 ` Sascha Hauer [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=20230728063706.GG18491@pengutronix.de \
--to=sha@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=christian.melki@t2data.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