Skip to contentSkip to conversation

xfrm: Do not parse 32bits compiled xfrm netlink msg on 64bits host

PATCH Superseded Fan Du 4 participants 5 messages Jan 27, 2015

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Fan Du

author
#0 lore raw

PATCH 1/1 xfrm: Do not parse 32bits compiled xfrm netlink msg on 64bits host

structure like xfrm_usersa_info or xfrm_userpolicy_info has different sizeof when compiled as 32bits and 64bits due to not appending pack attribute in their definition. This will result in broken SA and SP information when user trying to configure them through netlink interface.

Inform user land about this situation instead of keeping silent, the upper test scripts would behave accordingly.

Quotes from: http://marc.info/?l=linux-netdev&m=142226348715503&w=2

Quoted 4 lines

Before a clean solution show up, I think it's better to warn user in some way like http://patchwork.ozlabs.org/patch/323842/ did. Otherwise, many people who stuck there will always spend time and try to fix this issue in whatever way.

Yes, this is the first thing we should do. I'm willing to accept a patch

---
ChangeLog:
v2:
- Rebase with latest tree

---
 net/xfrm/xfrm_user.c |    5 +++++
 1 file changed, 5 insertions(+)
net/xfrm/xfrm_user.c +5 -0
index 8128594..f960bd9 100644
@@ -2419,6 +2419,11 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 	const struct xfrm_link *link;
 	int type, err;
 
+#ifdef CONFIG_COMPAT
+	if (is_compat_task())
+		return -EPERM;
+#endif
+
 	type = nlh->nlmsg_type;
 	if (type > XFRM_MSG_MAX)
 		return -EINVAL;
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw

From: Fan Du <[email protected]>
Date: Tue, 27 Jan 2015 10:54:22 +0800

net/xfrm/xfrm_user.c static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · line 2426

Quoted 9 lines
net/xfrm/xfrm_user.c +5 -0
@@ -2419,6 +2419,11 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 	const struct xfrm_link *link;
 	int type, err;
 
+#ifdef CONFIG_COMPAT
+	if (is_compat_task())
+		return -EPERM;
+#endif
+

This seems more like an unsupported operation rather then a permission problem.

#2 lore raw
Quoted 7 lines · David Miller

From: Fan Du <[email protected]>
Date: Tue, 27 Jan 2015 10:54:22 +0800

Quoted 4 lines
net/xfrm/xfrm_user.c +0 -0
@@ -2419,6 +2419,11 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
  	const struct xfrm_link *link;
  	int type, err;
 
Quoted 9 lines

net/xfrm/xfrm_user.c static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · line 2426

Quoted 5 lines
net/xfrm/xfrm_user.c +5 -0
+#ifdef CONFIG_COMPAT
+	if (is_compat_task())
+		return -EPERM;
+#endif
+

This seems more like an unsupported operation rather then a permission problem.

how about *ENOTSUPP* ?

Signature · 1 line
No zuo no die but I have to try.
maintainer
#3 lore raw

From: Fan Du <[email protected]>
Date: Tue, 27 Jan 2015 15:44:36 +0800

Quoted 18 lines
Quoted 8 lines · David Miller

From: Fan Du <[email protected]>
Date: Tue, 27 Jan 2015 10:54:22 +0800

Quoted 5 lines
net/xfrm/xfrm_user.c +0 -0
@@ -2419,6 +2419,11 @@ static int xfrm_user_rcv_msg(struct sk_buff
 *skb, struct nlmsghdr *nlh)
  	const struct xfrm_link *link;
  	int type, err;
 
Quoted 9 lines

net/xfrm/xfrm_user.c static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) · line 2426

Quoted 5 lines
net/xfrm/xfrm_user.c +5 -0
+#ifdef CONFIG_COMPAT
+	if (is_compat_task())
+		return -EPERM;
+#endif
+

This seems more like an unsupported operation rather then a permission problem.

Quoted 1 line

how about *ENOTSUPP* ?

Unquestionably, that is an improvement over EPERM.

#4 lore raw
Quoted 21 lines · David Miller

From: Fan Du <[email protected]>
Date: Tue, 27 Jan 2015 15:44:36 +0800

Quoted 18 lines
Quoted 17 lines · David Miller

From: Fan Du <[email protected]>
Date: Tue, 27 Jan 2015 10:54:22 +0800

net/xfrm/xfrm_user.c static int xfrm_user_rcv_msg(struct sk_buff · line 2427

Quoted 10 lines
net/xfrm/xfrm_user.c +5 -0
@@ -2419,6 +2419,11 @@ static int xfrm_user_rcv_msg(struct sk_buff
 *skb, struct nlmsghdr *nlh)
  	const struct xfrm_link *link;
  	int type, err;
 
+#ifdef CONFIG_COMPAT
+	if (is_compat_task())
+		return -EPERM;
+#endif
+

This seems more like an unsupported operation rather then a permission problem.

Quoted 3 lines
Quoted 1 line

how about *ENOTSUPP* ?

Unquestionably, that is an improvement over EPERM.

But it should be EOPNOTSUPP rather than ENOTSUP, right?

-Bill