public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: Anshu Kumari <anskuma@redhat.com>
Cc: passt-dev@passt.top
Subject: Re: [PATCH v2] tcp: Avoid division by zero with small MSS values
Date: Wed, 11 Nov 2026 08:03:19 +0100 (CET)	[thread overview]
Message-ID: <20261111080319.2d2fccb8@elisabeth> (raw)
In-Reply-To: <20261026111820.1600260-1-anskuma@redhat.com>

On Mon, 26 Oct 2026 16:48:20 +0530
Anshu Kumari <anskuma@redhat.com> wrote:

> Fuzz testing with AFL++ persistent mode found that
> tcp_buf_data_from_sock() terminates the process with SIGFPE
> (signal 8) from division by zero at:
> 
>   fill_bufs = DIV_ROUND_UP(wnd_scaled - already_sent, mss);
> 
> when MSS is small enough (less than four) to round down to 0
> during the bit-shift in MSS_SET(). The termination itself is
> clean (not memory corruption or data leakage), but we can
> handle this condition more gracefully.
> 
> We considered resetting connections with a zero or very low
> MSS, but concluded this is not RFC-compliant: RFC 9293,
> section 3.1 (MUST-7), states: "TCP implementations MUST be
> prepared to handle an illegal option length (e.g., zero); a
> suggested procedure is to reset the connection and log the
> error cause." However, this applies only to option *lengths*,
> not *values* — no standard RFC defines a minimum MSS value.
> Section 3.5.2 further states: "A reset must not be sent if
> it is not clear that this is the case." Very low MSS values
> also have legitimate uses in microcontroller applications
> with limited buffers, and a zero MSS could represent a
> unidirectional connection.
> 
> Rounding a low MSS upward is also not an option: emitting
> segments larger than the peer advertised violates the
> effective send MSS requirement in RFC 9293, section 3.7.1.
> 
> Instead, preserve the actual MSS:
> 
>   - Adjust MSS_SET() to clamp non-zero values below 4 to 1,
>     avoiding the round-to-zero in bit-field storage.
>   - Adjust MSS_GET() to return 1 when tap_mss is 1, so we
>     never inflate the MSS beyond what the peer advertised.
>   - When MSS is zero, don't send data:
>     tcp_buf_data_from_sock() returns early. The peer will
>     eventually determine the connection is unusable and
>     reset it.
> 
> Signed-off-by: Anshu Kumari <anskuma@redhat.com>
> ---
> v2:
>   - added comment for both MSS_SET() and MSS_GET() macro.
>   - fixed/modified MSS_GET().
>   - fixed commit message by explaining why we are not
>     resetting the connection.
> 
> NOTE: let the fuzzer run for more than a day with this
>       fix but till now, haven't found any issue.

Applied.

-- 
Stefano


      reply	other threads:[~2026-11-11  7:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26 11:18 Anshu Kumari
2026-11-11  7:03 ` Stefano Brivio [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=20261111080319.2d2fccb8@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=anskuma@redhat.com \
    --cc=passt-dev@passt.top \
    /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.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

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 IMAP folder(s).