Skip to contentSkip to conversation

ip_queue: Fix wrong skb->len == nlmsg_len assumption

PATCH Applied Thomas Graf 3 participants 3 messages Mar 7, 2006

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

PATCH 1/1 ip_queue: Fix wrong skb->len == nlmsg_len assumption

The size of the skb carrying the netlink message is not equivalent to the length of the actual netlink message due to padding. ip_queue matches the length of the payload against the original packet size to determine if packet mangling is desired, due to the above wrong assumption arbitary packets may not be mangled depening on their original size.

net/ipv4/netfilter/ip_queue.c +1 -1
Index: net-2.6/net/ipv4/netfilter/ip_queue.c
===================================================================
@@ -524,7 +524,7 @@ ipq_rcv_skb(struct sk_buff *skb)
 	write_unlock_bh(&queue_lock);
 	
 	status = ipq_receive_peer(NLMSG_DATA(nlh), type,
-	                          skblen - NLMSG_LENGTH(0));
+	                          nlmsglen - NLMSG_LENGTH(0));
 	if (status < 0)
 		RCV_SKB_FAIL(status);
 		
net/ipv6/netfilter/ip6_queue.c +1 -1
Index: net-2.6/net/ipv6/netfilter/ip6_queue.c
===================================================================
@@ -522,7 +522,7 @@ ipq_rcv_skb(struct sk_buff *skb)
 	write_unlock_bh(&queue_lock);
 	
 	status = ipq_receive_peer(NLMSG_DATA(nlh), type,
-	                          skblen - NLMSG_LENGTH(0));
+	                          nlmsglen - NLMSG_LENGTH(0));
 	if (status < 0)
 		RCV_SKB_FAIL(status);
 		
#1 lore raw
Quoted 7 lines · Thomas Graf

The size of the skb carrying the netlink message is not equivalent to the length of the actual netlink message due to padding. ip_queue matches the length of the payload against the original packet size to determine if packet mangling is desired, due to the above wrong assumption arbitary packets may not be mangled depening on their original size.

Looks good, thanks Thomas. I think this should also go in 2.4.

maintainer Applied
#2 lore raw

From: Patrick McHardy <[email protected]>
Date: Tue, 07 Mar 2006 13:58:53 +0100

Quoted 10 lines
Quoted 7 lines · Thomas Graf

The size of the skb carrying the netlink message is not equivalent to the length of the actual netlink message due to padding. ip_queue matches the length of the payload against the original packet size to determine if packet mangling is desired, due to the above wrong assumption arbitary packets may not be mangled depening on their original size.

Looks good, thanks Thomas. I think this should also go in 2.4.

Pushed to 2.6.16, 2.6.x stable, and 2.4.x.

Phew!

Thanks Thomas.