All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alessandro Rubini <rubini@gnudd.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] Bug in IP/UDP defragment?
Date: Thu, 10 Jun 2010 23:56:42 +0200	[thread overview]
Message-ID: <20100610215641.GA28418@morgana.i.gnudd.com> (raw)
In-Reply-To: <0B45E93C5FF65740AEAE690BF3848B7A02087B60@rennsmail04.eu.thmulti.com>

Hello.
Please forgive my delay.

> 16:58:32.290407 IP 10.12.48.10.33088 > 10.12.48.32.3285: UDP, length 2959
> 16:58:32.290410 IP 10.12.48.10 > 10.12.48.32: udp
> 16:58:32.290412 IP 10.12.48.10 > 10.12.48.32: udp

The third fragment here is less than 8 bytes of payload, and this
triggers the bug.

> I don't know yet what are the side effects of my patch.

Ok, I restudied the flow.

> -	if (offset8 + (len / 8) <= h - payload) {
> +	if (offset8 + (len / 8) < h - payload) {
>  		/* no overlap with holes (dup fragment?) */
>  		return NULL;

offset8 is the start of this fragment, as 8-byte-items, and h is the
current hole, the one that might be relevant. Since everything before
"h" is already filled, a fragment that ends where this hole starts
is duplicate, thus "<=". 

Here len/8 is 0, so you force accepting this trailing fragment, but
you'll also accept duplicate packets.  Looking@how following code
behaves in this case (it assumes some hole or part of is filled),
the "overlaps with initial part of the hole" will trigger, and the
hole will be rewritten unchanged.

So I don't see bad side effects in your fix, but if anyone will re-read
the code (looking for another bug, for example) after your change it will
be hard to understand (they'll suggest reverting the change for example).

I'd suggest to still discard duplicate fragments, by turning

	if (offset8 + (len / 8) <= h - payload)

to
	/* last fragment may be 1..7 bytes, the "+7" forces acceptance */
	if (offset8 + ((len + 7) / 8) <= h - payload)

or something along these lines. Will you please post a patch?

Thanks a lof for your report and fix

/alessandro

  reply	other threads:[~2010-06-10 21:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-08 13:08 [U-Boot] Bug in IP/UDP defragment? Fillod Stephane
2010-06-10 21:56 ` Alessandro Rubini [this message]
2010-08-08  9:28 ` Wolfgang Denk
2010-08-08  9:39   ` Alessandro Rubini
2010-08-08 13:16     ` Wolfgang Denk

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=20100610215641.GA28418@morgana.i.gnudd.com \
    --to=rubini@gnudd.com \
    --cc=u-boot@lists.denx.de \
    /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.