Skip to contentSkip to conversation

NFQUEUE and NFLOG fixes.

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

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

cover NFQUEUE and NFLOG fixes.

Hi,

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
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 3ceeffc..15a7de2 100644
@@ -353,7 +353,7 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
 
 	QDEBUG("entered\n");
 
-	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: [stable-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.

#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 2c7bd2e..dc43df1 100644
@@ -594,7 +594,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: [stable-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, thanks.