lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTikw3uonDB4nPXg8FVFN_07F_wq0SA_ayyAHL6VM@mail.gmail.com>
Date:	Tue, 1 Jun 2010 08:28:53 +0800
From:	Changli Gao <xiaosuo@...il.com>
To:	Eric Dumazet <eric.dumazet@...il.com>
Cc:	hawk@...x.dk, Jesper Dangaard Brouer <hawk@...u.dk>,
	paulmck@...ux.vnet.ibm.com, Patrick McHardy <kaber@...sh.net>,
	Linux Kernel Network Hackers <netdev@...r.kernel.org>,
	Netfilter Developers <netfilter-devel@...r.kernel.org>
Subject: Re: DDoS attack causing bad effect on conntrack searches

On Tue, Jun 1, 2010 at 5:21 AM, Eric Dumazet <eric.dumazet@...il.com> wrote:
>
> I had a look at current conntrack and found the 'unconfirmed' list was
> maybe a candidate for a potential blackhole.
>
> That is, if a reader happens to hit an entry that is moved from regular
> hash table slot 'hash' to unconfirmed list,

Sorry, but I can't find where we do this things. unconfirmed list is
used to track the unconfirmed cts, whose corresponding skbs are still
in path from the first to the last netfilter hooks. As soon as the
skbs end their travel in netfilter, the corresponding cts will be
confirmed(moving ct from unconfirmed list to regular hash table).

unconfirmed list should be small, as networking receiving is in BH.
How about implementing unconfirmed list as a per cpu variable?

> reader might scan whole
> unconfirmed list to find out he is not anymore on the wanted hash chain.
>
> Problem is this unconfirmed list might be very very long in case of
> DDOS. It's really not designed to be scanned during a lookup.
>
> So I guess we should stop early if we find an unconfirmed entry ?
>
>
>
> diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
> index bde095f..0573641 100644
> --- a/include/net/netfilter/nf_conntrack.h
> +++ b/include/net/netfilter/nf_conntrack.h
> @@ -298,8 +298,10 @@ extern int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp);
>  extern unsigned int nf_conntrack_htable_size;
>  extern unsigned int nf_conntrack_max;
>
> -#define NF_CT_STAT_INC(net, count)     \
> +#define NF_CT_STAT_INC(net, count)             \
>        __this_cpu_inc((net)->ct.stat->count)
> +#define NF_CT_STAT_ADD(net, count, value)      \
> +       __this_cpu_add((net)->ct.stat->count, value)
>  #define NF_CT_STAT_INC_ATOMIC(net, count)              \
>  do {                                                   \
>        local_bh_disable();                             \
> diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
> index eeeb8bc..e96d999 100644
> --- a/net/netfilter/nf_conntrack_core.c
> +++ b/net/netfilter/nf_conntrack_core.c
> @@ -299,6 +299,7 @@ __nf_conntrack_find(struct net *net, u16 zone,
>        struct nf_conntrack_tuple_hash *h;
>        struct hlist_nulls_node *n;
>        unsigned int hash = hash_conntrack(net, zone, tuple);
> +       unsigned int cnt = 0;
>
>        /* Disable BHs the entire time since we normally need to disable them
>         * at least once for the stats anyway.
> @@ -309,10 +310,19 @@ begin:
>                if (nf_ct_tuple_equal(tuple, &h->tuple) &&
>                    nf_ct_zone(nf_ct_tuplehash_to_ctrack(h)) == zone) {
>                        NF_CT_STAT_INC(net, found);
> +                       NF_CT_STAT_ADD(net, searched, cnt);
>                        local_bh_enable();
>                        return h;
>                }
> -               NF_CT_STAT_INC(net, searched);
> +               /*
> +                * If we find an unconfirmed entry, restart the lookup to
> +                * avoid scanning whole unconfirmed list
> +                */
> +               if (unlikely(++cnt > 8 &&
> +                            !nf_ct_is_confirmed(nf_ct_tuplehash_to_ctrack(h)))) {
> +                       NF_CT_STAT_INC(net, search_restart);
> +                       goto begin;
> +               }
>        }
>        /*
>         * if the nulls value we got at the end of this lookup is
> @@ -323,6 +333,7 @@ begin:
>                NF_CT_STAT_INC(net, search_restart);
>                goto begin;
>        }
> +       NF_CT_STAT_ADD(net, searched, cnt);
>        local_bh_enable();
>
>        return NULL;
>
>
>



-- 
Regards,
Changli Gao(xiaosuo@...il.com)
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