Commit:     b5505c6e1071b32176c7548a3aaf0be49f7c763e
Parent:     705962ccc9d21a08b74b6b6e1d3cf10f98968a67
Author:     Herbert Xu <[EMAIL PROTECTED]>
AuthorDate: Mon May 14 02:15:47 2007 -0700
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Mon May 14 02:15:47 2007 -0700

    [IPSEC]: Check validity of direction in xfrm_policy_byid
    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 <[EMAIL PROTECTED]>
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
 net/xfrm/xfrm_policy.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 95271e8..d0882e5 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -796,6 +796,10 @@ struct xfrm_policy *xfrm_policy_byid(u8 type, int dir, u32 
id, int delete,
        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 git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to