Skip to contentSkip to conversation

netfilter: add size check for udp packet mangling

PATCH Applied Harald Welte 2 participants 2 messages Oct 2, 2003 – Oct 3, 2003

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: add size check for udp packet mangling

Hi Davem!

Please apply the following patch to your 2.6 tree and push it for kernel inclusion, thanks.

Author: Patrick McHardy <[email protected]>

Add size check to ip_nat_mangle_udp_packet

Signature · 5 lines
- Harald Welte <[email protected]>             http://www.netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.1355 -> 1.1356
# net/ipv4/netfilter/ip_nat_helper.c 1.18 -> 1.19
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/09/27 [email protected] 1.1356
# [NETFILTER]: Add size check to ip_nat_mangle_udp_packet
# --------------------------------------------
#

net/ipv4/netfilter/ip_nat_helper.c +6 -0
diff -Nru a/net/ipv4/netfilter/ip_nat_helper.c b/net/ipv4/netfilter/ip_nat_helper.c
@@ -217,6 +217,12 @@
 	struct iphdr *iph;
 	struct udphdr *udph;
 
+	/* UDP helpers might accidentally mangle the wrong packet */
+	iph = (*pskb)->nh.iph;
+	if ((*pskb)->len < iph->ihl*4 + sizeof(*udph) + 
+	                       match_offset + match_len)
+		return 0;
+
 	if (!skb_ip_make_writable(pskb, (*pskb)->len))
 		return 0;
 
#1 lore raw
Quoted 2 lines · On Thu, 2 Oct 2003 16:29:37 +0200 Harald Welte <[email protected]> wrote:

Please apply the following patch to your 2.6 tree and push it for kernel inclusion, thanks.

Applied, thanks.