Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: nf_ct_h323: cap packet size at 64k

With BIG TCP, packets generated by tcp stack may exceed 64kb.
Cap datalen at 64kb. The internal message format uses 16bit fields,
so no embedded message can exceed 64k size.

Multiple h323 messages in a single superpacket may now result
in a message to get treated as incomplete/truncated, but thats
better than scribbling past h323_buffer.

Another alternative suitable for net tree would be a switch to
skb_linearize().

Fixes: 7c4e983c4f3c ("net: allow gso_max_size to exceed 65536")
Fixes: 0fe79f28bfaf ("net: allow gro_max_size to exceed 65536")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

authored by

Florian Westphal and committed by
Pablo Neira Ayuso
f3e124c3 a664375d

+9 -1
+9 -1
net/netfilter/nf_conntrack_h323_main.c
··· 34 34 #include <net/netfilter/nf_conntrack_zones.h> 35 35 #include <linux/netfilter/nf_conntrack_h323.h> 36 36 37 + #define H323_MAX_SIZE 65535 38 + 37 39 /* Parameters */ 38 40 static unsigned int default_rrq_ttl __read_mostly = 300; 39 41 module_param(default_rrq_ttl, uint, 0600); ··· 87 85 tcpdatalen = skb->len - tcpdataoff; 88 86 if (tcpdatalen <= 0) /* No TCP data */ 89 87 goto clear_out; 88 + 89 + if (tcpdatalen > H323_MAX_SIZE) 90 + tcpdatalen = H323_MAX_SIZE; 90 91 91 92 if (*data == NULL) { /* first TPKT */ 92 93 /* Get first TPKT pointer */ ··· 1174 1169 if (dataoff >= skb->len) 1175 1170 return NULL; 1176 1171 *datalen = skb->len - dataoff; 1172 + if (*datalen > H323_MAX_SIZE) 1173 + *datalen = H323_MAX_SIZE; 1174 + 1177 1175 return skb_header_pointer(skb, dataoff, *datalen, h323_buffer); 1178 1176 } 1179 1177 ··· 1778 1770 1779 1771 NF_CT_HELPER_BUILD_BUG_ON(sizeof(struct nf_ct_h323_master)); 1780 1772 1781 - h323_buffer = kmalloc(65536, GFP_KERNEL); 1773 + h323_buffer = kmalloc(H323_MAX_SIZE + 1, GFP_KERNEL); 1782 1774 if (!h323_buffer) 1783 1775 return -ENOMEM; 1784 1776 ret = h323_helper_init();