]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: nf_nat_snmp_basic: add missing length checks in ASN.1 cbs
authorJann Horn <jannh@google.com>
Wed, 6 Feb 2019 21:56:15 +0000 (22:56 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 11 Feb 2019 16:43:17 +0000 (17:43 +0100)
commit27e87777f306a437e4ab3fe87d7ab995f5b050cf
treeba8683c758581ed3dffa2cb5bf58426377cbb179
parentde83f7d81ee1f9b8d2584aec6984d9c0677c6037
netfilter: nf_nat_snmp_basic: add missing length checks in ASN.1 cbs

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.)

Fixes: 2425d145b020 ("netfilter: nf_nat_snmp_basic: use asn1 decoder library")
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/ipv4/netfilter/nf_nat_snmp_basic_main.c