Re: different packing of structs in kernel vs. userland ?

2002-07-15 Thread David Taylor
On Tue, 16 Jul 2002, David Taylor wrote: Bah, ignore me, it appears you've already admitted your post was rather less than clear :) -- David Taylor [EMAIL PROTECTED] "The future just ain't what it used to be" To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in

Re: different packing of structs in kernel vs. userland ?

2002-07-15 Thread David Taylor
On Mon, 15 Jul 2002, Terry Lambert wrote: > Thomas Moestl wrote: > > > He's making the valid point that for: > > > > > > struct foo *fee; > > > > > > It's possible that: > > > > > > sizeof(struct foo) != (((char *)&fee[1]) - ((char *)&fee[0])) > > > > No, I do not. In fact, the opposi

Re: different packing of structs in kernel vs. userland ?

2002-07-15 Thread Terry Lambert
Richard Tobin wrote: > It is not a valid point that it's possible that > > sizeof(struct foo) != (((char *)&fee[1]) - ((char *)&fee[0])) > > because it isn't possible. It must be the case that > > sizeof(struct foo) == (((char *)&fee[1]) - ((char *)&fee[0])) > > If that's what you meant,

Re: different packing of structs in kernel vs. userland ?

2002-07-15 Thread Richard Tobin
> If everyone could read the text past my example of bad math, so > that they could know it was an intentional example of bad math, > live would be beautiful. 8-). I did read past it, and I just read it again, and I can't make it come out any way other than it did the first time. You said: > H

Re: different packing of structs in kernel vs. userland ?

2002-07-15 Thread Terry Lambert
Richard Tobin wrote: > Er, no, that's not right. Otherwise [ ... ] If everyone could read the text past my example of bad math, so that they could know it was an intentional example of bad math, live would be beautiful. 8-). -- Terry To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsub

Re: different packing of structs in kernel vs. userland ?

2002-07-15 Thread Terry Lambert
Peter Edwards wrote: > > He's making the valid point that for: > > > > struct foo *fee; > > > > It's possible that: > > > > sizeof(struct foo) != (((char *)&fee[1]) - ((char *)&fee[0])) > > Wouldn't that mean > > .. struct X *xarr = malloc(sizeof (struct X) * arrayLen); > > woul

Re: different packing of structs in kernel vs. userland ?

