Skip to contentSkip to conversation

NFLOG and NFQUEUE fixes

PATCH Applied Eric Leblond 2 participants 5 messages Mar 4, 2008

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

cover NFLOG and NFQUEUE fixes

Hi,

This patchset is against latest git tree and contains the same fixes as the patchset against 2.6.24.3 that I've just sent.

Extended information:

The following two patches fix similar bugs in NFQUEUE and NFLOG. The allocated size of the skb use for the netlink message was too small due to the use of NLMSG_ALIGN instead of NLMSG_SPACE. In fact, the size for the initial netlink header was missing.

The effect on my setup was the drop of all queued packets of length inside the range [8*k+41, 8*k+48] with k an integer.

Effect on NFLOG has not been tested and is not known.

BR,
--
Eric Leblond <[email protected]>
INL: http://www.inl.fr/
NuFW: http://www.nufw.org/

#1 lore raw

PATCH 1/2 Fix computation of allocated size for netlink skb.

Size of the netlink skb was wrongly computed because the formula was using NLMSG_ALIGN instead of NLMSG_SPACE. NLMSG_ALIGN does not add the room for netlink header as NLMSG_SPACE does. This was causing a failure of message building in some cases.

On my test system, all messages for packets in range [8*k+41, 8*k+48] where k is an integer were invalid and the corresponding packets were dropped.

---
 net/netfilter/nfnetlink_queue.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/netfilter/nfnetlink_queue.c +1 -1
index 0043d3a..c0cc3d3 100644
@@ -224,7 +224,7 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
 	struct net_device *indev;
 	struct net_device *outdev;
 
-	size =    NLMSG_ALIGN(sizeof(struct nfgenmsg))
+	size =    NLMSG_SPACE(sizeof(struct nfgenmsg))
 		+ nla_total_size(sizeof(struct nfqnl_msg_packet_hdr))
 		+ nla_total_size(sizeof(u_int32_t))	/* ifindex */
 		+ nla_total_size(sizeof(u_int32_t))	/* ifindex */
Signature · 1 line
1.5.4.1
#2 lore raw

Re: [PATCH 1/2] Fix computation of allocated size for netlink skb.

Quoted 7 lines · Eric Leblond

Size of the netlink skb was wrongly computed because the formula was using NLMSG_ALIGN instead of NLMSG_SPACE. NLMSG_ALIGN does not add the room for netlink header as NLMSG_SPACE does. This was causing a failure of message building in some cases.

On my test system, all messages for packets in range [8*k+41, 8*k+48] where k is an integer were invalid and the corresponding packets were dropped.

Applied, thanks.

#3 lore raw

PATCH 2/2 Fix computation of netlink skb size.

In reply to Eric Leblond

This patch is similar to nfnetlink_queue fixes. It fixes the computation of skb size by using NLMSG_SPACE instead of NLMSG_ALIGN.

---
 net/netfilter/nfnetlink_log.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/netfilter/nfnetlink_log.c +1 -1
index 7efa40d..c6802c0 100644
@@ -556,7 +556,7 @@ nfulnl_log_packet(unsigned int pf,
 	/* FIXME: do we want to make the size calculation conditional based on
 	 * what is actually present?  way more branches and checks, but more
 	 * memory efficient... */
-	size =    NLMSG_ALIGN(sizeof(struct nfgenmsg))
+	size =    NLMSG_SPACE(sizeof(struct nfgenmsg))
 		+ nla_total_size(sizeof(struct nfulnl_msg_packet_hdr))
 		+ nla_total_size(sizeof(u_int32_t))	/* ifindex */
 		+ nla_total_size(sizeof(u_int32_t))	/* ifindex */
Signature · 1 line
1.5.4.1
#4 lore raw

Re: [PATCH 2/2] Fix computation of netlink skb size.

Quoted 2 lines · Eric Leblond

This patch is similar to nfnetlink_queue fixes. It fixes the computation of skb size by using NLMSG_SPACE instead of NLMSG_ALIGN.

Also applied. I'll push your -stable patches once these two hit upstream.