netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] netfilter: SIP conntrack fixes
@ 2011-05-17  5:26 kaber
  2011-05-17  5:26 ` [PATCH 1/2] netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages kaber
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: kaber @ 2011-05-17  5:26 UTC (permalink / raw)
  To: davem; +Cc: netfilter-devel, netdev

Hi Dave,

following are two fixes for the SIP connection tracking helper:

- missing validation of the Content-Length field, which is used to calculate
  the end of the SDP body

- incorrect parsing of the SIP message, resulting in a failure to locate
  the SDP body when the Content-Length field is not the last member of the
  SIP message

Please apply or pull from:

git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git master

Thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  2011-05-17  5:26 [PATCH 0/2] netfilter: SIP conntrack fixes kaber
@ 2011-05-17  5:26 ` kaber
  2011-05-17  5:26 ` [PATCH 2/2] netfilter: nf_ct_sip: fix SDP parsing in TCP SIP messages for some Cisco phones kaber
  2011-05-17 18:18 ` [PATCH 0/2] netfilter: SIP conntrack fixes David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: kaber @ 2011-05-17  5:26 UTC (permalink / raw)
  To: davem; +Cc: netfilter-devel, netdev

From: Patrick McHardy <kaber@trash.net>

Verify that the message length of a single SIP message, which is calculated
based on the Content-Length field contained in the SIP message, does not
exceed the packet boundaries.

Signed-off-by: Patrick McHardy <kaber@trash.net>
---
 net/netfilter/nf_conntrack_sip.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
index bcf47eb..1f81abd 100644
--- a/net/netfilter/nf_conntrack_sip.c
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -1461,6 +1461,8 @@ static int sip_help_tcp(struct sk_buff *skb, unsigned int protoff,
 		end += strlen("\r\n\r\n") + clen;
 
 		msglen = origlen = end - dptr;
+		if (msglen > datalen)
+			return NF_DROP;
 
 		ret = process_sip_msg(skb, ct, dataoff, &dptr, &msglen);
 		if (ret != NF_ACCEPT)
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] netfilter: nf_ct_sip: fix SDP parsing in TCP SIP messages for some Cisco phones
  2011-05-17  5:26 [PATCH 0/2] netfilter: SIP conntrack fixes kaber
  2011-05-17  5:26 ` [PATCH 1/2] netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages kaber
@ 2011-05-17  5:26 ` kaber
  2011-05-17 18:18 ` [PATCH 0/2] netfilter: SIP conntrack fixes David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: kaber @ 2011-05-17  5:26 UTC (permalink / raw)
  To: davem; +Cc: netfilter-devel, netdev

From: Patrick McHardy <kaber@trash.net>

Some Cisco phones do not place the Content-Length field at the end of the
SIP message. This is valid, due to a misunderstanding of the specification
the parser expects the SDP body to start directly after the Content-Length
field. Fix the parser to scan for \r\n\r\n to locate the beginning of the
SDP body.

Reported-by: Teresa Kang <teresa_kang@gemtek.com.tw>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
 net/netfilter/nf_conntrack_sip.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
index 1f81abd..c05c0dc 100644
--- a/net/netfilter/nf_conntrack_sip.c
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -1419,6 +1419,7 @@ static int sip_help_tcp(struct sk_buff *skb, unsigned int protoff,
 	const char *dptr, *end;
 	s16 diff, tdiff = 0;
 	int ret = NF_ACCEPT;
+	bool term;
 	typeof(nf_nat_sip_seq_adjust_hook) nf_nat_sip_seq_adjust;
 
 	if (ctinfo != IP_CT_ESTABLISHED &&
@@ -1453,10 +1454,15 @@ static int sip_help_tcp(struct sk_buff *skb, unsigned int protoff,
 		if (dptr + matchoff == end)
 			break;
 
-		if (end + strlen("\r\n\r\n") > dptr + datalen)
-			break;
-		if (end[0] != '\r' || end[1] != '\n' ||
-		    end[2] != '\r' || end[3] != '\n')
+		term = false;
+		for (; end + strlen("\r\n\r\n") <= dptr + datalen; end++) {
+			if (end[0] == '\r' && end[1] == '\n' &&
+			    end[2] == '\r' && end[3] == '\n') {
+				term = true;
+				break;
+			}
+		}
+		if (!term)
 			break;
 		end += strlen("\r\n\r\n") + clen;
 
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] netfilter: SIP conntrack fixes
  2011-05-17  5:26 [PATCH 0/2] netfilter: SIP conntrack fixes kaber
  2011-05-17  5:26 ` [PATCH 1/2] netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages kaber
  2011-05-17  5:26 ` [PATCH 2/2] netfilter: nf_ct_sip: fix SDP parsing in TCP SIP messages for some Cisco phones kaber
@ 2011-05-17 18:18 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2011-05-17 18:18 UTC (permalink / raw)
  To: kaber; +Cc: netfilter-devel, netdev

From: kaber@trash.net
Date: Tue, 17 May 2011 07:26:52 +0200

> following are two fixes for the SIP connection tracking helper:
> 
> - missing validation of the Content-Length field, which is used to calculate
>   the end of the SDP body
> 
> - incorrect parsing of the SIP message, resulting in a failure to locate
>   the SDP body when the Content-Length field is not the last member of the
>   SIP message
> 
> Please apply or pull from:
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git master

Pulled, thanks Patrick.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-17 18:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-17  5:26 [PATCH 0/2] netfilter: SIP conntrack fixes kaber
2011-05-17  5:26 ` [PATCH 1/2] netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages kaber
2011-05-17  5:26 ` [PATCH 2/2] netfilter: nf_ct_sip: fix SDP parsing in TCP SIP messages for some Cisco phones kaber
2011-05-17 18:18 ` [PATCH 0/2] netfilter: SIP conntrack fixes David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).