netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Patrick McHardy <kaber@trash.net>
Cc: Florian Westphal <fw@strlen.de>,
	netfilter-devel@vger.kernel.org,
	Bart De Schuymer <bdschuym@pandora.be>
Subject: Re: [PATCH 08/10] netfilter: ebtables: try native set/getsockopt handlers, too
Date: Thu, 11 Feb 2010 22:50:04 +0100	[thread overview]
Message-ID: <20100211215004.GD27427@Chamillionaire.breakpoint.cc> (raw)
In-Reply-To: <4B7440FC.3090508@trash.net>

Patrick McHardy <kaber@trash.net> wrote:
> > ebtables can be compiled to perform userspace-side padding of
> > structures. In that case, all the structures are already in the
> > 'native' format expected by the kernel.
> > 
> > This tries to determine what format the userspace program is
> > using.
> > 
> > For most set/getsockopts, this can be done by re-trying the
> > native handler once the compat_ version returns an error.
> > 
> > In case of EBT_SO_GET_ENTRIES, the native handler is tried first,
> > it should error out very early when checking the *len argument
> > (the compat version has to defer this check until after
> >  iterating over the kernel data set once, to adjust for all
> >  the structure size differences).
> 
> Can't we place an explicit check somewhere instead of "probing"
> for compatibility? Checking the size of struct ebt_replace for
> compat tasks should be suitable.

Yes, thats what is being done where possible.
Here is a list of the set/getsockopts and the current "detect" strategy:

EBT_SO_SET_COUNTERS:
in compat handler, copy struct ebt_replace from user, check that
len == sizeof(struct compat_ebt_replace) + repl.num_counters * sizeof(struct ebt_counter)

if yes: continue, else try non-compat handler

EBT_SO_SET_ENTRIES:
in compat handler, copy struct ebt_replace from user, check that
len == sizeof(struct compat_ebt_replace) + repl.entries_size

if yes, continue, else try non-compat handler.

Actually, one could move the call to the non-compat handler around
so that the non-compat handler is only called when this
particular error occurs and not on other errors, like e.g. EFAULT.

I can do this in the next version of the patch series.

EBT_SO_GET_INFO, EBT_SO_GET_INIT_INFO:
trivial: *len must be sizeof(struct compat_ebt_replace), else try
non-compat handler

EBT_SO_GET_ENTRIES, EBT_SO_GET_INIT_ENTRIES:
In the non-compat case, this check is easy:
len must be "sizeof(struct ebt_replace) + entries_size_in_kernel"
(and size of all counters, but this is irrelevant because the counters
 do not need compat fixups).

Thus in case of EBT_SO_GET_ENTRIES and EBT_SO_GET_INIT_ENTRIES
the native handler gets called first (compat_ translates
the kernel table first to determine how large the data set would be
in user space, so the check cannot be done right after copying struct
compat_ebt_replace from userspace).



  reply	other threads:[~2010-02-11 21:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-11 14:12 [PATCH v2 0/10] netfilter: ebtables: CONFIG_COMPAT support Florian Westphal
2010-02-11 14:12 ` [PATCH 01/10] netfilter: ebtables: abort if next_offset is too small Florian Westphal
2010-02-15 17:40   ` Patrick McHardy
2010-02-11 14:12 ` [PATCH 02/10] netfilter: ebtables: avoid explicit XT_ALIGN() in match/targets Florian Westphal
2010-02-15 17:40   ` Patrick McHardy
2010-02-11 14:12 ` [PATCH 03/10] netfilter: CONFIG_COMPAT: allow delta to exceed 32767 Florian Westphal
2010-02-15 16:33   ` Patrick McHardy
2010-02-15 16:37     ` Florian Westphal
2010-02-15 17:08       ` Patrick McHardy
2010-02-15 17:40   ` Patrick McHardy
2010-02-11 14:12 ` [PATCH 04/10] netfilter: ebtables: split do_replace into two functions Florian Westphal
2010-02-11 14:12 ` [PATCH 05/10] netfilter: ebtables: split copy_everything_to_user " Florian Westphal
2010-02-11 14:12 ` [PATCH 06/10] netfilter: ebtables: split update_counters " Florian Westphal
2010-02-11 14:12 ` [PATCH 07/10] netfilter: ebtables: add CONFIG_COMPAT support Florian Westphal
2010-02-11 14:12 ` [PATCH 08/10] netfilter: ebtables: try native set/getsockopt handlers, too Florian Westphal
2010-02-11 17:40   ` Patrick McHardy
2010-02-11 21:50     ` Florian Westphal [this message]
2010-02-11 14:12 ` [PATCH 09/10] netfilter: ebt_limit: add CONFIG_COMPAT support Florian Westphal
2010-02-13 13:20 ` [PATCH v2 0/10] netfilter: ebtables: " Bart De Schuymer
2010-02-13 13:31   ` Florian Westphal

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=20100211215004.GD27427@Chamillionaire.breakpoint.cc \
    --to=fw@strlen.de \
    --cc=bdschuym@pandora.be \
    --cc=kaber@trash.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).