From: Laszlo Valko <valko@linux.karinthy.hu>
To: Anders Fugmann <afu@fugmann.dhs.org>
Cc: Thomas Heinz <creatix@hipac.org>, netfilter-devel@lists.netfilter.org
Subject: Re: Comments about IPT_ALIGN
Date: Sun, 26 Jan 2003 15:22:27 +0100 [thread overview]
Message-ID: <20030126152227.A6811@linux.karinthy.hu> (raw)
In-Reply-To: <3E33C665.9080106@fugmann.dhs.org>; from afu@fugmann.dhs.org on Sun, Jan 26, 2003 at 12:28:37PM +0100
On Sun, Jan 26, 2003 at 12:28:37PM +0100, Anders Fugmann wrote:
> Does this not pose an interresting problem?
> What happens if userspace is 32bit, and kernel space is 64bit, when the
> elements of the structure changes size doe to conversion?
> Eg:
> struct x {
> int a;
> long int b;
> int c;
> }
>
> In 32bit userspace, x->a would have offset 0, x->b would have offset 4
> and x->c would have offset 8. But in 64bit kernel space, the long in
> would be 64 bit, and so the offset changes: offset x->a = 0, offset x->b
> = 4, offset x->c = 12. The structure would then need a special
> conversion from 32 bit userspace to 64 bit kernel space in order for
> values in the struct to be accessed correctly. If this is true, then we
Yes, that structure needs a special conversion for 32/64 platforms.
That's the reason netfilter from plain 2.4.20 kernel does not work
correctly on sparc64 (with 32-bit userspace). Fortunately, there are
not too many such misdesigns in there :)
Even a structure like that is not better:
struct {
long c;
};
Even if you IPT_ALIGN the whole thing, and memset with zeros, on bigendian
machines "c" (as seen from kernelside) will have its MSB 32-bit filled with
"c" from the userspace. That's the current situation with ipt_MARK for example.
> must only use type with welldifined sizes, that is sizes that does not
> changes from userspace to kernel space.
>
> Please correct me if I'm wrong.
>
> Regards
> Anders Fugmann
You are right. There's only one question left: what and how to change to
a) make everything work on all platforms,
b) introduce as little incompatibilities as possible,
c) avoid kernel code duplication just to maintain backward compatibility,
d) avoid doing #if defined(__sparcv9__) || defined(__hppa64__) (or whatever
it's called) in kernel headers (I guess it would be difficult to get that
into mainline as far as I know DaveM, and not without grounds),
e) avoid defining local copies of hack kernel headers and doing something like
#if sizeof(unsigned long) == 4 && defined (KERNEL_LOOKS_LIKE_SPARC64)
in userspace (a maintenance nightmare to have several copies of the
same structure)
all at the same time.
Currently, I see two ways:
1) make a translation function for all currently existing netfilter structures
that use longs or pointers (difficult, as modules can be added independently),
like those in arch/sparc64/sys_sparc32.c, and its friends,
2) introduce a new way of passing structures, with new structures, probably
with new setsockopt/getsockopt numbers, essentially creating an API
incompatible with the existing one (there are a few other bleeding wounds
waiting to be solved in the existing interface as I saw).
Maybe combining those two to provide a compatibility layer with 1) and
introduce a new layer with 2). And making the old interface a config
option (CONFIG_NETFILTER_OLD_INTERFACE).
Now I'm interested what other people think about the possibilities...
Regards,
Laszlo
next prev parent reply other threads:[~2003-01-26 14:22 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-26 3:57 Comments about IPT_ALIGN Thomas Heinz
2003-01-26 11:01 ` Laszlo Valko
2003-01-26 11:28 ` Anders Fugmann
2003-01-26 13:58 ` Thomas Heinz
2003-01-26 14:26 ` Laszlo Valko
2003-01-26 16:50 ` Thomas Heinz
2003-01-26 19:31 ` Laszlo Valko
2003-01-31 11:51 ` Harald Welte
2003-01-26 14:22 ` Laszlo Valko [this message]
2003-01-26 18:05 ` Thomas Heinz
2003-01-26 19:43 ` Laszlo Valko
2003-01-26 23:09 ` Thomas Heinz
2003-01-27 0:43 ` Laszlo Valko
2003-01-27 10:33 ` Thomas Heinz
2003-01-31 11:57 ` Harald Welte
2003-01-26 19:48 ` Thomas Heinz
2003-01-31 11:55 ` Harald Welte
2003-01-31 23:37 ` Laszlo Valko
2003-01-26 17:06 ` Thomas Heinz
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=20030126152227.A6811@linux.karinthy.hu \
--to=valko@linux.karinthy.hu \
--cc=afu@fugmann.dhs.org \
--cc=creatix@hipac.org \
--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.