All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Bernhard Schmidt <berni@birkenwald.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: null-pointer deref in ulogd2
Date: Tue, 23 Jun 2009 17:40:39 +0200	[thread overview]
Message-ID: <4A40F777.7010505@netfilter.org> (raw)
In-Reply-To: <h1q3tu$2vi$1@ger.gmane.org>

[-- Attachment #1: Type: text/plain, Size: 814 bytes --]

Bernhard Schmidt wrote:
> Bernhard Schmidt <berni@birkenwald.de> wrote:
> 
>> now it seems to work okay. In the database about 90% of the flows have
>> flow_end_sec NULL.

Please, rise "netlink_socket_buffer_size" and
"netlink_socket_buffer_maxsize". If you use the default buffer, it's
likely to overrun and, thus, to lose events.

[...]
> What is happening here?

I think that you're using the default "hash_max_entries" which is too
small. I suggest you to rise this value. I'm going to push a patch that
includes information on these parameter tweaking to the example config file.

BTW, could you give a quick test to this patch, yours seems to leak
memory since NFCT_CB_STOLEN means not to release the ct object (no
problem, I guess that you're not familiar with libnetfilter_conntrack).

Thanks for testing.

[-- Attachment #2: fix.patch --]
[-- Type: text/x-diff, Size: 1537 bytes --]

NFCT: fix NULL dereference when hashtable is full

This patch fixes a NULL dereference to the timestamp structure when
hashtable_add() fails, for example, because the hashtable is full.

Reported-by: Bernhard Schmidt <berni@birkenwald.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---

 input/flow/ulogd_inpflow_NFCT.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)


diff --git a/input/flow/ulogd_inpflow_NFCT.c b/input/flow/ulogd_inpflow_NFCT.c
index b8278af..b16687e 100644
--- a/input/flow/ulogd_inpflow_NFCT.c
+++ b/input/flow/ulogd_inpflow_NFCT.c
@@ -596,6 +596,9 @@ static int event_handler(enum nf_conntrack_msg_type type,
 	switch(type) {
 	case NFCT_T_NEW:
 		ts = hashtable_add(cpi->ct_active, &tmp);
+		if (ts == NULL)
+			return NFCT_CB_CONTINUE;
+
 		gettimeofday(&ts->time[START], NULL);
 		return NFCT_CB_STOLEN;
 	case NFCT_T_UPDATE:
@@ -604,6 +607,9 @@ static int event_handler(enum nf_conntrack_msg_type type,
 			nfct_copy(ts->ct, ct, NFCT_CP_META);
 		else {
 			ts = hashtable_add(cpi->ct_active, &tmp);
+			if (ts == NULL)
+				return NFCT_CB_CONTINUE;
+
 			gettimeofday(&ts->time[START], NULL);
 			return NFCT_CB_STOLEN;
 		}
@@ -734,6 +740,9 @@ static int overrun_handler(enum nf_conntrack_msg_type type,
 	/* if it does not exist, add it */
 	if (!hashtable_get(cpi->ct_active, &tmp)) {
 		ts = hashtable_add(cpi->ct_active, &tmp);
+		if (ts == NULL)
+			return NFCT_CB_CONTINUE;
+
 		gettimeofday(&ts->time[START], NULL); /* do our best here */
 		return NFCT_CB_STOLEN;
 	}

  reply	other threads:[~2009-06-23 15:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-23  7:27 null-pointer deref in ulogd2 Bernhard Schmidt
2009-06-23  8:31 ` Bernhard Schmidt
2009-06-23 15:40   ` Pablo Neira Ayuso [this message]
2009-06-23 16:54     ` Bernhard Schmidt
2009-06-23 22:39       ` Bernhard Schmidt
2009-06-24 10:59         ` conntrack segfault (was: Re: null-pointer deref in ulogd2) Bernhard Schmidt
2009-06-24 11:17           ` Krzysztof Oledzki
2009-06-24 11:57             ` Jan Engelhardt
2009-06-24 12:56               ` conntrack segfault Bernhard Schmidt
2009-06-24 17:58                 ` Pablo Neira Ayuso
2009-06-24 20:05                   ` Bernhard Schmidt
2009-06-24 22:18                   ` Bernhard Schmidt
2009-07-02 16:30                     ` Pablo Neira Ayuso
2009-07-06 10:29                     ` Krzysztof Oledzki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A40F777.7010505@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=berni@birkenwald.de \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.