netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: kaber@trash.net
Cc: klimes@centrum.cz, netdev@vger.kernel.org
Subject: Re: XFRM structures binary compability
Date: Wed, 14 Jan 2009 14:55:52 -0800 (PST)	[thread overview]
Message-ID: <20090114.145552.71463842.davem@davemloft.net> (raw)
In-Reply-To: <496B56B7.3080703@trash.net>

From: Patrick McHardy <kaber@trash.net>
Date: Mon, 12 Jan 2009 15:41:59 +0100

> klimes@centrum.cz wrote:
> > 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).

I'll commit the following and queue it up for -stable.

Thanks.

xfrm: For 32/64 compatability wrt. xfrm_usersa_info

Reported by Jiri Klimes.

Fix suggested by Patrick McHardy.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/xfrm/xfrm_user.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index b95a2d6..7877e79 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1914,10 +1914,17 @@ static int xfrm_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type,
 }
 #endif
 
+/* For the xfrm_usersa_info cases we have to work around some 32-bit vs.
+ * 64-bit compatability issues.  On 32-bit the structure is 220 bytes, but
+ * for 64-bit it gets padded out to 224 bytes.  Those bytes are just
+ * padding and don't have any content we care about.  Therefore as long
+ * as we have enough bytes for the content we can make both cases work.
+ */
+
 #define XMSGSIZE(type) sizeof(struct type)
 
 static const int xfrm_msg_min[XFRM_NR_MSGTYPES] = {
-	[XFRM_MSG_NEWSA       - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_info),
+	[XFRM_MSG_NEWSA       - XFRM_MSG_BASE] = 220, /* see above */
 	[XFRM_MSG_DELSA       - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_id),
 	[XFRM_MSG_GETSA       - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_id),
 	[XFRM_MSG_NEWPOLICY   - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_info),
@@ -1927,7 +1934,7 @@ static const int xfrm_msg_min[XFRM_NR_MSGTYPES] = {
 	[XFRM_MSG_ACQUIRE     - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_acquire),
 	[XFRM_MSG_EXPIRE      - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_expire),
 	[XFRM_MSG_UPDPOLICY   - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_info),
-	[XFRM_MSG_UPDSA       - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_info),
+	[XFRM_MSG_UPDSA       - XFRM_MSG_BASE] = 220, /* see above */
 	[XFRM_MSG_POLEXPIRE   - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_polexpire),
 	[XFRM_MSG_FLUSHSA     - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_flush),
 	[XFRM_MSG_FLUSHPOLICY - XFRM_MSG_BASE] = 0,
-- 
1.6.1.15.g159c88


  reply	other threads:[~2009-01-14 22:55 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
2009-01-14 22:55                   ` David Miller [this message]
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=20090114.145552.71463842.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=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 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).