Skip to contentSkip to conversation

: nlmsg length not computed correctly in the presence of subpolicies

PATCH Applied jamal 3 participants 3 messages Nov 17, 2006 – Nov 19, 2006

Subsystems (3)
lore
Share & tools
lore

jamal

author
#0 lore raw

PATCH 1/1 : nlmsg length not computed correctly in the presence of subpolicies

Another one in the same spirit as before. Compiles. I dont have a good test case, but looks right.
Nakamura-san please ACK and Dave (as before this goes in as a bug-fix).

cheers,
jamal

[XFRM]: nlmsg length not computed correctly in the presence of subpolicies

I actually dont have a test case for these; i just found them by inspection. Refer to patch "[XFRM]: Sub-policies broke policy events" for more info

---
commit c3d793454ab2a36c2d618d226d7de975ab9b7570
tree 26198ba84d85317b4f1b54c0e10c220dbe0d97da
parent b53ec68c276ac1d879759de130620a72254cb969
author Jamal Hadi Salim <[email protected]> Fri, 17 Nov 2006 08:39:52 -0500 committer Jamal Hadi Salim <hadi@jzny2.(none)> Fri, 17 Nov 2006 08:39:52 -0500

 net/xfrm/xfrm_user.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
net/xfrm/xfrm_user.c +9 -1
index 2dae1c1..c4cde57 100644
@@ -1927,6 +1927,9 @@ static int xfrm_send_acquire(struct xfrm
 	len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr);
 	len += NLMSG_SPACE(sizeof(struct xfrm_user_acquire));
 	len += RTA_SPACE(xfrm_user_sec_ctx_size(xp));
+#ifdef CONFIG_XFRM_SUB_POLICY
+	len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type));
+#endif
 	skb = alloc_skb(len, GFP_ATOMIC);
 	if (skb == NULL)
 		return -ENOMEM;
@@ -2034,6 +2037,9 @@ static int xfrm_exp_policy_notify(struct
 	len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr);
 	len += NLMSG_SPACE(sizeof(struct xfrm_user_polexpire));
 	len += RTA_SPACE(xfrm_user_sec_ctx_size(xp));
+#ifdef CONFIG_XFRM_SUB_POLICY
+	len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type));
+#endif
 	skb = alloc_skb(len, GFP_ATOMIC);
 	if (skb == NULL)
 		return -ENOMEM;
@@ -2109,10 +2115,12 @@ static int xfrm_notify_policy_flush(stru
 	struct nlmsghdr *nlh;
 	struct sk_buff *skb;
 	unsigned char *b;
+	int len = 0;
 #ifdef CONFIG_XFRM_SUB_POLICY
 	struct xfrm_userpolicy_type upt;
+	len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type));
 #endif
-	int len = NLMSG_LENGTH(0);
+	len += NLMSG_LENGTH(0);
 
 	skb = alloc_skb(len, GFP_ATOMIC);
 	if (skb == NULL)
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · On Fri, 17 Nov 2006 08:48:31 -0500 jamal <[email protected]> wrote:

Another one in the same spirit as before. Compiles. I dont have a good test case, but looks right.
Nakamura-san please ACK and Dave (as before this goes in as a bug-fix).

I've tested with your patch and the result is fine.

However, unlike the add/delete XFRM policy case pointed by Jamal as the previous patch, I don't see the error without this patch on my environment about acqiure.
(Maybe, does acquire path happen to make some buffer for policy type since the structures is not aligned cleanly?)

..Anyway, the fix is correct for me. David, please apply it, too.

Quoted 14 lines

[XFRM]: nlmsg length not computed correctly in the presence of subpolicies

I actually dont have a test case for these; i just found them by inspection. Refer to patch "[XFRM]: Sub-policies broke policy events" for more info

---
commit c3d793454ab2a36c2d618d226d7de975ab9b7570
tree 26198ba84d85317b4f1b54c0e10c220dbe0d97da
parent b53ec68c276ac1d879759de130620a72254cb969
author Jamal Hadi Salim <[email protected]> Fri, 17 Nov 2006 08:39:52 -0500 committer Jamal Hadi Salim <hadi@jzny2.(none)> Fri, 17 Nov 2006 08:39:52 -0500

Signature · 1 line
Masahide NAKAMURA
maintainer Applied
#2 lore raw

From: Masahide NAKAMURA <[email protected]>
Date: Sat, 18 Nov 2006 18:08:42 +0900

Quoted 11 lines
Quoted 3 lines · On Fri, 17 Nov 2006 08:48:31 -0500 jamal <[email protected]> wrote:

Another one in the same spirit as before. Compiles. I dont have a good test case, but looks right.
Nakamura-san please ACK and Dave (as before this goes in as a bug-fix).

I've tested with your patch and the result is fine.

Quoted 7 lines

However, unlike the add/delete XFRM policy case pointed by Jamal as the previous patch, I don't see the error without this patch on my environment about acqiure.
(Maybe, does acquire path happen to make some buffer for policy type since the structures is not aligned cleanly?)

..Anyway, the fix is correct for me. David, please apply it, too.

Applied, thanks.