]> git.itanic.dy.fi Git - linux-stable/commit
netfilter: nf_conntrack_sip: fix ct_sip_walk_headers
authorIgor Ryzhov <iryzhov@nfware.com>
Wed, 5 Jun 2019 09:32:40 +0000 (12:32 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Sep 2022 09:10:29 +0000 (11:10 +0200)
commit369ec4dab0972dd407d4ed9dae82f57a2a0fdf6e
treebc6f3944c5ea181a2c3859185e1c653adf6c0281
parent66f9470ffe42c30688984d9aed0a2d236b19cbc8
netfilter: nf_conntrack_sip: fix ct_sip_walk_headers

[ Upstream commit 39aebedeaaa95757f5c1f2ddb5f43fdddbf478ca ]

ct_sip_next_header and ct_sip_get_header return an absolute
value of matchoff, not a shift from current dataoff.
So dataoff should be assigned matchoff, not incremented by it.

This issue can be seen in the scenario when there are multiple
Contact headers and the first one is using a hostname and other headers
use IP addresses. In this case, ct_sip_walk_headers will work as follows:

The first ct_sip_get_header call to will find the first Contact header
but will return -1 as the header uses a hostname. But matchoff will
be changed to the offset of this header. After that, dataoff should be
set to matchoff, so that the next ct_sip_get_header call find the next
Contact header. But instead of assigning dataoff to matchoff, it is
incremented by it, which is not correct, as matchoff is an absolute
value of the offset. So on the next call to the ct_sip_get_header,
dataoff will be incorrect, and the next Contact header may not be
found at all.

Fixes: 05e3ced297fe ("[NETFILTER]: nf_conntrack_sip: introduce SIP-URI parsing helper")
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netfilter/nf_conntrack_sip.c