2002-07-15 Thread Terry Lambert
Thomas Moestl wrote: > > He's making the valid point that for: > > > > struct foo *fee; > > > > It's possible that: > > > > sizeof(struct foo) != (((char *)&fee[1]) - ((char *)&fee[0])) > > No, I do not. In fact, the opposite: > > sizeof(struct foo) = (((char *)&fee[1]) - ((c

Re: different packing of structs in kernel vs. userland ?

2002-07-15 Thread Mike Barcroft
Thomas Moestl <[EMAIL PROTECTED]> writes: > Oh, right, that's related: the kernel checks for a minimum size of the > passed data on two occasions, first in sooptcopyin(), and then again > in check_ipfw_struct(). > It the size to be at least sizeof(struct ip_fw), however for > structures containing

Re: different packing of structs in kernel vs. userland ?

2002-07-15 Thread Luigi Rizzo
ok, convincing explaination, thanks! I will review the code and try to implement a proper fix, not the workaround that I put in. cheers luigi To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message

Re: different packing of structs in kernel vs. userland ?

2002-07-15 Thread Richard Tobin
> struct foo *fee; > > It's possible that: > > sizeof(struct foo) != (((char *)&fee[1]) - ((char *)&fee[0])) > > because of end-padding, which is not accounted for in arrays, Er, no, that's not right. Otherwise fee = malloc(n * sizeof(struct foo)) wouldn't work. C89 says:

Re: different packing of structs in kernel vs. userland ?

2002-07-15 Thread Peter Edwards
Hi, > He's making the valid point that for: > > struct foo *fee; > > It's possible that: > > sizeof(struct foo) != (((char *)&fee[1]) - ((char *)&fee[0])) Wouldn't that mean .. struct X *xarr = malloc(sizeof (struct X) * arrayLen); wouldn't produce a useable array of struct X o

Re: different packing of structs in kernel vs. userland ?

2002-07-15 Thread Thomas Moestl
On Mon, 2002/07/15 at 04:24:33 -0700, Terry Lambert wrote: > Luigi Rizzo wrote: > > sorry but all this just does not make sense to me. > > > > sizeof(foo) should give the same result irrespective of > > where you use it. > > > > Perhaps the best thing would be to put a > > > > printf("s

Re: different packing of structs in kernel vs. userland ?

2002-07-15 Thread Thomas Moestl
On Mon, 2002/07/15 at 04:00:08 -0700, Luigi Rizzo wrote: > sorry but all this just does not make sense to me. > > sizeof(foo) should give the same result irrespective of > where you use it. OK, let me rephrase it: as I explained before, struct ip_fw has padding after 'cmd' (the last member) to e

Re: different packing of structs in kernel vs. userland ?

2002-07-15 Thread Terry Lambert
Luigi Rizzo wrote: > sorry but all this just does not make sense to me. > > sizeof(foo) should give the same result irrespective of > where you use it. > > Perhaps the best thing would be to put a > > printf("struct ip_fw has size %d\n", sizeof(struct ip_fw)); > > both in ipfw2.c and s

Re: different packing of structs in kernel vs. userland ?

2002-07-15 Thread Luigi Rizzo
sorry but all this just does not make sense to me. sizeof(foo) should give the same result irrespective of where you use it. Perhaps the best thing would be to put a printf("struct ip_fw has size %d\n", sizeof(struct ip_fw)); both in ipfw2.c and somewhere in ip_fw2.c and see if there i

Re: different packing of structs in kernel vs. userland ?

2002-07-15 Thread Thomas Moestl
On Sun, 2002/07/14 at 23:08:21 -0400, Mike Barcroft wrote: > Thomas Moestl <[EMAIL PROTECTED]> writes: > > (Disclaimer: my solution below is untested, so it may all be bogus) > > As request, here are the test results. > > Most rules work, except my final one: > %%% > bowie# ipfw add allow all fr

Re: different packing of structs in kernel vs. userland ?

2002-07-14 Thread Mike Barcroft
Thomas Moestl <[EMAIL PROTECTED]> writes: > (Disclaimer: my solution below is untested, so it may all be bogus) As request, here are the test results. Most rules work, except my final one: %%% bowie# ipfw add allow all from any to any ipfw: getsockopt(IP_FW_ADD): Invalid argument %%% Here's a l

Re: different packing of structs in kernel vs. userland ?

2002-07-14 Thread Thomas Moestl
On Sun, 2002/07/14 at 13:43:37 -0700, Luigi Rizzo wrote: > [i am deliberately not trimming the email in case someone wants to > look at the context] > > i am a bit dubious about your explaination -- it also does not > explain why the person reporting this problem "fixed" that > by swapping "times

Re: different packing of structs in kernel vs. userland ?

2002-07-14 Thread Luigi Rizzo
[i am deliberately not trimming the email in case someone wants to look at the context] i am a bit dubious about your explaination -- it also does not explain why the person reporting this problem "fixed" that by swapping "timestamp" and "next_rule" in the structure cheers luigi

Re: different packing of structs in kernel vs. userland ?

2002-07-14 Thread Thomas Moestl
On Sun, 2002/07/14 at 01:18:10 -0700, Luigi Rizzo wrote: > Hi, > the following message seems to suggest that the compiler > (the way it is invoked) packs structures differently > when building the kernel and userland. > > The stize of the structure in question is computed > by both kernel and use

Re: different packing of structs in kernel vs. userland ?

2002-07-14 Thread Terry Lambert
Luigi Rizzo wrote: > Hi, > the following message seems to suggest that the compiler > (the way it is invoked) packs structures differently > when building the kernel and userland. > > The stize of the structure in question is computed > by both kernel and userland app using sizeof(), > so there i