All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: "David S. Miller" <davem@davemloft.net>
Cc: laforge@netfilter.org, netfilter-devel@lists.netfilter.org,
	pablo@eurodev.net
Subject: Re: [PATCH 1/2] string match for iptables
Date: Sun, 21 Aug 2005 15:55:22 +0200	[thread overview]
Message-ID: <430887CA.1080505@trash.net> (raw)
In-Reply-To: <20050820.131403.37427784.davem@davemloft.net>

David S. Miller wrote:
> Our ability to translate netfilter structures in compat mode
> is primitive, at best, and I think we really should try to
> do something about this soon.

The compat code looks broken, it assumes struct ipt_entry is equal
in both environments, which is not true, at least not on my AMD64.
But we have a couple of spots in userspace were 32bit iptables on
64bit kernel is explicitly handled (libipt_MARK, libipt_CONNMARK,
...), so it does seem to work on some machines.

Anyway, I already started working on this after Andi claimed it was
unfixable, but so far I can only dump the ruleset, insertion doesn't
work yet.

> This IP tables modules can provide a bit of help, with some kind
> of descriptor, or set of methods the compat layer can call into
> for help (or a flag saying, "no translation necessary").

At the moment we have two modules that need translation, CLUSTERIP
and hashlimit. Thanks to versioning we can just fix them in a new
structure.

> One thing about the implementation is that it is apparent that
> people often load an _enormous_ amount of rules.  A large enough
> set that kmalloc() can't get enough space for the entire rule set.
> I've seen a report about this recently on sparc64, where someone
> tries to load enough ipt_replace rules that the kmalloc() done
> by the compat mode translation stuff was too large.

Where does it call kmalloc? net/compat.c uses compat_alloc_user_space
for the translated ruleset.

> One thing that can help is to not put pointers into these rules,
> that is actually the most difficult case to handle.  Without
> pointers, the entire struct can be defined using portable types
> that require no translation.  Once you introduce a pointer, using
> the user's struct as-is becomes impossible.  (as an added bonus
> such rules could thus be sent over the wire as well, if we ever
> wanted to do that)
> 
> In this case, we could put a zero length array at the end.  But
> I realize that with iptables rules this may be difficult due to
> some restriction I am not aware of.

The entire ruleset is one big blob so dynamically sizing structures
doesn't work. There's also no room to put a pointer somewhere outside
of the match/target structures where they could keep instantiated
private data. I think there is no way to avoid this until we get
rid of the one-big-blob thing.

  reply	other threads:[~2005-08-21 13:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-20 16:06 [PATCH 1/2] string match for iptables Pablo Neira
2005-08-20 16:35 ` Patrick McHardy
2005-08-20 20:14   ` David S. Miller
2005-08-21 13:55     ` Patrick McHardy [this message]
2005-08-21 22:34       ` David S. Miller
2005-08-22  0:13         ` Patrick McHardy
2005-08-22  2:14           ` David S. Miller
2005-08-25 10:42     ` Harald Welte
2005-08-25 16:54       ` Martin Josefsson
2005-08-25 17:19         ` Martin Josefsson
2005-08-26 12:00           ` Patrick McHardy
2005-08-26 13:27             ` DaveM get's removed from Cc (was Re: [PATCH 1/2] string match for iptables) Harald Welte
2005-08-26 15:21               ` Phil Oester
2005-08-26 18:33                 ` Harald Welte

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=430887CA.1080505@trash.net \
    --to=kaber@trash.net \
    --cc=davem@davemloft.net \
    --cc=laforge@netfilter.org \
    --cc=netfilter-devel@lists.netfilter.org \
    --cc=pablo@eurodev.net \
    /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.