]> asedeno.scripts.mit.edu Git - linux.git/commit
netfilter: nat: fix crash when conntrack entry is re-used
authorFlorian Westphal <fw@strlen.de>
Wed, 23 Nov 2016 00:11:03 +0000 (01:11 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 24 Nov 2016 13:43:35 +0000 (14:43 +0100)
commit5173bc679dec881120df109a6a2b39143235382c
treef646792fa521b2cb536f5e9ea1bf17d889e8a412
parent49cdc4c74918a5576cb93b679629714d8a9ef399
netfilter: nat: fix crash when conntrack entry is re-used

Stas Nichiporovich reports oops in nf_nat_bysource_cmp(), trying to
access nf_conn struct at address 0xffffffffffffff50.

This is the result of fetching a null rhash list (struct embedded at
offset 176; 0 - 176 gets us ...fff50).

The problem is that conntrack entries are allocated from a
SLAB_DESTROY_BY_RCU cache, i.e. entries can be free'd and reused
on another cpu while nf nat bysource hash access the same conntrack entry.

Freeing is fine (we hold rcu read lock); zeroing rhlist_head isn't.

-> Move the rhlist struct outside of the memset()-inited area.

Fixes: 7c9664351980aaa6a ("netfilter: move nat hlist_head to nf_conn")
Reported-by: Stas Nichiporovich <stasn77@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/net/netfilter/nf_conntrack.h