[lkml]   [2007]   [May]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[patch 53/69] IPSEC: Check validity of direction in xfrm_policy_byid
-stable review patch.  If anyone has any objections, please let us know.

From: Herbert Xu <>

The function xfrm_policy_byid takes a dir argument but finds the policy
using the index instead. We only use the dir argument to update the
policy count for that direction. Since the user can supply any value
for dir, this can corrupt our policy count.

I know this is the problem because a few days ago I was deleting
policies by hand using indicies and accidentally typed in the wrong
direction. It still deleted the policy and at the time I thought
that was cool. In retrospect it isn't such a good idea :)

I decided against letting it delete the policy anyway just in case
we ever remove the connection between indicies and direction.

Signed-off-by: Herbert Xu <>
Signed-off-by: David S. Miller <>
Signed-off-by: Chris Wright <>

net/xfrm/xfrm_policy.c | 4 ++++
1 file changed, 4 insertions(+)

--- linux-
+++ linux-
@@ -782,6 +782,10 @@ struct xfrm_policy *xfrm_policy_byid(u8
struct hlist_head *chain;
struct hlist_node *entry;

+ *err = -ENOENT;
+ if (xfrm_policy_id2dir(id) != dir)
+ return NULL;
*err = 0;
chain = xfrm_policy_byidx + idx_hash(id);
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2007-05-21 21:51    [W:0.665 / U:27.124 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site