Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=4bda4f250d21c3e4f2a2da5f4cef829a434a4046
Commit:     4bda4f250d21c3e4f2a2da5f4cef829a434a4046
Parent:     5e41fb83216d370d158fe17675af82d12c6c72c9
Author:     Pavel Emelyanov <[EMAIL PROTECTED]>
AuthorDate: Fri Dec 14 11:38:04 2007 -0800
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Mon Jan 28 14:58:07 2008 -0800

    [XFRM]: Fix potential race vs xfrm_state(only)_find and xfrm_hash_resize.
    
    The _find calls calculate the hash value using the
    xfrm_state_hmask, without the xfrm_state_lock. But the
    value of this mask can change in the _resize call under
    the state_lock, so we risk to fail in finding the desired
    entry in hash.
    
    I think, that the hash value is better to calculate
    under the state lock.
    
    Signed-off-by: Pavel Emelyanov <[EMAIL PROTECTED]>
    Signed-off-by: David S. Miller <[EMAIL PROTECTED]>
---
 net/xfrm/xfrm_state.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index b2343d4..f7c0951 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -756,7 +756,7 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t 
*saddr,
                struct xfrm_policy *pol, int *err,
                unsigned short family)
 {
-       unsigned int h = xfrm_dst_hash(daddr, saddr, tmpl->reqid, family);
+       unsigned int h;
        struct hlist_node *entry;
        struct xfrm_state *x, *x0;
        int acquire_in_progress = 0;
@@ -764,6 +764,7 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t 
*saddr,
        struct xfrm_state *best = NULL;
 
        spin_lock_bh(&xfrm_state_lock);
+       h = xfrm_dst_hash(daddr, saddr, tmpl->reqid, family);
        hlist_for_each_entry(x, entry, xfrm_state_bydst+h, bydst) {
                if (x->props.family == family &&
                    x->props.reqid == tmpl->reqid &&
@@ -865,11 +866,12 @@ struct xfrm_state *
 xfrm_stateonly_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
                    unsigned short family, u8 mode, u8 proto, u32 reqid)
 {
-       unsigned int h = xfrm_dst_hash(daddr, saddr, reqid, family);
+       unsigned int h;
        struct xfrm_state *rx = NULL, *x = NULL;
        struct hlist_node *entry;
 
        spin_lock(&xfrm_state_lock);
+       h = xfrm_dst_hash(daddr, saddr, reqid, family);
        hlist_for_each_entry(x, entry, xfrm_state_bydst+h, bydst) {
                if (x->props.family == family &&
                    x->props.reqid == reqid &&
-
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  http://vger.kernel.org/majordomo-info.html

Reply via email to