From: Patrick McHardy <kaber@trash.net>
To: Willy Tarreau <willy@w.ods.org>
Cc: Netfilter Development Mailinglist
<netfilter-devel@lists.netfilter.org>,
Harald Welte <laforge@netfilter.org>,
Tom Eastep <teastep@shorewall.net>,
Michal Ludvig <mludvig@suse.cz>,
alex@samad.com.au, guillaume@morinfr.org
Subject: Re: [PATCH]: latest netfilter+ipsec patches
Date: Fri, 05 Mar 2004 02:47:58 +0100 [thread overview]
Message-ID: <4047DC4E.8020309@trash.net> (raw)
In-Reply-To: <20040304231141.GA1782@alpha.home.local>
[-- Attachment #1: Type: text/plain, Size: 4497 bytes --]
Hi Willy,
Willy Tarreau wrote:
> This is excellent. So if I understand it right, a packet now passes this way
> (please excuse the ascii-art, it seems I'll never take the time to start xfig)
>
> [incoming packet]
> |<-----------------.
> v |
> PREROUTING |
> dest!=local? / \ dest==local? |
> / \ |
> FORWARD LOCAL_IN |
> | | |
> | (ipsec?decrypt:nop)|
> | | \ / dest!=local ? nf_postxfrm_nonlocal()
> | | `------'
> v v dest==local ? ip_local_deliver_finish()
>
>
> So if it behaves like this (which is what seems the best solution to me), is
> there a risk that a carefully crafted packet loops many times on the right
> side (multiple encapsulation with local DIP) ? And if so, is it risky or not,
> wrt resource leak, multiple locks, etc... ?
Not exactly. the ipsec transformers are ip protocol handlers,
their input handler (xfrm4_input) is called from
ip_local_deliver_finish. After decrypting the payload the packets
are either reposted into the network stack (in case of a tunnel-mode
SA) or again delivered to the ip-protocol contained in the next
header. packets reposted into the stack may be in some intermediate
state in case of a transport mode encapsulation following a tunnel
mode encapsulation. The difficulty is to know when the packet
is "done". So nf_postxfrm_nonlocal is called directly after input
routing if the destination is non-local, but only for packets which
were reposted into the stack. The fact that they have a non-local
destination means ipsec must be done with them. For packet with
local destination, we look at what the ipprotocol handler does
in ip_local_deliver_finish (xfrm_prot or not) and if the packet
was handled by ipsec before and the protocol handler is no xfrm_prot,
ipsec is done, so the packets are passed through nf_postxfrm_input.
I attached a xfig file with a little picture of how it works, I hope
it's understandable. The blue lines represent the flow as it happens
without my patches, the red lines represent whats new. While drawing
it, I noticed a bug, packets with their destination changed
in nf_postxfrm_nonlocal may need to be delivered locally afterwards.
Regarding loop-danger, I'm not totally sure yet, but I don't think
that it would be triggerable by crafted packets but only by
adventurous configurations. Multiple encapsulations are no error
and they are limited to 4.
>>The only problem with this approach I'm currently aware of is that
>>one of the ip-protocol handlers marked with xfrm_prot
>>(xfrm4_tunnel.c) is also responsible for dispatching packets to
>>ipip.c; the encapsulated packets heading for a ipip-tunnel won't
>>traverse the netfilter hooks on input.
>
>
> I don't know well the internals of IPSEC (bought the book but didn't read it
> yet). Are IPIP tunnels often used ? or are they simply used according to a
> negociation, in which case the ipsec implementation on the netfilter side
> could refuse them ?
It's not IPIP with IPSEC that misbehaves but plaintext-IPIP tunnels.
xfrm4_tunnel.c is the registered handler for IPIP, it used to be ipip.c.
ipip.c now registers itself with xfrm4_tunnel, but xfrm4_tunnel is
marked as a xfrm_prot which is not true for ipip.c. Right now I'm not
even sure that it is a problem and under what exact circumstances, I
need to think about this some more (tomorrow).
>>- new match "policy" for matching the policy that was used during
>>decapsulation (well, the used SAs, policy checks come later), and the
>>policy that will be used for encapsulation.
>
>
> Even more interesting... Now we can for sure check that packets coming from
> a tunnel have not been spoofed by another tunnel.
That should also be handled by the policy checks, although at a
later time (at socket-delivery/forwarding). I'm unsure if the
policy checks should happen before packets are looked at by
netfilter, after all it manipulates it's state from information
in these untrusted packets.
>
> Thanks a lot Patrick.
> My main goal is to use this on 2.4 with davem/herbert xu's ipsec backport.
> I will soon check if your patches apply on top of their implementation.
Thanks for your comments, I'm looking forward to your testing.
Best regards
Patrick
>
> Cheers,
> Willy
>
[-- Attachment #2: nf+ipsec.xfig.fig --]
[-- Type: image/x-xfig, Size: 3113 bytes --]
next prev parent reply other threads:[~2004-03-05 1:47 UTC|newest]
Thread overview: 63+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-21 12:29 NAT before IPsec with 2.6 Michal Ludvig
2004-01-23 6:57 ` Willy Tarreau
2004-01-23 12:31 ` Henrik Nordstrom
2004-01-23 13:31 ` Michal Ludvig
2004-01-23 14:24 ` Henrik Nordstrom
2004-01-23 14:40 ` Michal Ludvig
2004-01-23 15:56 ` Henrik Nordstrom
2004-01-23 15:51 ` Tom Eastep
2004-01-24 8:22 ` Willy Tarreau
2004-01-24 9:21 ` Henrik Nordstrom
2004-01-24 9:27 ` Willy Tarreau
2004-01-27 10:39 ` Harald Welte
2004-01-27 11:57 ` Henrik Nordstrom
2004-01-27 13:07 ` Harald Welte
2004-01-27 13:22 ` Henrik Nordstrom
2004-01-27 14:12 ` Henrik Nordstrom
2004-01-27 20:51 ` Harald Welte
2004-01-27 22:35 ` Henrik Nordstrom
2004-01-28 13:48 ` Harald Welte
2004-01-27 22:41 ` Willy Tarreau
2004-01-27 23:55 ` Harald Welte
2004-01-28 0:14 ` Willy Tarreau
2004-01-28 0:09 ` [PATCH]Re: " Harald Welte
2004-01-28 8:49 ` Patrick McHardy
2004-01-28 9:37 ` Patrick McHardy
2004-01-28 10:30 ` Harald Welte
2004-01-28 11:24 ` Willy Tarreau
2004-01-28 13:39 ` Harald Welte
2004-01-28 15:58 ` Tom Eastep
2004-01-28 13:22 ` Patrick McHardy
2004-01-28 14:23 ` Henrik Nordstrom
2004-02-01 14:52 ` Patrick McHardy
2004-02-16 1:19 ` Patrick McHardy
2004-02-18 14:57 ` Patrick McHardy
[not found] ` <20040218220337.GA3193@alpha.home.local>
2004-02-20 1:43 ` Patrick McHardy
2004-03-04 22:30 ` [PATCH]: latest netfilter+ipsec patches Patrick McHardy
2004-03-04 23:11 ` Willy Tarreau
2004-03-04 23:42 ` Alexander Samad
2004-03-05 2:00 ` Patrick McHardy
2004-03-05 2:13 ` Alexander Samad
2004-03-10 2:45 ` Alexander Samad
2004-03-11 22:10 ` Patrick McHardy
2004-03-12 0:15 ` Alexander Samad
2004-03-05 1:47 ` Patrick McHardy [this message]
2004-03-05 11:10 ` Willy Tarreau
2004-03-04 23:44 ` Patrick McHardy
2004-03-05 11:39 ` Harald Welte
2004-01-28 10:30 ` [PATCH]Re: NAT before IPsec with 2.6 Andreas Jellinghaus
2004-01-29 19:05 ` Harald Welte
2004-01-27 19:54 ` Michael Richardson
2004-01-27 13:27 ` Valentijn Sessink
2004-01-27 13:57 ` Henrik Nordstrom
2004-01-27 21:13 ` Andreas Jellinghaus
2004-01-28 8:58 ` Harald Welte
2004-01-28 10:21 ` Andreas Jellinghaus
2004-01-28 13:00 ` Harald Welte
2004-01-28 13:43 ` Andreas Jellinghaus
2004-01-28 14:24 ` 2.6.2-rc2 and nf-log Wojciech 'Sas' Cieciwa
2004-01-28 19:38 ` NAT before IPsec with 2.6 David S. Miller
2004-01-27 16:11 ` Tom Eastep
2004-01-27 20:45 ` Harald Welte
2004-01-28 15:36 ` Tom Eastep
2004-01-27 19:51 ` Michael Richardson
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=4047DC4E.8020309@trash.net \
--to=kaber@trash.net \
--cc=alex@samad.com.au \
--cc=guillaume@morinfr.org \
--cc=laforge@netfilter.org \
--cc=mludvig@suse.cz \
--cc=netfilter-devel@lists.netfilter.org \
--cc=teastep@shorewall.net \
--cc=willy@w.ods.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.