From: Patrick McHardy <kaber@trash.net>
To: klimes@centrum.cz
Cc: netdev@vger.kernel.org
Subject: Re: XFRM structures binary compability
Date: Mon, 12 Jan 2009 15:41:59 +0100 [thread overview]
Message-ID: <496B56B7.3080703@trash.net> (raw)
In-Reply-To: <200901121454.21748@centrum.cz>
klimes@centrum.cz wrote:
> Hello,
>
> I face a problem due to binary incompatibility of XFRM structures.
>
> I use XFRM interface to create IPsec SAs. My user application is compiled as 32bit binary.
> It works properly when running against 32bit kernel. However when I've run it on 64bit kernel, netlink returns an error (EINVAL).
> I use Fedora for both 32 and 64-bit environment.
>
> I'm aware that it is due to incompatibility (different alignment and padding) of XFRM structures passed between user space and kernel
> (defined here for user space: /usr/include/linux/xfrm.h)
> My question is: shall not the structures be designed to be the same in 32 and 64bit environment?
> I think a padding should be added to meet the more strict alignment rules (i.e. 64bit environment).
>
> I used pahole tool (available in dwarves package) to display structure alignment (see attachment).
> pahole_32.txt - structures from 32bit binary
> pahole_64.txt - structures from 64bit binary
>
> What causes my trouble is "xfrm_usersa_info" which is padded with 7 bytes at the end in 64-bit,
> so that the whole structure is 224 bytes in 64bit application against 220 bytes in 32bit (just 3-byte padding).
> An explicit 7-byte padding in the structure would cure the case, IMHO.
That would break on 32 bit because userspace binaries compiled
with the old layout would send "short" messages. I'd suggest
to explicitly use the smaller value for the xfrm_msg_min checks
(i.e. replace sizeof by numerical constant).
next prev parent reply other threads:[~2009-01-12 14:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200901091324.3936@centrum.cz>
[not found] ` <200901091325.24572@centrum.cz>
[not found] ` <200901091326.18260@centrum.cz>
[not found] ` <200901091327.25342@centrum.cz>
[not found] ` <200901091328.6816@centrum.cz>
[not found] ` <200901091329.27638@centrum.cz>
[not found] ` <200901091330.17816@centrum.cz>
[not found] ` <200901091331.18342@centrum.cz>
2009-01-12 13:54 ` XFRM structures binary compability klimes
2009-01-12 14:41 ` Patrick McHardy [this message]
2009-01-14 22:55 ` David Miller
2009-01-16 13:40 ` Jiri Klimes
2009-01-17 11:27 ` Herbert Xu
2009-01-27 5:14 ` David Miller
2009-01-18 7:13 ` David Miller
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=496B56B7.3080703@trash.net \
--to=kaber@trash.net \
--cc=klimes@centrum.cz \
--cc=netdev@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 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.