Netdev List
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: "Eric Dumazet" <edumazet@kernel.org>,
	"tencentos_secure(TencentOS安全公共邮箱)"
	<tencentos_secure@tencent.com>
Cc: netdev@vger.kernel.org,  David Ahern <dsahern@kernel.org>,
	 Ido Schimmel <idosch@nvidia.com>,
	 Paolo Abeni <pabeni@redhat.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	 Willem de Bruijn <willemb@google.com>,
	 Steffen Klassert <klassert@kernel.org>,
	 security@kernel.org
Subject: Re: [PATCH net 2/2] net/ipv4: fail append when the moved fraggap exceeds the fragment data
Date: Fri, 30 Oct 2026 18:29:43 -0400	[thread overview]
Message-ID: <willemdebruijn.kernel.15f496f9f2418@gmail.com> (raw)
In-Reply-To: <CAL4Wiio2inRipSSWgFKkRjuPA=iLkynvWCXQ7cpe9G5XWi9=7Q@mail.gmail.com>

Eric Dumazet wrote:
> Le lun. 26 oct. 2026 à 12:23, tencentos_secure(TencentOS安全公共邮箱)
> <tencentos_secure@tencent.com> a écrit :
> >
> > When the first fragment of a cork is already at maxfraglen, the next
> > __ip_append_data() iteration relays the previous fragment's tail,
> > fraggap = skb_prev->len - maxfraglen, into the new skb. The moved
> > fraggap is charged against datalen by computing
> >
> >         copy = datalen - transhdrlen - fraggap - pagedlen;
> >
> > but once datalen is capped at maxfraglen - fragheaderlen it can become
> > smaller than transhdrlen + fraggap. Then copy goes negative: no payload
> > is copied and the iteration makes no progress. Worse, in the paged
> > branch (MSG_SPLICE_PAGES / MSG_ZEROCOPY / GSO) pagedlen = datalen -
> > transhdrlen - fraggap additionally wraps unsigned, breaking the
> > alloclen + pagedlen == fraglen invariant that commit eca856950f7c
> > ("ipv4: account for fraggap on the paged allocation path") relies
> > on; the loop then either queues skbs with garbage tail accounting
> > (silent packet corruption) or, when maxfraglen == fragheaderlen,
> > never makes progress and grinds on until -ENOBUFS.
> >
> > Reject such an append before any allocation: if the moved tail
> > (transhdrlen + fraggap) cannot fit in the fragment's datalen, the
> > iteration cannot make progress, so fail with -EINVAL. This covers all
> > three alloclen branches, including the paged one. With the preceding
> > fix fraggap is bounded by the alignment slop, but the condition stays
> > reachable with extreme geometries (e.g. an effective mtu too small for
> > fragheaderlen + transhdrlen), so pin the geometry explicitly, as
> > __ip6_append_data() has done since commit 232cd35d0804 ("ipv6: fix
> > out of bound writes in __ip6_append_data()").
> >
> 
> I do not think this is reachable once patch 1 is applied.
> 
> ip_setup_cork() rejects cork->fragsize < 68 (inetdev_valid_mtu()), and
> fragheaderlen is at most 60, so a capped datalen is at least 8, and
> maxfraglen == fragheaderlen cannot happen.
> 
> transhdrlen is non zero only on the first iteration with an empty
> queue, where fraggap is 0, and current callers pass at most 8 bytes
> (UDP, ICMP, ping). On later iterations transhdrlen is 0 and, with
> patch 1, fraggap <= mtu - maxfraglen <= 7.
> 
> So transhdrlen + fraggap > datalen can not be true.

Supposedly there is a path where

    transhdrlen + fraggap > IPV4_MIN_MTU

icmp_timestamp sets transhdrlen to 20

      reply	other threads:[~2026-10-30 22:29 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <v2-20261026-cover@tencent.com>
2026-10-26  9:51 ` [PATCH net 1/2] net/ipv4: reserve exthdrlen as headroom instead of counting it in skb->len =?gb18030?B?dGVuY2VudG9zX3NlY3VyZShUZW5jZW50T1Owssiruau5stPKz+Qp?=
2026-10-27 15:26   ` Willem de Bruijn
2026-10-29  8:29     ` =?gb18030?B?dGVuY2VudG9zX3NlY3VyZShUZW5jZW50T1Owssiruau5stPKz+Qp?=
2026-10-29 14:21       ` Willem de Bruijn
2026-10-30 22:23   ` Willem de Bruijn
2026-10-26  9:51 ` [PATCH net 2/2] net/ipv4: fail append when the moved fraggap exceeds the fragment data =?gb18030?B?dGVuY2VudG9zX3NlY3VyZShUZW5jZW50T1Owssiruau5stPKz+Qp?=
2026-10-26 12:20   ` Eric Dumazet
2026-10-30 22:29     ` Willem de Bruijn [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=willemdebruijn.kernel.15f496f9f2418@gmail.com \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=klassert@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=security@kernel.org \
    --cc=tencentos_secure@tencent.com \
    --cc=willemb@google.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