From: Amin Azez <azez@ufomechanic.net>
To: netfilter-devel@lists.netfilter.org
Subject: Re: BUG/CONFLICT conntrack with preroute/postroute mangle table
Date: Thu, 05 May 2005 12:08:07 +0100 [thread overview]
Message-ID: <d5cue9$3qf$1@sea.gmane.org> (raw)
In-Reply-To: <426E4442.5070800@ufomechanic.net>
Further to the problem below, skb->nfcache is having the lower 2 bits
clobbered by net/ipv4/netfilter/ip_tables.c around line 316 (2.6.11.7)
back = get_entry(table_base, table->private->underflow[hook]);
do {
IP_NF_ASSERT(e);
IP_NF_ASSERT(back);
//THIS IS THE CULPRIT!
(*pskb)->nfcache |= e->nfcache;
e->nfcache has been observed at 0,1,2,0x4000
1 and 2 are IPCT_NEW and IPCT_RELATED and these are causing the damage.
At this point, e is a: struct ipt_entry *e
I haven't manage to find in the kernel source where nfcache of an
ipt_entry is used or set for anything.
find net include -type f | xargs grep 'nfcache' | less
shows every modification to be on some kind of skb!
I'm baffled, but I'll keep looking to see where this is being set.
Anyone else got ideas?
Is this maybe just ipt_entry not being properly initialized when
allocated and I'm just getting junk?
Amin Azez wrote:
>
> I've got a sample case of two iptables rules that reproduce the problems
> of a netlink message for every packet that I have been having with
> conntrack(-tool).
>
...
> To reproduce the bug, follow these steps which I have just verified, yes
> on a pristine 2.6.11.7 kernel with ctnetlink, nfnetlink and
> conntrack-event-api (and without my conntrack mac address patches):
>
> 1) modprobe ip_conntrack_netlink
> 2) /path/to/conntrack -E conntrack
> 3) now connect to the box and see that conntrack is reporting NEW UPDATE
> UPDATE
>
> then do: (1.2.3.4 is any IP address nowhere near your network)
> 4) iptables -t mangle -A PREROUTING -d 1.2.3.4
> 5) iptables -t mangle -A POSTROUTING -d 1.2.3.4
> 7) /path/to/conntrack -E conntrack
> 8) now connect to the box and watch it spring an event for every packet
> as NEW NEW NEW
>
> Thats it! So why does presence of these rules in PREROUTING and
> POSTROUTING damage skb->nfcache in this way?
> Either rule will do it, they aren't both needed, but note that the rules
> don't actually match OR take any action if it does match.
>
> So it is merely the action of processing the rule that breaks
> skb->nfcache value.
>
> Amin
>
> Amin Azez wrote:
>
>> Further investigation points to the layer 7 matching and mangle-tables
>> rules etc, once I remove those rules it stops the magical increment
>> from 4078 to c079.
>>
>> Possibly this has been the cuase of the problems, I'll check tomorrow
>> to see how this could cause it.
>>
>> Amin
>>
>> Amin Azez wrote:
>>
>>> Looking at some of my skb->nfcache debugging
>>> (de8ce580 is the skb address)
>>>
>>> during tcp_packet, I get calls to ip_conntrack_event_cache which
>>> changes nfcache thus:
>>> * event_cache on de8ce580 from 4000 to 4040
>>> * event_cache on de8ce580 from 4040 to 4060
>>> * {leave tcp_packet}
>>> * event_cache on de8ce580 from 4060 to 4068
>>> * event_cache on de8ce580 from 4068 to 4078
>>> * deliver_cached_events c079 right now skb de8ce580
>>>
>>> By the time ip_confirm is called some more stuff has happened to
>>> nfcache, hence ip_confirm c079 de8ce580
>>>
>>> Question is how did the nfcache get from 4078 to c079
>>> It was c079 when ip_confirm was called
>>>
>>> Whence the extra 8001 that has been combined? The 1 is IPCT_NEW, the
>>> 8000 is NFC_ALTERED
>>>
>>> NFC_ALTERED is used in various places, the most like in
>>> ip_ct_gather_frags but this hardly seems likely if src and dst
>>> machines are on the same subnet?
>>> I confirmed with logging that it isn't there so I will have to add
>>> debug to all the other places to see which one is guilty.
>>>
>>> Azez
>>>
>>
>>
>
>
>
next prev parent reply other threads:[~2005-05-05 11:08 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-19 13:37 nfnetlink/ctnetlink from pom-ng r3884 Wang Jian
2005-04-20 0:55 ` Pablo Neira
2005-04-21 8:21 ` Wang Jian
2005-04-21 11:05 ` Pablo Neira
2005-04-21 11:29 ` Wang Jian
2005-04-20 13:41 ` Amin Azez
2005-04-20 14:17 ` Samuel Liddicott
2005-04-20 22:44 ` Pablo Neira
2005-04-21 8:07 ` Amin Azez
2005-04-21 9:25 ` extending conntrack event data Amin Azez
2005-04-21 9:49 ` Amin Azez
2005-04-21 10:14 ` Wang Jian
2005-04-21 11:04 ` Pablo Neira
2005-04-25 13:51 ` Amin Azez
2005-04-25 16:35 ` IPCT_NEW comes from was " Amin Azez
2005-04-25 16:43 ` Amin Azez
2005-04-26 13:37 ` BUG/CONFLICT conntrack with preroute/postroute mangle table Samuel Liddicott
2005-04-26 13:38 ` Amin Azez
2005-05-05 11:08 ` Amin Azez [this message]
2005-05-05 13:36 ` RFC for fix? Was " Amin Azez
2005-05-05 16:05 ` Pablo Neira
2005-05-09 11:11 ` Amin Azez
2005-05-09 13:48 ` Amin Azez
2005-04-21 11:04 ` extending conntrack event data Amin Azez
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='d5cue9$3qf$1@sea.gmane.org' \
--to=azez@ufomechanic.net \
--cc=netfilter-devel@lists.netfilter.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.