Netfilter fixes for net
Subsystems (3)
Pablo Neira Ayuso
maintainercover Netfilter fixes for net
Hi David,
The following patchset contains Netfilter fixes for net:
1) Out-of-bound access to packet data from the snmp nat helper, from Jann Horn.
2) ICMP(v6) error packets are set as related traffic by conntrack, update protocol number before calling nf_nat_ipv4_manip_pkt() to use ICMP(v6) rather than the original protocol number, from Florian Westphal.
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Thanks!
----------------------------------------------------------------
The following changes since commit 31b58ad0c3279817cd246eab27eaf53b626dfcde:
Merge branch 'r8169-revert-two-commits-due-to-a-regression' (2019-02-10 12:54:49 -0800)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git HEAD
for you to fetch changes up to 8303b7e8f018724a2cd7752eb29c2801fa8c4067:
netfilter: nat: fix spurious connection timeouts (2019-02-11 17:43:17 +0100)
----------------------------------------------------------------
Florian Westphal (1):
netfilter: nat: fix spurious connection timeouts
Jann Horn (1):
netfilter: nf_nat_snmp_basic: add missing length checks in ASN.1 cbs
net/ipv4/netfilter/nf_nat_l3proto_ipv4.c | 1 + net/ipv4/netfilter/nf_nat_snmp_basic_main.c | 7 ++++++- net/ipv6/netfilter/nf_nat_l3proto_ipv6.c | 1 + 3 files changed, 8 insertions(+), 1 deletion(-)
Pablo Neira Ayuso
maintainerPATCH 1/2 netfilter: nf_nat_snmp_basic: add missing length checks in ASN.1 cbs
From: Jann Horn <[email protected]>
The generic ASN.1 decoder infrastructure doesn't guarantee that callbacks will get as much data as they expect; callbacks have to check the datalen parameter before looking at data. Make sure that snmp_version() and snmp_helper() don't read/write beyond the end of the packet data.
(Also move the assignment to pdata down below the check to make it clear that it isn't necessarily a pointer we can use before the datalen check.)
--- net/ipv4/netfilter/nf_nat_snmp_basic_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/ipv4/netfilter/nf_nat_snmp_basic_main.c +6 -1
@@ -105,6 +105,8 @@ static void fast_csum(struct snmp_ctx *ctx, unsigned char offset)int snmp_version (void *context,size_t hdrlen,unsigned char tag,const void *data,size_t datalen) { +if (datalen !=1 ) +return -EINVAL ;if (*(unsigned char *)data >1 )return -ENOTSUPP ;return 1 ;
@@ -114,8 +116,11 @@ int snmp_helper(void *context, size_t hdrlen, unsigned char tag, const void *data, size_t datalen) {struct snmp_ctx *ctx = (struct snmp_ctx *)context; -__be32 *pdata = (__be32 *)data; +__be32 *pdata; +if (datalen !=4 ) +return -EINVAL ; + pdata = (__be32 *)data;if (*pdata == ctx->from) {pr_debug ("%s: %pI4 to %pI4\n" , __func__, (void *)&ctx->from, (void *)&ctx->to);
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH 2/2 netfilter: nat: fix spurious connection timeouts
In reply to Pablo Neira AyusoFrom: Florian Westphal <[email protected]>
Sander Eikelenboom bisected a NAT related regression down to the l4proto->manip_pkt indirection removal.
I forgot that ICMP(v6) errors (e.g. PKTTOOBIG) can be set as related to the existing conntrack entry.
Therefore, when passing the skb to nf_nat_ipv4/6_manip_pkt(), that ended up calling the wrong l4 manip function, as tuple->dst.protonum is the original flows l4 protocol (TCP, UDP, etc).
Set the dst protocol field to ICMP(v6), we already have a private copy of the tuple due to the inversion of src/dst.
--- net/ipv4/netfilter/nf_nat_l3proto_ipv4.c | 1 + net/ipv6/netfilter/nf_nat_l3proto_ipv6.c | 1 + 2 files changed, 2 insertions(+)
net/ipv4/netfilter/nf_nat_l3proto_ipv4.c +1 -0
@@ -215,6 +215,7 @@ int nf_nat_icmp_reply_translation(struct sk_buff *skb,/* Change outer to look like the reply to an incoming packet */ nf_ct_invert_tuplepr (&target, &ct->tuplehash[!dir].tuple); + target.dst.protonum =IPPROTO_ICMP ;if (!nf_nat_ipv4_manip_pkt (skb,0 , &target, manip))return 0 ;
net/ipv6/netfilter/nf_nat_l3proto_ipv6.c +1 -0
@@ -226,6 +226,7 @@ int nf_nat_icmpv6_reply_translation(struct sk_buff *skb, }nf_ct_invert_tuplepr (&target, &ct->tuplehash[!dir].tuple); + target.dst.protonum =IPPROTO_ICMPV6 ;if (!nf_nat_ipv6_manip_pkt (skb,0 , &target, manip))return 0 ;
Signature · 1 line
2.11.0
David Miller
maintainerFrom: Pablo Neira Ayuso <[email protected]>
Date: Mon, 11 Feb 2019 17:53:17 +0100
Quoted 5 lines
The following patchset contains Netfilter fixes for net:
1) Out-of-bound access to packet data from the snmp nat helper, from Jann Horn.
Quoted 8 lines
2) ICMP(v6) error packets are set as related traffic by conntrack, update protocol number before calling
nf_nat_ipv4_manip_pkt()to use ICMP(v6) rather than the original protocol number, from Florian Westphal.You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Pulled, thanks Pablo.