NFQUEUE and NFLOG fixes.
Subsystems (2)
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/
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
@@ -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
Patrick McHardy
AppliedRe: [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_ALIGNinstead ofNLMSG_SPACE.NLMSG_ALIGNdoes not add the room for netlink header asNLMSG_SPACEdoes. 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.
PATCH 2/2 Fix computation of netlink skb size.
In reply to Eric LeblondThis 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
@@ -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
Re: [stable-patch 2/2] Fix computation of netlink skb size.
Quoted 2 lines · Eric Leblond
This patch is similar to
nfnetlink_queuefixes. It fixes the computation of skb size by usingNLMSG_SPACEinstead ofNLMSG_ALIGN.
Also applied, thanks.