Thread View: linux.kernel.netdev
4 messages
4 total messages
Started by Greg KH
Mon, 26 Oct 2026 11:46
Re: ipv6: skb_over_panic in __ip6_append_data() when mtu - fragheaderlen is in [1,7] (single sendmsg, since 2.6.12)
Author: Greg KH
Date: Mon, 26 Oct 2026 11:46
Date: Mon, 26 Oct 2026 11:46
13 lines
13101 bytes
13101 bytes
On Mon, Oct 26, 2026 at 06:54:50PM +0800, 平之 wrote: > 5. Suggested fix > ---------------- <snip> can you turn this into a real patch that can be applied so that you can get proper credit for resolving this? thanks, greg k-h
Re: [PATCH net] ipv6: fix dead half of the MTU guard in __ip6_append_data()
Author: netdev-bot+sinfo
Date: Mon, 26 Oct 2026 12:56
Date: Mon, 26 Oct 2026 12:56
18 lines
8591 bytes
8591 bytes
Hi! This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information: - How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan. Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then. The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
Re: [PATCH net] ipv6: fix dead half of the MTU guard in __ip6_append_data()
Author: Willem de Bruijn
Date: Mon, 26 Oct 2026 15:12
Date: Mon, 26 Oct 2026 15:12
94 lines
14345 bytes
14345 bytes
平之 wrote:
> The second half of the MTU guard in __ip6_append_data() has been dead
> code since the initial git import:
>
> if (mtu <= fragheaderlen ||
> ((mtu - fragheaderlen) & ~7) + fragheaderlen <= sizeof(struct frag_hdr))
> goto emsgsize;
>
> (x & ~7) is unsigned and >= 0, and fragheaderlen is at least
> sizeof(struct ipv6hdr) = 40 > sizeof(struct frag_hdr) = 8, so the
> second condition can never be true. Commit 5e34af4142ff ("net: ipv6:
> fix skb_over_panic in __ip6_append_data") tightened the first half
> (mtu == fragheaderlen) but left the dead second half in place.
>
> For mtu - fragheaderlen in [1,7], (x & ~7) == 0, so
>
> maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen - 8
>
> underflows below fragheaderlen. Every later bound computed as
> maxfraglen - fragheaderlen then wraps to 0xfffffff8, in particular the
> datalen clamp inside the fragment loop, which never fires and lets
> fraglen = datalen + fragheaderlen escape the MTU constraint.
>
> With MSG_MORE on an egress device without NETIF_F_SG, alloclen = mtu
> while skb_put() is called with the unclamped fraglen, so a single
> sendmsg() on a raw IPv6 socket with a 1240-byte HOPOPTS cmsg and
> IPV6_MTU = fragheaderlen + 1 triggers:
>
> skbuff: skb_over_panic: len:61280 put:61280 ...
> [ 37.607856] kernel BUG at net/core/skbuff.c:214!
> [ 37.607865] Internal error: Oops - BUG: 00000000f2000800 [#1] SMP
> ...
> [ 37.616606] Call trace:
> [ 37.616606] skb_panic+0x5c/0x60 (P)
> [ 37.616778] skb_put+0x9c/0xa8
> [ 37.616952] __ip6_append_data+0xf80/0x1948
> [ 37.617172] ip6_append_data+0x94/0x2a8
> [ 37.617363] rawv6_sendmsg+0x588/0x988
> [ 37.617716] inet_sendmsg+0x4c/0xa8
> [ 37.617891] ____sys_sendmsg+0x268/0x308
> [ 37.618105] ___sys_sendmsg+0xb4/0x140
> [ 37.618299] __sys_sendmsg+0xa8/0x140
>
> Replace the dead expression with a direct check of the payload space
> available in a fragment, which rejects mtu - fragheaderlen in [1,8].
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@vger.kernel.org
> Signed-off-by: bo cao <treebacker@foxmail.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
> ---
> net/ipv6/ip6_output.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
> index 25fe0ba98b1a..7d4d4d45e207 100644
> --- a/net/ipv6/ip6_output.c
> +++ b/net/ipv6/ip6_output.c
> @@ -1500,7 +1500,7 @@ static int __ip6_append_data(struct sock *sk,
> rt->rt6i_nfheader_len;
>
> if (mtu <= fragheaderlen ||
> - ((mtu - fragheaderlen) & ~7) + fragheaderlen <= sizeof(struct frag_hdr))
> + mtu - fragheaderlen <= sizeof(struct frag_hdr))
> goto emsgsize;
Thanks for the patch. Not critical, but could even consider a single check:
if (mtu <= fragheaderlen + sizeof(struct frag_hdr))
Checkers may complain that the right hand side could overflow, but in
practice fragheaderlen is bounded.
>
> maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen -
> --
Re: [PATCH net] ipv6: fix dead half of the MTU guard in __ip6_append_data()
Author: Willem de Bruijn
Date: Mon, 26 Oct 2026 15:19
Date: Mon, 26 Oct 2026 15:19
94 lines
14424 bytes
14424 bytes
平之 wrote:
> The second half of the MTU guard in __ip6_append_data() has been dead
> code since the initial git import:
>
> if (mtu <= fragheaderlen ||
> ((mtu - fragheaderlen) & ~7) + fragheaderlen <= sizeof(struct frag_hdr))
> goto emsgsize;
>
> (x & ~7) is unsigned and >= 0, and fragheaderlen is at least
> sizeof(struct ipv6hdr) = 40 > sizeof(struct frag_hdr) = 8, so the
> second condition can never be true. Commit 5e34af4142ff ("net: ipv6:
> fix skb_over_panic in __ip6_append_data") tightened the first half
> (mtu == fragheaderlen) but left the dead second half in place.
>
> For mtu - fragheaderlen in [1,7], (x & ~7) == 0, so
>
> maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen - 8
>
> underflows below fragheaderlen. Every later bound computed as
> maxfraglen - fragheaderlen then wraps to 0xfffffff8, in particular the
> datalen clamp inside the fragment loop, which never fires and lets
> fraglen = datalen + fragheaderlen escape the MTU constraint.
>
> With MSG_MORE on an egress device without NETIF_F_SG, alloclen = mtu
> while skb_put() is called with the unclamped fraglen, so a single
> sendmsg() on a raw IPv6 socket with a 1240-byte HOPOPTS cmsg and
> IPV6_MTU = fragheaderlen + 1 triggers:
>
> skbuff: skb_over_panic: len:61280 put:61280 ...
> [ 37.607856] kernel BUG at net/core/skbuff.c:214!
> [ 37.607865] Internal error: Oops - BUG: 00000000f2000800 [#1] SMP
> ...
> [ 37.616606] Call trace:
> [ 37.616606] skb_panic+0x5c/0x60 (P)
> [ 37.616778] skb_put+0x9c/0xa8
> [ 37.616952] __ip6_append_data+0xf80/0x1948
> [ 37.617172] ip6_append_data+0x94/0x2a8
> [ 37.617363] rawv6_sendmsg+0x588/0x988
> [ 37.617716] inet_sendmsg+0x4c/0xa8
> [ 37.617891] ____sys_sendmsg+0x268/0x308
> [ 37.618105] ___sys_sendmsg+0xb4/0x140
> [ 37.618299] __sys_sendmsg+0xa8/0x140
>
> Replace the dead expression with a direct check of the payload space
> available in a fragment, which rejects mtu - fragheaderlen in [1,8].
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Fixes: 6596a0229541 ("xfrm: fix MTU regression")
> Cc: stable@vger.kernel.org
> Signed-off-by: bo cao <treebacker@foxmail.com>
> ---
> net/ipv6/ip6_output.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
> index 25fe0ba98b1a..7d4d4d45e207 100644
> --- a/net/ipv6/ip6_output.c
> +++ b/net/ipv6/ip6_output.c
> @@ -1500,7 +1500,7 @@ static int __ip6_append_data(struct sock *sk,
> rt->rt6i_nfheader_len;
>
> if (mtu <= fragheaderlen ||
> - ((mtu - fragheaderlen) & ~7) + fragheaderlen <= sizeof(struct frag_hdr))
> + mtu - fragheaderlen <= sizeof(struct frag_hdr))
> goto emsgsize;
Correction: I thought a difference with ip6_fragment was benign and
this patch is still an improvement, but it seems that additionally
ensuring enough space for one octet of payload is mandatory:
+ if (mtu < fragheaderlen + sizeof(struct frag_hdr) + 8)
+ goto emsgsize;
See ip6_fragment:
if (mtu < hlen + sizeof(struct frag_hdr) + 8)
goto fail_toobig;
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads