* [PATCH iproute2] ip xfrm: support 64bit kernel and 32bit userspace
@ 2014-11-28 6:58 roy.qing.li
2014-11-28 7:08 ` FengYu LeiDian
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: roy.qing.li @ 2014-11-28 6:58 UTC (permalink / raw)
To: netdev
From: Li RongQing <roy.qing.li@gmail.com>
The size of struct xfrm_userpolicy_info is 168 bytes for 64bit kernel, and
164 bytes for 32bit userspace because of the different alignment. and lead
to "ip xfrm" be unable to work.
add a pad in struct xfrm_userpolicy_info, and enable it by set
KERNEL_64_USERSPACE_32 to y
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
---
Makefile | 4 ++++
include/linux/xfrm.h | 3 +++
2 files changed, 7 insertions(+)
diff --git a/Makefile b/Makefile
index 9dbb29f..3cd0d67 100644
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,10 @@ ifneq ($(SHARED_LIBS),y)
DEFINES+= -DNO_SHARED_LIBS
endif
+ifeq ($(KERNEL_64_USERSPACE_32),y)
+DEFINES+= -DKNL_64_US_32
+endif
+
DEFINES+=-DCONFDIR=\"$(CONFDIR)\"
#options for decnet
diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h
index fa2ecb2..009510c 100644
--- a/include/linux/xfrm.h
+++ b/include/linux/xfrm.h
@@ -407,6 +407,9 @@ struct xfrm_userpolicy_info {
/* Automatically expand selector to include matching ICMP payloads. */
#define XFRM_POLICY_ICMP 2
__u8 share;
+#ifdef KNL_64_US_32
+ int pad;
+#endif
};
struct xfrm_userpolicy_id {
--
2.1.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH iproute2] ip xfrm: support 64bit kernel and 32bit userspace
2014-11-28 6:58 [PATCH iproute2] ip xfrm: support 64bit kernel and 32bit userspace roy.qing.li
@ 2014-11-28 7:08 ` FengYu LeiDian
2014-11-28 7:35 ` Li RongQing
2014-11-28 10:47 ` David Laight
2014-11-30 1:33 ` Ben Hutchings
2 siblings, 1 reply; 7+ messages in thread
From: FengYu LeiDian @ 2014-11-28 7:08 UTC (permalink / raw)
To: roy.qing.li; +Cc: netdev
于 2014年11月28日 14:58, roy.qing.li@gmail.com 写道:
> From: Li RongQing<roy.qing.li@gmail.com>
>
> The size of struct xfrm_userpolicy_info is 168 bytes for 64bit kernel, and
> 164 bytes for 32bit userspace because of the different alignment. and lead
> to "ip xfrm" be unable to work.
>
> add a pad in struct xfrm_userpolicy_info, and enable it by set
> KERNEL_64_USERSPACE_32 to y
It's not easy to fix it like this.
Refer:
http://marc.info/?l=linux-netdev&m=139280143513650&w=2
http://thread.gmane.org/gmane.linux.network/157118/focus=157122
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH iproute2] ip xfrm: support 64bit kernel and 32bit userspace
2014-11-28 7:08 ` FengYu LeiDian
@ 2014-11-28 7:35 ` Li RongQing
2014-11-28 8:07 ` FengYu LeiDian
0 siblings, 1 reply; 7+ messages in thread
From: Li RongQing @ 2014-11-28 7:35 UTC (permalink / raw)
To: FengYu LeiDian; +Cc: netdev
On Fri, Nov 28, 2014 at 3:08 PM, FengYu LeiDian
<fengyuleidian0615@gmail.com> wrote:
> 于 2014年11月28日 14:58, roy.qing.li@gmail.com 写道:
>> From: Li RongQing<roy.qing.li@gmail.com>
>>
>> The size of struct xfrm_userpolicy_info is 168 bytes for 64bit kernel, and
>> 164 bytes for 32bit userspace because of the different alignment. and lead
>> to "ip xfrm" be unable to work.
>>
>> add a pad in struct xfrm_userpolicy_info, and enable it by set
>> KERNEL_64_USERSPACE_32 to y
>
>
> It's not easy to fix it like this.
>
> Refer:
> http://marc.info/?l=linux-netdev&m=139280143513650&w=2
> http://thread.gmane.org/gmane.linux.network/157118/focus=157122
>
is it be practical to find all structures which has the issue for
64bit kernel and 32 bit
userspace, and conditionally add a pad for them
-Roy
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH iproute2] ip xfrm: support 64bit kernel and 32bit userspace
2014-11-28 7:35 ` Li RongQing
@ 2014-11-28 8:07 ` FengYu LeiDian
0 siblings, 0 replies; 7+ messages in thread
From: FengYu LeiDian @ 2014-11-28 8:07 UTC (permalink / raw)
To: Li RongQing; +Cc: netdev
于 2014年11月28日 15:35, Li RongQing 写道:
> On Fri, Nov 28, 2014 at 3:08 PM, FengYu LeiDian
> <fengyuleidian0615@gmail.com> wrote:
>> >于 2014年11月28日 14:58,roy.qing.li@gmail.com 写道:
>>> >>From: Li RongQing<roy.qing.li@gmail.com>
>>> >>
>>> >>The size of struct xfrm_userpolicy_info is 168 bytes for 64bit kernel, and
>>> >>164 bytes for 32bit userspace because of the different alignment. and lead
>>> >>to "ip xfrm" be unable to work.
>>> >>
>>> >>add a pad in struct xfrm_userpolicy_info, and enable it by set
>>> >>KERNEL_64_USERSPACE_32 to y
>> >
>> >
>> >It's not easy to fix it like this.
>> >
>> >Refer:
>> >http://marc.info/?l=linux-netdev&m=139280143513650&w=2
>> >http://thread.gmane.org/gmane.linux.network/157118/focus=157122
>> >
> is it be practical to find all structures which has the issue for
> 64bit kernel and 32 bit
> userspace, and conditionally add a pad for them
Apparently struct xfrm_userpolicy_info is not the only one,
you could try to set SA as well, it breaks also...
Fix those where it hurts, hehe :) Otherwise, the "compat layer"
fix style is good choice.
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH iproute2] ip xfrm: support 64bit kernel and 32bit userspace
2014-11-28 6:58 [PATCH iproute2] ip xfrm: support 64bit kernel and 32bit userspace roy.qing.li
2014-11-28 7:08 ` FengYu LeiDian
@ 2014-11-28 10:47 ` David Laight
2014-11-30 1:33 ` Ben Hutchings
2 siblings, 0 replies; 7+ messages in thread
From: David Laight @ 2014-11-28 10:47 UTC (permalink / raw)
To: 'roy.qing.li@gmail.com', netdev@vger.kernel.org
From: roy.qing.li@gmail.com
> From: Li RongQing <roy.qing.li@gmail.com>
>
> The size of struct xfrm_userpolicy_info is 168 bytes for 64bit kernel, and
> 164 bytes for 32bit userspace because of the different alignment. and lead
> to "ip xfrm" be unable to work.
>
> add a pad in struct xfrm_userpolicy_info, and enable it by set
> KERNEL_64_USERSPACE_32 to y
...
> diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h
> index fa2ecb2..009510c 100644
> --- a/include/linux/xfrm.h
> +++ b/include/linux/xfrm.h
> @@ -407,6 +407,9 @@ struct xfrm_userpolicy_info {
> /* Automatically expand selector to include matching ICMP payloads. */
> #define XFRM_POLICY_ICMP 2
> __u8 share;
> +#ifdef KNL_64_US_32
> + int pad;
> +#endif
> };
You could add __attribute__((aligned(8))) to the structure to pad it on
all systems.
Or find the 64bit member and add __attribute__((aligned(4))) to that member
so that the 64bit version doesn't get padded.
That will make the field more expensive to access on systems that can't
do misaligned memory transfers.
David
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH iproute2] ip xfrm: support 64bit kernel and 32bit userspace
2014-11-28 6:58 [PATCH iproute2] ip xfrm: support 64bit kernel and 32bit userspace roy.qing.li
2014-11-28 7:08 ` FengYu LeiDian
2014-11-28 10:47 ` David Laight
@ 2014-11-30 1:33 ` Ben Hutchings
2014-11-30 17:42 ` Stephen Hemminger
2 siblings, 1 reply; 7+ messages in thread
From: Ben Hutchings @ 2014-11-30 1:33 UTC (permalink / raw)
To: roy.qing.li; +Cc: netdev
[-- Attachment #1: Type: text/plain, Size: 838 bytes --]
On Fri, 2014-11-28 at 14:58 +0800, roy.qing.li@gmail.com wrote:
> From: Li RongQing <roy.qing.li@gmail.com>
>
> The size of struct xfrm_userpolicy_info is 168 bytes for 64bit kernel, and
> 164 bytes for 32bit userspace because of the different alignment.
I think it's specific to x86 as other architectures have the same type
alignments for 32- and 64-bit variants.
> and lead to "ip xfrm" be unable to work.
>
> add a pad in struct xfrm_userpolicy_info, and enable it by set
> KERNEL_64_USERSPACE_32 to y
[...]
This doesn't make sense. 32-bit compat needs to work like 32-bit native
- no exceptions, no workarounds in userland. And if you really want to
work around this in userland you'll need a run-time, not compile-time,
check.
Ben.
--
Ben Hutchings
The world is coming to an end. Please log off.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 811 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH iproute2] ip xfrm: support 64bit kernel and 32bit userspace
2014-11-30 1:33 ` Ben Hutchings
@ 2014-11-30 17:42 ` Stephen Hemminger
0 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2014-11-30 17:42 UTC (permalink / raw)
To: Ben Hutchings; +Cc: roy.qing.li, netdev
[-- Attachment #1: Type: text/plain, Size: 973 bytes --]
On Sun, 30 Nov 2014 01:33:22 +0000
Ben Hutchings <ben@decadent.org.uk> wrote:
> On Fri, 2014-11-28 at 14:58 +0800, roy.qing.li@gmail.com wrote:
> > From: Li RongQing <roy.qing.li@gmail.com>
> >
> > The size of struct xfrm_userpolicy_info is 168 bytes for 64bit kernel, and
> > 164 bytes for 32bit userspace because of the different alignment.
>
> I think it's specific to x86 as other architectures have the same type
> alignments for 32- and 64-bit variants.
>
> > and lead to "ip xfrm" be unable to work.
> >
> > add a pad in struct xfrm_userpolicy_info, and enable it by set
> > KERNEL_64_USERSPACE_32 to y
> [...]
>
> This doesn't make sense. 32-bit compat needs to work like 32-bit native
> - no exceptions, no workarounds in userland. And if you really want to
> work around this in userland you'll need a run-time, not compile-time,
> check.
I agree with Ben, this is not a good solution.
It creates a 3rd ABI (32, 64, and 32/64).
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-11-30 17:42 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-28 6:58 [PATCH iproute2] ip xfrm: support 64bit kernel and 32bit userspace roy.qing.li
2014-11-28 7:08 ` FengYu LeiDian
2014-11-28 7:35 ` Li RongQing
2014-11-28 8:07 ` FengYu LeiDian
2014-11-28 10:47 ` David Laight
2014-11-30 1:33 ` Ben Hutchings
2014-11-30 17:42 ` Stephen Hemminger
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).