From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2BD561925AC; Tue, 10 Sep 2024 10:25:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725963914; cv=none; b=ISqrb2KbdaeDPXUjEjdadboZui7NMYpBjJbGbVyB8bc+Cc2B5ZTKG4Oo+NOpyG3+rznwF2XSCuerOUzv4x1JVSUhGRFcXKxB4pe851CM8yy/WCWphLghtMzczsN3sfqCifiDEFj1kQGfG61vTTSkIxI1vk6s64jzpH4Yhdnn6PA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725963914; c=relaxed/simple; bh=fvWNfUxw0nMW2QV38lVXtHjaDh2WJLTHhCE15M6bejs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FEu564QoXdx8q1MY0tW/fSFAtRzl4YHaK/4Kil8kWkJuNBjsWE96WJEllC467lTEw8jLpM6rn4lSu6dKDcStWDqWb10b5fhbwkim3fYqy/32Vh+lQBoePEJ7WOvpagyaepqkPAL4vnPfs/d6cZmbETiqq+5uX0U2TjKXsr5KsHc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=A7OvNMBg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="A7OvNMBg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4C93C4CEC3; Tue, 10 Sep 2024 10:25:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725963914; bh=fvWNfUxw0nMW2QV38lVXtHjaDh2WJLTHhCE15M6bejs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A7OvNMBgrmeBGdcx0yhSZpZlllu9/u7UJRJWfuveFDcW5t25E4n24saFdnS1Fvj2X ddkfWGFKNXB8qpnDxRyhIMo3KlxYAIccBvTGtI9ewFwce3b7D2sa1yn9w8ooMYJCit ETePBejB7ed40wcVq3Jfu+aK4JWHnWMSMKcKC5gY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Willem de Bruijn , Yan Zhai , Willem de Bruijn , Jason Wang , "David S. Miller" Subject: [PATCH 5.15 208/214] gso: fix dodgy bit handling for GSO_UDP_L4 Date: Tue, 10 Sep 2024 11:33:50 +0200 Message-ID: <20240910092607.009399882@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240910092558.714365667@linuxfoundation.org> References: <20240910092558.714365667@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yan Zhai [ Upstream commit 9840036786d90cea11a90d1f30b6dc003b34ee67 ] Commit 1fd54773c267 ("udp: allow header check for dodgy GSO_UDP_L4 packets.") checks DODGY bit for UDP, but for packets that can be fed directly to the device after gso_segs reset, it actually falls through to fragmentation: https://lore.kernel.org/all/CAJPywTKDdjtwkLVUW6LRA2FU912qcDmQOQGt2WaDo28KzYDg+A@mail.gmail.com/ This change restores the expected behavior of GSO_UDP_L4 packets. Fixes: 1fd54773c267 ("udp: allow header check for dodgy GSO_UDP_L4 packets.") Suggested-by: Willem de Bruijn Signed-off-by: Yan Zhai Reviewed-by: Willem de Bruijn Acked-by: Jason Wang Signed-off-by: David S. Miller [5.15 stable: clean backport] Signed-off-by: Willem de Bruijn Signed-off-by: Greg Kroah-Hartman --- net/ipv4/udp_offload.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --- a/net/ipv4/udp_offload.c +++ b/net/ipv4/udp_offload.c @@ -272,13 +272,20 @@ struct sk_buff *__udp_gso_segment(struct __sum16 check; __be16 newlen; - if (skb_shinfo(gso_skb)->gso_type & SKB_GSO_FRAGLIST) - return __udp_gso_segment_list(gso_skb, features, is_ipv6); - mss = skb_shinfo(gso_skb)->gso_size; if (gso_skb->len <= sizeof(*uh) + mss) return ERR_PTR(-EINVAL); + if (skb_gso_ok(gso_skb, features | NETIF_F_GSO_ROBUST)) { + /* Packet is from an untrusted source, reset gso_segs. */ + skb_shinfo(gso_skb)->gso_segs = DIV_ROUND_UP(gso_skb->len - sizeof(*uh), + mss); + return NULL; + } + + if (skb_shinfo(gso_skb)->gso_type & SKB_GSO_FRAGLIST) + return __udp_gso_segment_list(gso_skb, features, is_ipv6); + skb_pull(gso_skb, sizeof(*uh)); /* clear destructor to avoid skb_segment assigning it to tail */