From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-b1-smtp.messagingengine.com (fhigh-b1-smtp.messagingengine.com [202.12.124.152]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9BB383CCA19 for ; Tue, 25 Aug 2026 20:02:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.152 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787688159; cv=none; b=fZzLTjbXl/bwFlXC0sqREfLH3F9sp19QNG3PbcVuHCnxmhCgNpiIpIuMXvMQuyL+ysYBrrqmBWQow+bKbqDSjU6jzvbIfELkyC/SKlIQ89WHFO49GjTEFWbZsGQx7aM4ynm1CGUUcbCBpiNsx3Mf2L09AsiJzyjV48ltDNFFRzQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787688159; c=relaxed/simple; bh=/YZKVYk/L6dyruLdxfl7WIXz33gjUDcSeoPRd9IwmHk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fFNe/FCyuycUMC161pgnRec27HxeVelOzNcqOvQeQ2eGtCl7vgOfyfZb9j8hH8Pc4ZiywYRyyAYaNa+bnq2zQn4FgGlCyTrOhs20ZODR7OSXPMWkQWgG12ZZ25kmpbZV9kihZm0WcJpJUi/RSaYApnIFgLztg12kQboTbbNpLx4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fastmail.im; spf=pass smtp.mailfrom=fastmail.im; dkim=pass (2048-bit key) header.d=fastmail.im header.i=@fastmail.im header.b=kgqYoNO1; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=fCu7HnMU; arc=none smtp.client-ip=202.12.124.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fastmail.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastmail.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fastmail.im header.i=@fastmail.im header.b="kgqYoNO1"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="fCu7HnMU" Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfhigh.stl.internal (Postfix) with ESMTP id A31247A00D0; Tue, 25 Aug 2026 16:02:36 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-09.internal (MEProxy); Tue, 25 Aug 2026 16:02:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.im; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1787688156; x= 1787774556; bh=SiCj95U5huzbKKQRE4iCRqDxTe2vaNO9s6DJBSD0N5I=; b=k gqYoNO1xISolh1sgBtehCLph5Iv6FCdLfMqd9qkQBcL/kGaY/hE3pwRwlnJSAiR8 JQcPidVTSM/vXH7wKKq8UvaZEYJWQwsJNxbQVLQXZkCulwl40FTCvx7SouwVa2/q dilTG8fHET0iYtZnuaLrufZgHaQxSMVMSINCOu8/o3LufpXY1uRN6XLdzSvrJShK MKxzBpWf4+DSz1cNb70MeW+4KeXw3oXUj9Kd1RHYRwO661D/aU8MBe/+fPeRswaz uadoa241qj9tFDcM88gMj1XG5jwHCYnMGxlx6ESXnY8nxenCow9lQ5K3NQJfhFyv yCghShEY2VflQo1mSUmkg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1787688156; x=1787774556; bh=S iCj95U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axDtem43I+7+Ia198iYVIBOueA X-ME-Proxy: Feedback-ID: i559e4809:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 25 Aug 2026 16:02:35 -0400 (EDT) From: Alice Mikityanska To: Willem de Bruijn , David Ahern , Ido Schimmel , Jakub Kicinski , Paolo Abeni Cc: "David S. Miller" , Eric Dumazet , Simon Horman , Shuah Khan , Hannes Frederic Sowa , Vadim Fedorenko , netdev@vger.kernel.org, Alice Mikityanska , syzbot+ce13c07d96d04716eaa2@syzkaller.appspotmail.com, Willem de Bruijn Subject: [PATCH net v4 1/4] net: ipv4: Fix UDP length overflow with PMTU discover and big MTU Date: Tue, 25 Aug 2026 23:02:12 +0300 Message-ID: <20260825200215.90326-2-alice.kernel@fastmail.im> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260825200215.90326-1-alice.kernel@fastmail.im> References: <20260825200215.90326-1-alice.kernel@fastmail.im> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Alice Mikityanska This commit bounds cork->base.fragsize to IP_MAX_MTU to avoid a possible overflow of UDP length that triggers a WARN in udp_set_len_short when setsockopt IP_MTU_DISCOVER is set to IP_PMTUDISC_PROBE, and a large packet is sent over a netdev with an unusually large MTU. Steps to reproduce: 1. Set device MTU bigger than IP_MAX_MTU + 20. cork->base.fragsize will be set to that MTU in ip_setup_cork. 2. Set IP_MTU_DISCOVER to IP_PMTUDISC_PROBE. It lets maxnonfragsize be set to device MTU (cork->fragsize) in __ip_append_data, rather than to IP_MAX_MTU. 3. Send 65528 bytes of payload (+8 bytes of UDP header, +20 bytes of IPv4 header). Device MTU allows it (it's only one byte bigger than IP_MAX_MTU + IPv4 header, and the device MTU is bigger than that). 4. The UDP length in the built packet is 65536, which overflows the 16-bit length field and triggers the WARN in udp_set_len_short. Note: IP_PMTUDISC_DO with IPv4 is safe, because ip_dst_mtu_maybe_forward always clamps at IP_MAX_MTU, unlike ip6_dst_mtu_maybe_forward. The Fixes tag points at the first commit where I could reproduce the overflow with IPv4 and IP_PMTUDISC_PROBE. Fixes: daba287b299e ("ipv4: fix DO and PROBE pmtu mode regarding local fragmentation with UFO/CORK") Reported-by: syzbot+ce13c07d96d04716eaa2@syzkaller.appspotmail.com Closes: https://lore.kernel.org/netdev/6a6a966c.86abc875.e5c3d.0054.GAE@google.com/ Signed-off-by: Alice Mikityanska Assisted-by: Claude:claude-sonnet-4.6 Reviewed-by: Willem de Bruijn --- net/ipv4/ip_output.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 74e095b6b7ca..a24cc8ee11d3 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -1303,6 +1303,7 @@ static int ip_setup_cork(struct sock *sk, struct inet_cork *cork, cork->fragsize = ip_sk_use_pmtu(sk) ? dst4_mtu(&rt->dst) : READ_ONCE(rt->dst.dev->mtu); + cork->fragsize = min(cork->fragsize, IP_MAX_MTU); if (!inetdev_valid_mtu(cork->fragsize)) return -ENETUNREACH; -- 2.55.0